这个例子是 free pascal 在Windows XP 调用 MS TTS 读中英文
tts2.pas
Program space2; {$mode objfpc}{$H+} uses Classes,SysUtils,Process,Variants,ComObj,RegExpr,ShellApi; var Sp: Variant; re: TRegExpr; i : Integer; begin if Assigned(InitProc) then TProcedure(InitProc); try Sp := CreateOleObject('SAPI.SpVoice') ; re := TRegExpr.Create; re.Expression := '^[A-Za-z]+$'; for i:=1 to ParamCount do begin if re.Exec(ParamStr(i)) then Sp.Speak(ParamStr(i)) // english else // speak.vbs 读中文 ShellExecute(0,nil, PChar('".\speak.vbs"'),PChar(ParamStr(i)),nil,0); Sleep(1); end except writeln(' OLE Error '); end; re.free; end.
原文地址:http://blog.csdn.net/belldeep/article/details/45113775