SpeechSynthesize.pas - yes!!!
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
SpeechSynthesize;
type
TMyThread = class(TThread)
private
protected
procedure Execute; override;
public
constructor Create(CreateSuspended: boolean);
end;
{ TForm1 }
TForm1 = class(TForm)
MainMenu1: TMainMenu;
MenuItem1: TMenuItem;
MenuItem2: TMenuItem;
MenuItem3: TMenuItem;
MenuItem4: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure MenuItem3Click(Sender: TObject);
procedure MenuItem4Click(Sender: TObject);
private
aTh: TMyThread;
SpeechSynthesize: TSpeechSynthesize;
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
SpeechSynthesize := TSpeechSynthesize.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
SpeechSynthesize.Free;
end;
procedure TForm1.MenuItem3Click(Sender: TObject);
begin
aTh := TMyThread.Create(False);
end;
procedure TForm1.MenuItem4Click(Sender: TObject);
begin
SpeechSynthesize.StopSpeaking;
end;
//
procedure TMyThread.Execute;
begin
Form1.MenuItem4.Enabled := True;;
Form1.SpeechSynthesize.StartSpeakingString('i was the World, i was the World, i was the World,');
while (not Terminated) and (Form1.SpeechSynthesize.IsSpeaking = True {any condition required}) do
begin
Sleep(5);
end;
Form1.MenuItem4.Enabled := False;
end;
constructor TMyThread.Create(CreateSuspended: boolean);
begin
FreeOnTerminate := True;
inherited Create(CreateSuspended);
end;
end.
kogs