文本转语音

TTS引擎,基于文本驱动的语音发声,核心的应用程序接口是ISpVoice

在有些精简的操作系统下,可能TTS组件无法正常使用,下载

http://download.csdn.net/detail/windows_nt/6961609

win7 tts修复文件.zip,解压安装即可。

#include<sapi.h>
#include<iostream>
#pragma comment(lib,"sapi.lib");
#pragma comment(lib,"ole32.lib");//需要调用ole32.dll

int main(int argc,char** argv)
{
ISpVoice* pVoice = NULL;//初始化COM对象
if(FAILED(::CoInitialize(NULL))) 
return FALSE;
std::cout<<"speak:Hello world,nice to meet you";
//获取ISpVoice接口
HRESULT hr = CoCreateInstance(CLSID_SpVoice,NULL,CLSCTX_ALL,IID_ISpVoice,(void**)&pVoice);
if(SUCCEEDED(hr))
{
hr = pVoice->Speak(L"Hello world,nice to meet you",0,NULL);
pVoice->Release();
pVoice = NULL;
}
::CoUninitialize();
return TRUE;
}

下边是一个含有界面的事例程序:

http://download.csdn.net/detail/windows_nt/6961621

你可能感兴趣的:(文本转语音)