What you are looking for is the SpeechLib_tlb activex that you will import with the delphi itself.
http://www.exceletel.com/support/whtpapers/speech/delphi.htm
Code Sample
unit UnitF;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, SpeechLib_TLB, OleServer, XPMan, ExtCtrls, ComCtrls, ENGINE,
TFlatCheckBoxUnit;
type
TPropriedsF = class(TForm)
SAPI: TSpVoice;
CBFA: TComboBox;
IMG: TImage;
XPManifest1: TXPManifest;
EDTEST: TEdit;
DEMVOZ: TButton;
TB: TTrackBar;
LAUT: TCheckBox;
APPLY: TButton;
BCANC: TButton;
BOK: TButton;
Button1: TButton;
procedure FormShow(Sender: TObject);
procedure CBFAChange(Sender: TObject);
procedure DEMVOZClick(Sender: TObject);
procedure TBChange(Sender: TObject);
procedure APPLYClick(Sender: TObject);
procedure BCANCClick(Sender: TObject);
procedure BOKClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
PropriedsF: TPropriedsF;
VPT: string;
implementation
{$R *.dfm}
procedure TPropriedsF.FormShow(Sender: TObject);
var
SOTokenVoice: ISpeechObjectToken; // See the MS SAPI SDK for info on
SOTokenVoices:ISpeechObjectTokens; // registry tokens that hold resources
i: Integer;
begin
VPT:= 'Você selecionou X como voz padrão do sistema.';
//
SAPI.EventInterests := SVEAllEvents;
SOTokenVoices := SAPI.GetVoices('',''); // Use the registry tokens
for I := 0 to SOTokenVoices.Count - 1 do
begin
//For each voice, store the descriptor in the TStrings list
SOTokenVoice := SOTokenVoices.Item(i);
CBFA.Items.AddObject(SOTokenVoice.GetDescription(0), TObject(SOTokenVoice));
//Increment descriptor reference count to ensure it's not destroyed
SOTokenVoice._AddRef;
end;
if CBFA.Items.Count > 0 then
begin
CBFA.ItemIndex := CBFA.Items.IndexOf(SAPI.Voice.GetDescription(0));
end;
//
TB.Position := SAPI.Rate;
EDTEST.TEXT:= TROCA('X', SAPI.Voice.GetDescription(0), VPT);
end;
procedure TPropriedsF.CBFAChange(Sender: TObject);
var SOTokenVoice: ISpeechObjectToken;
begin
SOTokenVoice := ISpeechObjectToken(Pointer(CBFA.Items.Objects[CBFA.ItemIndex]));
SAPI.Voice := SOTokenVoice;
EDTEST.TEXT:= TROCA('X', SAPI.Voice.GetDescription(0), VPT);
end;
procedure TPropriedsF.DEMVOZClick(Sender: TObject);
begin
if SAPI.Voice = nil then
exit;
//
SAPI.Speak(EDTEST.Text, 1);
end;
procedure TPropriedsF.Button1Click(Sender: TObject);
var
SpFileStream1: TSpFileStream;
FileName : TFileName;
T: TSTRINGLIST;
I: INTEGER;
begin
T:= TSTRINGLIST.CREATE;
T.LoadFromFile(EXTRACTFILEPATH(PARAMSTR(0))+'LISTA.TXT');
FOR I:=0 TO T.COUNT-1 DO
BEGIN
FileName := extractfilepath(paramstr(0))+'RAQUEL\'+T[I];
SpFileStream1 := TSpFilestream.Create(nil);
SpFileStream1.Open(FileName, SSFMCreateForWrite, False);
SAPI.AudioOutputStream := SPFileStream1.DefaultInterface;
SAPI.Speak(COPY(T[I], 1, POS('.', T[I])-1), SVSFDefault);
SPFileStream1.Close;
SpFileStream1.Free;
SLEEP(300);
END;
end;
procedure TPropriedsF.TBChange(Sender: TObject);
begin
SAPI.Rate:= TB.Position;
end;
procedure TPropriedsF.APPLYClick(Sender: TObject);
begin
APPLY.ENABLED:= FALSE;
//
//SAPI
//..
end;
procedure TPropriedsF.BCANCClick(Sender: TObject);
begin
CLOSE;
end;
procedure TPropriedsF.BOKClick(Sender: TObject);
begin
CLOSE;
end;
end.