5 delphi text-to-speech windows-vista
我是通过使用Delphi在2000/NT/XP中创建OLE对象来实现的,如下所示:
Voice := CreateOLEObject('SAPI.SpVoice');
Voice.speak(...)
Run Code Online (Sandbox Code Playgroud)
但是这在Vista中不起作用,我怎么能让我的程序只是在Vista中说一些文字?
我刚刚尝试使用以下代码(Vista Home Premium 上的 D2009)并且它有效!
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.
Run Code Online (Sandbox Code Playgroud)
仅供参考, Brian Long写了一篇关于在 Delphi 编程中使用语音的精彩论文...
(非常)迟更新:
对于为什么它可能无法在 Vista 中工作并在 IDE 之外给出 EZeroDivide 异常,请参阅另一个 SO 问题:Delphi SAPI Text-To-Speech
| 归档时间: |
|
| 查看次数: |
2864 次 |
| 最近记录: |