XP上可以安装Speech SDK5.1
1.将sapi.dll导入到C++Builder:
Component->Import Component->Import a Type Library->Add添加Sapi.dll语音识别引擎库文件。
2.Install完后会生成许多语音控件,添加spVoice控件
3.可以进行编程了:
#include
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ACTIVEVOICEPROJECTLib_OCX"
#pragma link "SpeechLib_OCX"
#pragma resource "*.dfm"
TForm1 *Form1;
TSpVoice *SpVoice1;//=new TSpVoice(this);
ISpeechObjectTokensPtr sots;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
WideString con=Memo1->Text; //中文=804;英文=409
sots=SpVoice1->GetVoices(WideString("Language=409"),WideString("VW Kate"));//获取中文语音(wchar_t*)("")
if(sots->get_Count()==0)//如果没有中文语音,则count为0
return;
SpVoice1->_set_Voice(sots->Item(0));//设置中文发音
SpVoice1->Speak(con,SVSFDefault);//快乐的说吧
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
SpVoice1=new TSpVoice(this);
ComboBox1->Items->Clear();
ComboBox1->Items->Add("声音");
sots=SpVoice1->GetVoices(NULL,NULL);
for(int i=0;i
{
ComboBox1->Items->Add(sots->Item(i)->GetDescription(NULL));
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
delete SpVoice1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBox1Change(TObject *Sender)
{
SpVoice1->_set_Voice(sots->Item(ComboBox1->ItemIndex));
}
加油噢!setu6 高清的人体艺术 谁有啊