关于语音朗读TTS的问题
#include "SpeechLib_OCX.h"#include "SpeechLib_TLB.h"TSpVoice *SpVoice1;ISpeechObjectTokensPtr sots;DWORD __stdcall TreadPlay(LPVOID lpParametr){ WideString con=Form1->Memo1->Text; ::CoInitialize(NULL); SpVoice1->Speak(con, SVSFDefault); ::CoUninitialize(); return 0;}//---------------------------------------void __fastcall TForm1::FormCreate(TObject *Sender){ SpVoice1=new TSpVoice(this); sots=SpVoice1->GetVoices(WideString("Language=804"), (wchar_t*)""); if(sots->get_Count() == 0) { MessageBox(Handle, "没有安装中文朗读语音库!", "警告", MB_OK + MB_ICONWARNING); Close(); } //列出所有语音库 ComboBox1->Items->Clear(); for(int i=0;i<sots->get_Count();i++) { ComboBox1->Items->Add(sots->Item(i)->GetDescription(NULL)); } ComboBox1->ItemIndex = 0; SpVoice1->_set_Voice(sots->Item(0));//设置发音}//---------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender)//播放按钮{ CreateThread(NULL,0,TreadPlay,this,0,NULL);}//---------------------------------------void __fastcall TForm1::Button3Click(TObject *Sender)//继续按钮{ SpVoice1->Resume();}//---------------------------------------void __fastcall TForm1::ComboBox1Change(TObject *Sender)//更换发音{ SpVoice1->_set_Voice(sots->Item(Form1->ComboBox1->ItemIndex));}//---------------------------------------void __fastcall TForm1::trckbr1Change(TObject *Sender)//音量{ SpVoice1->set_Volume(trckbr1->Position);}//---------------------------------------void __fastcall TForm1::trckbr2Change(TObject *Sender)//语速{ SpVoice1->set_Rate(trckbr2->Position);}void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action){ SpVoice1->Pause();//关闭时先停止,因为不知道停止怎么实现,先用暂停代替}//---------------------------------------void __fastcall TForm1::FormDestroy(TObject *Sender){ delete SpVoice1;}//---------------------------------------