从前做过的一个实验的*.pas文件,希望对你有用。
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleServer, SpeechLib_TLB, SIMPLEAUDIOLib_TLB, ComCtrls,
OleCtrls, VoiceAngelLib_TLB;
type
TForm1 = class(TForm)
SpVoice1: TSpVoice;
Memo1: TMemo;
Button1: TButton;
ComboBox1: TComboBox;
Edit1: TEdit;
ComboBox2: TComboBox;
TrackBar1: TTrackBar;
TrackBar2: TTrackBar;
Button2: TButton;
Edit2: TEdit;
Edit3: TEdit;
ComboBox3: TComboBox;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure ComboBox2Change(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure TrackBar1Change(Sender: TObject);
procedure TrackBar2Change(Sender: TObject);
private
// i:integer;
z,j:integer;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
SpVoice1.speak(memo1.Lines.Text,1);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
x,i:integer;
begin
//----------------------------------------------------
//----------------------------------------------------
spvoice1.Volume:=TrackBar2.Position;
for i:=0 to spvoice1.getvoices('','').count-1do
begin
ComboBox1.Items.Add(string(spvoice1.GetVoices('','').Item(i).GetDescription(i)));
combobox1.ItemIndex:=i;
j:=i;
end;
for x:=0 to spvoice1.GetAudioOutputs('','').Count-1do
begin
ComboBox2.Items.Add(string(spvoice1.GetAudioOutputs('','').Item(x).GetDescription(x)));
combobox2.ItemIndex:=x;
z:=x;
end;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
spvoice1.Voice :=spvoice1.GetVoices('','').Item(combobox1.itemindex);
end;
procedure TForm1.ComboBox2Change(Sender: TObject);
begin
spvoice1.AudioOutput :=spvoice1.GetAudioOutputs('','').Item(combobox2.itemindex);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
aa:string;
//
bb:ispeechwaveformatex;
begin
bb:=spvoice1.AudioOutputStream.Format.GetWaveFormatEx;
edit3.text:=string(bb);
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
spvoice1.Rate:=TrackBar1.Position;
end;
procedure TForm1.TrackBar2Change(Sender: TObject);
begin
spvoice1.Volume:=TrackBar2.Position;
end;
end.