delphi调用windows自带语音功能
windows自带语音接口 SAPI.SpVoice, 接口说明如下
https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ee125663(v%3dvs.85)
简单调用代码:
uses System.Win.ComObj; {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var lO: OleVariant; begin lO := CreateOleObject('SAPI.SpVoice'); {设置语音库 男/女 中文/英文支持, 这句可以不要, 使用默认语音库} lO.Voice := lO.GetVoices('name=Microsoft David Desktop', '').Item(0); {语音播报} lO.Speak(Memo1.Lines.Text); end; procedure TForm1.Button2Click(Sender: TObject); var lO, lV, lX: OleVariant; x: integer; begin {获取系统语音库} lO := CreateOleObject('SAPI.SpVoice'); lV := lO.GetVoices; for x := 0 to lV.count - 1 do begin lX := lV.item(x); memo1.Lines.Add(lX.GetDescription); end; end;
--------------------------------------------------------------------------------------------------
作者:黑暗煎饼果子
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
--------------------------------------------------------------------------------------------------