谁用过MS的TTS5.1,在delphi中的AxtiveX类为:TDirectSR,TDirectSS,TTexttoSpeech,安装了中文,却仍发英文.参数也不会调.谁用过的指点一下..

gum 2002-03-31 10:47:00
谁用过MS的TTS5.1,在delphi中的AxtiveX类为:TDirectSR,TDirectSS,TTexttoSpeech,安装了中文,却仍发英文.参数也不会调.谁用过的指点一下...
...全文
18 点赞 收藏 2
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
cynwhm 2002-09-16
我已安装了MS SAPI5.1 中为何找不到SpeechLib_TLB文件。
回复
smilboy 2002-06-13
请看
unit frm_VoiceMain;

interface

uses
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.
回复
发动态
发帖子
非技术区
创建于2007-08-02

797

社区成员

Delphi 非技术区
申请成为版主
社区公告
暂无公告