最近给老师做一个系统用到这个,收集了点资料,网上也找了找,关于用tts阅读中文的资料不是很多,就整理点出来,如果哪天某个陌生人能用到这个而找到这个地方,我也会小欣慰下的(*^__^*) 嘻嘻……
程序必须先安装微软的中文语音引擎。SpeechSDK51,SpeechSDK51LangPack。微软官网有下载。添加activex控件user SpeechLib_TLB。
代码很简单:
CoInitialize(nil);
spvoice1:=TSpVoice.Create(nil);
istokens:=spvoice1.GetVoices('','');
for i:=0 to istokens.Count-1 do
begin
istoken:=istokens.Item(i);
ListBox1.Items.AddObject(istoken.GetDescription(0),TObject(istoken));
end;
//istokens:=spvoice1.GetVoices('','');
istoken:=istokens.Item(ListBox1.ItemIndex);
//istoken:=ISpeechObjectToken(Pointer(ListBox1.Items.Objects[ListBox1.ItemIndex]));
spvoice1.Voice:=istoken;
SpVoice1.Speak(Label1.Caption, SVSFDefault);
如果疑问在下面留言,本程序可以选择精灵朗读label的caption,如果选择简体中文则可以朗读中文文本。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。