Delphi调用OLE类实现TTS方式语音朗读
直接看代码:
unit uMain; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Comobj, Dialogs, StdCtrls, RzButton; type TFrmMain = class(TForm) btnStart: TRzBitBtn; mmMsg: TMemo; procedure btnStartClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var FrmMain: TFrmMain; implementation {$R *.dfm} procedure TFrmMain.btnStartClick(Sender: TObject); var voice: OLEVariant; begin voice := CreateOLEObject('SAPI.SpVoice'); voice.Speak(mmMsg.Lines.Text, 0); end; end.
看效果:
作者:Jeremy.Wu
出处:https://www.cnblogs.com/jeremywucnblog/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。