没说明白要干啥啊?如果只要runtime的话,装个http://download.microsoft.com/download/speechSDK/Install/4.0a/WIN98/EN-US/spchapi.EXE
就行了。

解决方案 »

  1.   

    看这篇文章:
    http://etc.elec.bnu.edu.cn/application%20and%20development/reading.htm金山词霸2000的奂文全文朗读功能相信一定给尝试过的用户留下了很深刻的印象,而作为一个程序设计者,你一定也想在自己的程序中加入类似的功能吧,因为那将让自己的程序增色不少。其实这并不是一件困难的事,因为金山词霸实际上也只是直接使用了MS的TTS(Text-to-Speech)技术而已,通过对MS Speech API 的编程,我们完全可以实现比其更强大的功能。下面,让我们在Delphi环境下实际尝试一下。首先从金山词霸的光盘上\ ciba目录下运行并安装mstts. Exe(MS TTs engine)和spchapi. Exe (MS Speech API).再在Delphi 里新建一个application。然后从Delphi的菜单Project/Import Type Library. . .中选击Add. . .,浏览到Windows目录下的Speech子目录里,打开vtxtauto. Tlb,可以看到下面Class names中会出现我们需要的接口的包装类的名字TVTxtAuto,注意对话框底部的Generate Component Wrapper需要被选中,点击Create Unit 就可以打开一个名为VtxtAuTo_TLB的Unit。至此,我们就可以开始实际编程了。首先在Form的OnCreate中对需要使用接口初始化并进行注册:...Procedure TfrmMain. FormCreate (Sender. Tobject); beginFISpeech: = CoVTxtAuto_Create;FISpeech. Register (“Demo Site’, ‘Demo App’); end;...由于Delphi对接口进行了良好的包装,因此,只需直接建立包装类,其他后台的操作如接口的查询、释放等交给Delphi在后台自动完成。注意这里的Register操作是必不可少的,因为可能有多个程序不同设置使用TIS引擎。然后在MainForm上放一个Tmemo和若干个Tbutton,并在其OnClick中加入对应的代码。Form定义如下:Object frmMain: TfrmMainLeft = 296Top = 187BorderStyle = bsDialogCaption = ‘英文全文朗读演示’ClientHeight = 185ClientWidth = 456Color = clBtnFaceFont. Charset = GB2312_CHARSETFont. Color = clWindowTextFont. Height = -12Font. Name = ‘宋体’Font. Style = [ ]OldCreateOrder = FalsePosition = poDesktopCenterOnCreate = FormCreatePixelsPerInch = 96TexHeight = 12Object memText: TmemoLeft =8Top = 8Width = 361Height = 169ScrollBars = ssVerticalTabOrder = 0EndObject btnRead: TbuttonLeft = 376Top = 8Width = 75Height = 25Caption = ‘朗读(&R)’TabOrder = 1OnClick = btnReadClickEndObject btnPause: TbuttonLeft = 376Top = 40Width = 75Height = 25Caption = ‘暂停(&P)’Enabled = FalseTabOrder = 2OnClick = btnPauseClickEnd Object btnStop: TbuttonLeft = 376Top = 72Width = 75Height = 25Caption = ‘停止(&S)’Enabled = FalseTabOrder = 3OnClick = btnStopClickEndObject btnForward: TbrttonLeft = 376Top = 120Width = 75Height = 25Caption = ‘下一句(&N)’Enabled = FalseTabOrder =4OnClick = btnForwardClickEnd Object btnRewind: TbuttonLeft = 376Top = 152Width = 75Height = 25Caption = ‘上一句(&W)’Enabled = falseTabOrder = 5OnClick = btnRewindClickEnd End关键代码段如下:1.朗读与停止...procedure TfrmMain. BtnReadClick (Sender: Tobject); beginFISpeech. Speak (memText. Lines. Text, vtxtst_READING0;BtnPause. Enabled : = True;BtuStop. Enabled : = True;End;Procedure TfrmMain. BtnStopClicl (Sender: Tobject); beginFISpeech. StopSpeaking;BtnPause. Enabled : = False;BtnStop. Enabled : = False;BtnPause. Caption : = ‘暂停(&P)’;end;...speak成员函数的第一个参数向TTS引擎传递需要朗读的文字,第二个参数由指定朗读时使用的语气和优先级的两个符号合并而成。  符号
     值
     意义
     
    语气 
     vtxtst_STATEMENT
     $00000001
     平常说话的语气(缺省) 
    vtxtst_QUESTION
     $00000002
     提问的语气 
    vtxtst_COMMAND
     $00000004
     命令的语气 
    vtxtst_WARNING
     $00000008
     警告的语气 
    vtxtst_READING
     $00000010
     阅读文档时的语气 
    vtxtst_NUMBERS
     $00000020
     适合阅读数字的语气 
    vtxtst_SPREADSHEET
     $00000040
     适合阅读电子表格中元素的语气 
    优先级
     vtxtsp_VERYHING
     $00000080
     立即读出,可打断正在读的内容 
    vtxtsp_HIGH
     $00000100
     尽快读出,加入播放队列开始 
    vtxtsp_NORMAL
     $00000200
     仅仅加入播放队列末尾(缺省)  2.暂停为与恢复...procedure TfrmMain. BtnPauseClick (Sender: Tobject);beginwith FISpeech do if IsSpeaking thenbeginAudioPause;BtnPause. Caption : = ‘恢复(&R)’;EndElseBeginAudioResume;BtnPause. Caption : = ‘暂停(&R)’;End;End;...这里通过IsSpeaking属性可以取得当前状态,然后通过audioPause和AudioResume暂停和恢复朗读。另外用成员函数AudioFastForward和AudioRewind可以向前和后跳过一句朗读,通过读写speed属性还可以取得或调协朗读的语速,单位是字/分,缺省值为170。注意speed和Enabled属性缺省设置是只写的,但实际上IVTxtAuto提供了Get_Speed和Get_Enabled函数,所以我们只要把VtxtAuto_TLB单元中的声明修改一下,如:...IVTxtAuto = interface (Idispatch)...property Speed: Integer read Get_Speed write Set_Speed;propert Enabled: Integer read Get_Speed write Set_Speed;...end;...即可正常使用Speed和enabled属性了。至此,一个简单的英文全文朗读器就完成了,有兴趣的朋友可以为其加入监视剪贴板,热键激活等功能。本文程序在win NT/98 + Delphi 4/5环境下调试通过。
      

  2.   

    unit frm_VoiceMain;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, OleServer, SpeechLib_TLB, ComCtrls;type
      TfrmVoices = class(TForm)
        SpVoice1: TSpVoice;
        Button1: TButton;
        cmbVoices: TComboBox;
        memText: TMemo;
        Button2: TButton;
        tbRate: TTrackBar;
        tbVolume: TTrackBar;
        Label1: TLabel;
        Label2: TLabel;
        Label3: TLabel;
        Button3: TButton;
        Button4: TButton;
        Label4: TLabel;
        cmbAudioOutput: TComboBox;
        Button5: TButton;
        procedure Button1Click(Sender: TObject);
        procedure cmbVoicesChange(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure tbRateChange(Sender: TObject);
        procedure tbVolumeChange(Sender: TObject);
        procedure Button3Click(Sender: TObject);
        procedure Button4Click(Sender: TObject);
        procedure cmbAudioOutputChange(Sender: TObject);
        procedure Button5Click(Sender: TObject);
      private
        procedure InitVoices;   //获取系统安装的语音库
        procedure InitAudioOutputs; //获取系统声音输出设备
      public
        { Public declarations }
      end;var
      frmVoices: TfrmVoices;implementation{$R *.DFM}procedure TfrmVoices.Button1Click(Sender: TObject);
    begin
      SpVoice1.Speak(memText.text,1);
    end;procedure TfrmVoices.cmbVoicesChange(Sender: TObject);
    var
      a,b:WideString;
    begin
      SpVoice1.Voice:=SpVoice1.GetVoices(a,b).item(cmbVoices.ItemIndex)
    end;procedure TfrmVoices.InitVoices;
    var
      a,b:WideString;
      Voices:ISpeechObjectTokens;
      i:integer;
    begin
      Voices:=SpVoice1.GetVoices(a,b);
      for i:=0 to Voices.Count-1 do begin
        cmbVoices.Items.Add(Voices.item(i).GetDescription(i))
      end;
      cmbVoices.ItemIndex:=0;
    end;procedure TfrmVoices.FormCreate(Sender: TObject);
    begin
      InitVoices;
      InitAudioOutputs;
      tbRate.Position:=SpVoice1.Rate;
      tbVolume.Position:=SpVoice1.Volume;
    end;procedure TfrmVoices.tbRateChange(Sender: TObject);
    begin
     SpVoice1.Rate :=tbRate.Position;
    end;procedure TfrmVoices.tbVolumeChange(Sender: TObject);
    begin
      SpVoice1.Volume := tbVolume.Position;
    end;procedure TfrmVoices.Button3Click(Sender: TObject);
    begin
      SpVoice1.Pause
    end;procedure TfrmVoices.Button4Click(Sender: TObject);
    begin
      SpVoice1.Resume
    end;procedure TfrmVoices.InitAudioOutputs;
    var
      a,b:WideString;
      AudioOutputs:ISpeechObjectTokens;
      i:integer;
    begin
      AudioOutputs:=SpVoice1.GetAudioOutputs(a,b);
      for i:=0 to AudioOutputs.Count-1 do begin
        cmbAudioOutput.Items.Add(AudioOutputs.item(i).GetDescription(i))
      end;
      cmbAudioOutput.ItemIndex:=0;
    end;procedure TfrmVoices.cmbAudioOutputChange(Sender: TObject);
    var
      a,b:WideString;
    begin
      SpVoice1.AudioOutput:=SpVoice1.GetAudioOutputs(a,b).item(cmbAudioOutput.ItemIndex)
    end;procedure TfrmVoices.Button5Click(Sender: TObject);
    var
      WaveFileStream:SpFileStream;
      SpFileMode:SpeechStreamFileMode;
    begin
      SpFileMode := SpeechStreamFileMode.SSFMCreateForWrite;
      WaveFileStream.Open('c:\1.wav',SpFileMode,false);
      SpVoice1.AudioOutputStream:= WaveFileStream;
      SpVoice1.Speak(memtext.text,1);
      SpVoice1.WaitUntilDone(1000);
      WaveFileStream.Close;
    end;end.