Tôi vừa thử (D2009 trên Vista Home Premium) với mã sau và hoạt động!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComObj;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Voice: Variant;
begin
Voice := CreateOLEObject('SAPI.SpVoice');
Voice.speak('Hello World');
end;
end.
FYI, có một nice paper on using speech in Delphi programming bởi Brian Long ...
(Rất) Cuối Cập nhật:
Đối với lý do tại sao nó có thể không hoạt động trong Vista và đưa ra một EZeroDivide ngoại trừ IDE, hãy xem câu hỏi SO khác này: Delphi SAPI Text-To-Speech
Nguồn
2008-10-16 08:00:19
cảm ơn François. Nó hoạt động với thành phần trong bài báo bạn đề xuất (http://www.blong.com/Conferences/DCon2002/Speech/SAPI51/SAPI51.htm) –