共有回帖数 0 个
-
功能:朗读用户输入的内容。
C源代码:
-----------------------------------------------------------------------------------------------------------------
#includestdio.h
#includesapi.h
#includewindows.h
#define max 1024
void speak_string(char string[]);
int main()
{
HWND hwnd=GetForegroundWindow();
SetWindowTextA(hwnd,"朗读输入-核心记忆(QQ:326981992)");
system("color 0a");
printf("Hello!我会朗读您输入的内容。n");
speak_string("Hello!我会朗读您输入的内容");
char userInput[max]={0};
while(1)
{
printf("输入:");
gets(userInput);
speak_string(userInput);
}
return 0;
}
void speak_string(char string[])
{
ISpVoice *pSpVoice;
::CoInitialize(NULL);
CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_INPROC_SERVER, IID_ISpVoice, (void**)&pSpVoice);
wchar_t buffer_speak[max];
MultiByteToWideChar(0,0,string,max,buffer_speak,max);
pSpVoice - Speak(buffer_speak,SPF_DEFAULT,NULL);
}
----------------------------------------------------------------------------------------------------------------------
代码结束
若提示#includesapi.h不存在,则需安装微软语音识别引擎开发库——Microsoft Speech SDK开发包,下载地址:http://www.microsoft.com/en-us/download/details.aspx?id=1012
本程序下载地址:链接:http://pan.baidu.com/s/1i33uiGX 密码:vdcw
楼主 2015-07-31 19:38 回复
Copyright © 2010~2015 直线网 版权所有,All Rights Reserved.沪ICP备10039589号
意见反馈 |
关于直线 |
版权声明 |
会员须知