求教:微软英语发音引擎-TTS在Delphi中的使用方法,比如如何安装\安装后怎样用它来读单词\句子???(最好有源码说明)-------多谢了

解决方案 »

  1.   

    Speech API可以作为类型库引用到Delphi中,方法是:打开Project选单下的Import
    > 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的属性和方法,
    > 我们还可以控制阅读速度和语气,实现暂停、跳句等功能
      

  2.   

    以下是一遍文章,你要设置正确的发音:利用Microsoft Text To Speech技术编程 金山词霸2000进行查字典时,可以同时读出相应的英文单词,这大大方便用户的使用。其实,我们也可以在自己的应用程序中加入这种功能。金山词霸2000中利用的语音发声就是微软的Text To Speech技术,简称为MSTTS。在金山词霸2000的安装过程中,将自动安装MSTTS,我们也可以利用金山词霸2000安装光盘中的MSTTS.EXE文件单独安装。安装成功后,系统的Windows目录下将有一个Speech子目录,其中安装了相应的支持文件。其中的Vcmd.exe作为进程外的自动化服务器,提供将文本转换为语音的服务。Vtxtauto.tlb为相应的类型库,对服务器的接口给出了与语言无关的描述。在注册表中注册了相应的接口和自动化对象Speech.VoiceText.1。下面给出一个使用Delphi利用相应接口进行开发的简单例子,程序可以读出一个文本编辑控件中的文本。例子主要利用Win32的COM API进行编程,该方法同样适用于VC等开发语言。 首先,选择Project|Import Type Library菜单项检查是否注册了相应的类型库文件Vtxtauto.tlb,如果没用选择安装目录下的Vtxtauto.tlb文件进行注册。此时,Delphi将在Import子目录下生成该类型库的Object Pascal"包装"文件VtxtAuto_TLB.Pas,打开该文件可以看到该自动化对象支持的接口较为简单,只有一个IVTxtAuto接口,下面是该接口的说明: IVTxtAuto = interface(IDispatch)
    ['{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下调试运行通过
      

  3.   

    检测本机同Internet之间的连接是否畅通(转自DELPHIBBS)
    公司规定上网要先申请,我懒得填单,写了下面的程序,当有别人上网时,我可以蹭一下。//******************************************************************************
    //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.