unit
Unit1;
interface
uses
Winapi
.
Windows, Winapi
.
Messages, System
.
SysUtils, System
.
Variants, System
.
Classes, Vcl
.
Graphics,
Vcl
.
Controls, Vcl
.
Forms, Vcl
.
Dialogs, SpeechLib_TLB, Vcl
.
ComCtrls,
Vcl
.
StdCtrls;
type
TForm1 =
class
(TForm)
Button1: TButton;
Memo1: TMemo;
TrackBar1: TTrackBar;
TrackBar2: TTrackBar;
VolumeLabel: TLabel;
RateLabel: TLabel;
ListBox1: TListBox;
procedure
Button1Click(Sender: TObject);
procedure
TrackBar1Change(Sender: TObject);
procedure
TrackBar2Change(Sender: TObject);
procedure
FormCreate(Sender: TObject);
procedure
ListBox1Click(Sender: TObject);
private
public
Voices:ISpeechObjectTokens;
end
;
var
Form1: TForm1;
gpIVTxt: TSpVoice;
Voices:ISpeechObjectTokens;
i:
integer
;
implementation
{$R *.dfm}
procedure
TForm1
.
Button1Click(Sender: TObject);
begin
gpIVTxt
.
Speak(Memo1
.
Text,SVSFlagsAsync);
end
;
procedure
TForm1
.
FormCreate(Sender: TObject);
begin
gpIVTxt:=TSpVoice
.
Create(
nil
);
Voices:=gpIVTxt
.
GetVoices(
''
,
''
);
for
i:=
0
to
Voices
.
Count -
1
do
listbox1
.
Items
.
Add(Voices
.
Item(i).GetDescription(
0
));
end
;
procedure
TForm1
.
ListBox1Click(Sender: TObject);
begin
gpIVTxt
.
Voice:=Voices
.
Item(listbox1
.
ItemIndex);
end
;
procedure
TForm1
.
TrackBar1Change(Sender: TObject);
begin
VolumeLabel
.
Caption:=IntToStr(TrackBar1
.
Position);
gpIVTxt
.
Volume:=TrackBar1
.
Position;
end
;
procedure
TForm1
.
TrackBar2Change(Sender: TObject);
begin
RateLabel
.
Caption:=IntToStr(TrackBar2
.
Position);
gpIVTxt
.
Rate:=TrackBar2
.
Position;
end
;
end
.