求教:微软英语发音引擎-TTS在Delphi中的使用方法,比如如何安装\安装后怎样用它来读单词\句子???(最好有源码说明)-------多谢了
解决方案 »
- 宝烂公司光卖一堆原码有什么用,他厉害的话把DELPHI开发小组和DELPHI产品一起卖了三,或许这样还可以多得几个子儿。
- 来看看这样的问题??
- 请问大家在哪里可以下载如下的Delphi 书籍
- 紧急求救(delphi读取SQL server里的图片)
- xe2的一些问题,有人碰到没?
- Delphi & VC
- TOpenDialog中的Files属性出了一个不是问题的问题,大家帮帮忙
- 关于一个(考勤)算法的问题,有代码
- 100相送!!!!
- 我刚开始学,从哪学起?
- 关于EXCEL导入数据库的两个问题,在线等待!
- DBGRID显示了存储过程得来的数据,能不能给DBGRID增加这样一列:该列可以由用户输入字符
> Type Litrary,点击“Add”加入Windows\Speech目录下的Vtxauto.tlb文件,在
> Delphi的Import目录中就会生成VTxtAuto—TLB.pas文件,其中定义了VTxtAuto—TLB
> 单元,把它加到Uses成员中来。定义全局变量:
>
> var VoTxt:IVTxtAuto;
>
> 然后在Form的OnCreate事件中加入:
>
> VoTxt:=CoVTxtAuto_.Create;
>
> VoTxt.Register(′′,′Speech Test′);{注册}
>
> “Read”按钮代码为:
>
> VoTxt.Speak(Memo1.Lines.Text,10);{朗读}
>
> “Stop”按钮代码为:
>
> VoTxt.StopSpeaking; {停止朗读}
>
> 至此,应用程序已具有朗读功能,10表示使用普通语气。借住VoTxt的属性和方法,
> 我们还可以控制阅读速度和语气,实现暂停、跳句等功能
['{FF2C7A50-78F9-11CE-B762-00AA004CD65C}']
procedure Register(const pszSite:
WideString; const pszApp: WideString); safecall;
procedure Speak(const pszBuffer:
WideString; dwFlags: Integer); safecall;
procedure StopSpeaking; safecall;
procedure AudioPause; safecall;
procedure AudioResume; safecall;
procedure AudioRewind; safecall;
procedure AudioFastForward; safecall;
procedure Set_Callback(const Param1:
WideString); safecall;
procedure Set_Speed(pdwSpeed: Integer); safecall;
function Get_Speed: Integer; safecall;
procedure Set_Enabled(pdwEnabled: Integer); safecall;
function Get_Enabled: Integer; safecall;
function Get_IsSpeaking: WordBool; safecall;
property Callback: WideString write Set_Callback;
property Speed: Integer write Set_Speed;
property Enabled: Integer write Set_Enabled;
property IsSpeaking: WordBool read Get_IsSpeaking;
end;新建一个应用程序,在新建的工程中加入VtxtAuto_TLB.Pas,并在主窗体单元中引用该文件。在主窗体中加入一个编辑控件(TEdit)和一个按钮(TButton),在主窗体单元中说明全局变量IVTxtAuto1:IVTxtAuto,在主窗体的创建过程中加入如下代码。 IVTxtAuto1:=nill;CoInitialize(nil);//初始化COM库OleCheck(CoCreateInstance(CLASS_VTxtAuto_,nil,
CLSCTX_ALL,IID_IVTxtAuto,IVTxtAuto1));
//创建IVTxtAuto接口IVTxtAuto1.Register('Demo1','Project1.Exe');
//向服务器注册IVTxtAuto1.Set_Enabled(1);//使能TTS功能
IVTxtAuto1.Set_Speed(150);//设置语音速度IVTxtAuto1.Speak('Hi,I am trying to
speak to you, Do you hear me?',
vtxtsp_VERYHIGH);//发声在Button1的Click事件处理过程中加入如下的代码。if IVTxtAuto1<>nil then
IVTxtAuto1.Speak(Edit1.Text,vtxtsp_VERYHIGH)
Else
ShowMessage( '服务器没用初始化成功');编译运行程序就可以听到相应的Edit1编辑控件中文本的发音了。 对于接口的其他方法可以参照类型库的说明进行使用,另外,也可以利用注册的OLE自动化对象Speech.VoiceText.1进行更为简洁的开发。声明变量msttsServer:OleVariant,利用如下的语句产生自动化对象,msttsServer:=CreateOleObject('Speech.VoiceText.1')。接着利用msttsServer自动化对象同样可以调用前面介绍的接口方法,这和通常利用自动化对象对MS Word等进行编程的方法一样。 利用相应的屏幕取词技术,我们同样可以实现金山词霸2000的功能。以上程序在Win98和Delphi5.0下调试运行通过
公司规定上网要先申请,我懒得填单,写了下面的程序,当有别人上网时,我可以蹭一下。//******************************************************************************
//1、本系统用于检测本机同Internet之间的连接是否畅通(每隔5分钟检测一次)
//2、本系统使用了以下几种技术:
//2。1、TTS发音技术;使用TTS发音引擎将指定文字内容(英文)转换成语音信号;
//2。2、Ping技术:使用ICS控件包中的Ping控件测试本机到指定地址的远程终端是否连通;
//2。3、将wave文件做到exe文件里;
//2。4、缩小图标到系统托盘。
//2。5、写注册表,是本系统在操作系统启动后自行启动;
//******************************************************************************unit uTestNetwork;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, Ping, CoolTrayIcon, StdCtrls, OleCtrls, VTxtAuto_TLB, comobj,
ActiveX, Menus, mmsystem, Registry, AMAboutDialog;type
TfrmMain = class(TForm)
CoolTrayIcon1: TCoolTrayIcon;
Ping1: TPing;
Timer1: TTimer;
Panel1: TPanel;
PopupMenu1: TPopupMenu;
Close1: TMenuItem;
N1: TMenuItem;
About1: TMenuItem;
AboutDlg: TAMAboutDialog;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Close1Click(Sender: TObject);
procedure About1Click(Sender: TObject);
private
{ Private declarations }
Connected: Boolean;
PtrSound : PChar;
hRes : THandle; {handle to the loaded resource if 0 indicates nothing playing}
procedure WriteRegistry;
procedure TellAll;
procedure TestConnect;
public
{ Public declarations }
end;var
frmMain: TfrmMain;
IVTxtAuto1:IVTxtAuto;
implementation{$R *.DFM}
{$R Ring.RES}//写注册表
procedure TfrmMain.WriteRegistry;
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run', True)
then Reg.WriteString('TestConnect','"' + ParamStr(0) + '"');
finally
Reg.CloseKey;
Reg.Free;
inherited;
end;
end;//发音
procedure TfrmMain.TellAll;
begin
IVTxtAuto1:=nil;
CoInitialize(nil);//初始化COM库
OleCheck(CoCreateInstance(CLASS_VTxtAuto_, nil, CLSCTX_ALL, IID_IVTxtAuto, IVTxtAuto1));
//创建IVTxtAuto接口
IVTxtAuto1.Register('Demo1',Application.ExeName);
//向服务器注册
IVTxtAuto1.Set_Enabled(1);//使能TTS功能
IVTxtAuto1.Set_Speed(150);//设置语音速度
IVTxtAuto1.Speak('Net is Connected!',vtxtsp_VERYHIGH);//发声
end;//测试连通状态
procedure TfrmMain.TestConnect;
var
i:integer;
bConnect:boolean;
begin
//连续测试四次,如果有一次Ping通,就认为网络是通的
bConnect:=False;
i:=1;
while (not bConnect) and (i<=4) do
begin
Ping1.Ping;
if Ping1.ErrorCode=0 then bConnect:=True
Inc(i);
end;
//状态处理
if not bConnect
then Connected:=False
else begin
if not Connected
then begin
//如果是第一次Ping通,先播放一段音乐,再使用语音提示
SndPlaySound(PtrSound,SND_ASYNC or SND_MEMORY);
TellAll;
Connected:=True;
end
end;
end;//每五分钟测试一次
procedure TfrmMain.Timer1Timer(Sender: TObject);
begin
TestConnect;
end;//初始化
procedure TfrmMain.FormCreate(Sender: TObject);
var
hResInfo : THandle;
begin
Connected:=False; Ping1.Address:='202.96.209.5'; //上海热线DNS服务器地址
Ping1.TimeOut:=5000;
Ping1.Size :=32; CoolTrayIcon1.Icon:= Application.Icon;
CoolTrayIcon1.Hint:= Application.Title; hResInfo := FindResource(HInstance, 'ring', 'WAVE');
hRes := LoadResource(HInstance, hResInfo);
if hRes > 32 then {its a good load}
PtrSound:=LockResource(hRes); {lock the resource} WriteRegistry;
TestConnect;
end;//退出系统
procedure TfrmMain.Close1Click(Sender: TObject);
begin
Application.Terminate;
end;//显示系统关于对话框:使用AMAboutDialog控件
procedure TfrmMain.About1Click(Sender: TObject);
begin
AboutDlg.AppName :='三宝爱踢 版权所有!';
AboutDlg.Caption :=Application.Title;
AboutDlg.Icon :=Application.Icon ;
AboutDlg.ExtraInfo :='本系统可以检测网络的连通状况';
AboutDlg.Execute ;
end;end.