1,183
社区成员
发帖
与我相关
我的任务
分享
unit Ifly_Stts;
interface
implementation
// 各种声音格式
Const
TTS_ADF_DEFAULT = 0;
TTS_ADF_PCM8K8B1C = 1;
TTS_ADF_PCM16K8B1C = 2;
TTS_ADF_PCM8K16B1C = 3;
TTS_ADF_PCM16K16B1C = 4;
TTS_ADF_PCM11K8B1C = 5;
TTS_ADF_PCM11K16B1C = 6;
TTS_ADF_ALAW16K1C = 9;
TTS_ADF_ULAW16K1C = 10;
TTS_ADF_ALAW8K1C = 11;
TTS_ADF_ULAW8K1C = 12;
TTS_ADF_ALAW11K1C = 13;
TTS_ADF_ULAW11K1C = 14;
TTS_ADF_ADPCMG7218K4B1C = 17;
TTS_ADF_ADPCMG7216K4B1C = 18;
TTS_ADF_ADPCMG7233B1C = 19;
TTS_ADF_ADPCMG7235B1C = 20;
TTS_ADF_VOX6K1C = 21;
TTS_ADF_VOX8K1C = 22;
//文本内码
TTS_CP_GB2312 = 1
TTS_CP_GBK = 2
TTS_CP_UNICODE = 4
//'参数类型
TTS_PARAM_LOCAL_BASE = &H0;
TTS_PARAM_INBUFSIZE = &H1;
TTS_PARAM_OUTBUFSIZE = &H2;
TTS_PARAM_VID = &H3;
TTS_PARAM_CODEPAGE = &H4;
TTS_PARAM_AUDIODATAFMT = &H5;
TTS_PARAM_SPEED = &H6;
TTS_PARAM_AUDIOHEADFMT = &H7;
TTS_PARAM_VOLUME = &H8;
TTS_PARAM_PITCH = &H9;
type
//'================================================================
//' STTS Api 声明
//'================================================================
//' 初始化
function STTSInit():boolean;stdcall;
external 'STTSApi.dll';
//' 逆初始化
function STTSDeInit():boolean;stdcall;
external 'STTSApi.dll';
//' 建立与TTS服务器的连接
function STTSConnect(sSerialNumber:string;sServerIP:string):Integer;stdcall;
external 'STTSApi.dll';
//' 断开与TTS服务器的连接
Function STTSDisconnect(hTTSInstance:Integer):boolean;stdcall;
external 'STTSApi.dll';
//' 设置本次连接的合成参数
Function STTSSetParam(hTTSInstance:integer;lngType:integer;lngParam:integer):Boolean;stdcall;
external 'STTSApi.dll';
//' 获得本次连接的合成参数
Function STTSGetParam(hTTSInstance:Integer;lngType:integer;lngParam:integer):Boolean;stdcall;
external 'STTSApi.dll';
//' 从字符串合成到音频文件
Function STTSString2AudioFile(hTTSInstance:Integer;sString:string;sWaveFile:string):Boolean;stdcall;
external 'STTSApi.dll';
//' 从文本文件合成到音频文件
Function STTSFile2AudioFile(hTTSInstance:Integer;sTextFile:string;sWaveFile:string):Boolean;stdcall;
external 'STTSApi.dll';
//'播放字符串
Function STTSPlayString(hTTSInstance:Integer;sTextFile:string;bAsynch:Boolean):Boolean;stdcall;
external 'STTSApi.dll';
//'播放文本文件
Function SSTTSPlayTextFile(hTTSInstance:Integer;sTextFile:string;bAsynch:Boolean):Boolean;stdcall;
external 'STTSApi.dll';
//'播放停止
Function STTSPlayStop():Boolean;stdcall;
external 'STTSApi.dll';
//'查询播放状态
Function STTSQueryPlayStatus(lngStatus:Integer):Boolean;stdcall;
external 'STTSApi.dll';
//'TTS版本信息
Function STTSAbout(sAboutInfo:string;ninfosize:Integer):Boolean;stdcall;
external 'STTSApi.dll';
//' 用来获取错误代码的Windows API函数
//Public Declare Function GetLastError Lib "kernel32" () As Long
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//'================================================================
//' STTS Api 声明
//'================================================================
//' 初始化
function STTSInit():boolean;stdcall; external 'STTSApi.dll';
//' 逆初始化
function STTSDeinit():boolean;stdcall;
external 'STTSApi.dll';
//' 建立与TTS服务器的连接
function STTSConnect(sSerialNumber:string;sServerIP:string):Integer;stdcall;
external 'STTSApi.dll';
//' 断开与TTS服务器的连接
Function STTSDisconnect(hTTSInstance:Integer):boolean;stdcall;
external 'STTSApi.dll';
//' 设置本次连接的合成参数
Function STTSSetParam(hTTSInstance:integer;lngType:integer;lngParam:integer):Boolean;stdcall;
external 'STTSApi.dll';
//' 获得本次连接的合成参数
Function STTSGetParam(hTTSInstance:Integer;lngType:integer;lngParam:integer):Boolean;stdcall;
external 'STTSApi.dll';
//' 从字符串合成到音频文件
Function STTSString2AudioFile(hTTSInstance:Integer;sString:string;sWaveFile:string):Boolean;stdcall;
external 'STTSApi.dll';
//' 从文本文件合成到音频文件
Function STTSFile2AudioFile(hTTSInstance:Integer;sTextFile:string;sWaveFile:string):Boolean;stdcall;
external 'STTSApi.dll';
//'播放字符串
Function STTSPlayString(hTTSInstance:Integer;sString:string;bAsynch:Boolean):Boolean;stdcall;
external 'STTSApi.dll';
//'播放文本文件
Function STTSPlayTextFile(hTTSInstance:Integer;sTextFile:string;bAsynch:Boolean):Boolean;stdcall;
external 'STTSApi.dll';
//'播放停止
Function STTSPlayStop():Boolean;stdcall;
external 'STTSApi.dll';
//'查询播放状态
Function STTSQueryPlayStatus(lngStatus:Integer):Boolean;stdcall;
external 'STTSApi.dll';
//'TTS版本信息
Function STTSAbout(sAboutInfo:string;ninfosize:Integer):Boolean;stdcall;
external 'STTSApi.dll';
//' 用来获取错误代码的Windows API函数
//Public Declare Function GetLastError Lib "kernel32" () As Long
procedure TForm1.Button1Click(Sender: TObject);
var
myhandle:integer;
begin
STTSInit();
myhandle:=STTSconnect('80','127.0.0.1');
STTSPlayString(myhandle,self.Memo1.Text,true) ;
STTSDisconnect(myhandle);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
STTSPlayStop();
end;
procedure TForm1.Button3Click(Sender: TObject);
var
strls:string;
myhandle:integer;
begin
if not self.OpenDialog1.Execute then exit;
strls:=self.OpenDialog1.FileName;
STTSInit();
myhandle:=STTSconnect('80','127.0.0.1');
STTSPlayTextFile(myhandle,strls,true);
STTSDisconnect(myhandle);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
STTSDeInit();
end;
end.