C++BUILDER 下开发语音源码,转载

 XP上可以安装Speech SDK5.11.将sapi.dll导入到C++Builder:Component->Import Component->Import a Type Library->Add添加Sapi.dll语音识别引擎库文件。2.Install完后会生成许多语音控件,添加spVoice控件3.可以进行编程了:#include <vcl.h>#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;英文=409sots=SpVoice1->GetVoices(WideString("Language=409"),WideString("VW Kate"));//获取中文语音(wchar_t*)("")if(sots->get_Count()==0)//如果没有中文语音,则count为0return;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<sots->get_Count();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));}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值