语音语音合成科大讯飞和Tizen-TTS语音合成引擎
2013-06-24 20:56
621 查看
废话就不多说了,开始。。。
最近在做一个文本转语音TTS(TexttoSpeech)的第三方软件封装,应用的是海内语音技术龙头安徽科大讯飞公司提供的离线引擎AiSound5.0,重要用于汽车导航用途。科大讯飞还提供了AiTalk用于语音识别,AiWrite用于手写识别服务等。另外还有针对6种平台的SDK和开辟示例。
一、科大讯飞语音平台
科大讯飞目前有不少产品应用在移动终端上了,比如说用在手机上的讯飞语点,可方便语音拨打电话和发送短信,查气候、股票等信息。
在上面讯飞语音云这个网站可以找到科大讯飞针对6种平台的SDK,http://open.voicecloud.cn/download.php,包含Android、Iphone、Windows、Linux、Java、Flash这些平台的语音合成、语音识别和语音听写的开辟文档和SDK下载,不过应用之前须要请求AppID(每一个语音应用程序须要一个Appid来独一标识,您须要通过注册帐号来获得自己应用的Appid,未注册的语音应用将无法正常获取语音服务。),通过考核后就可以下载响应的开辟文档和SDK并用于自己的软件系统中了。
二、科大讯飞语音合成、识别-在线文档和应用程序示例网址
从这里可以查看在线的开辟文档http://open.voicecloud.cn/developer.php?column=aW50ZV9zZGs%3D
Android平台的开辟文档和应用程序示例:http://open.voicecloud.cn/developer.php?category=YW5kcm9pZA%3D%3D&column=ZG9jdW1lbnQ%3D&type=d2lkZ2V0#a38
Windows和Linux平台的开辟文档和程序示例:http://open.voicecloud.cn/developer.php?category=b3RoZXI%3D&column=ZG9jdW1lbnQ%3D&type=YXBp
三、科大讯飞语音产品的移动应用
这里有一个科大讯飞的在线语音合成系统演示程序:ViViVoice2.1在线演示系统
'target='_blank'>http://www.iflytek.com/TtsDemo/viviVoiceShow.aspx
1、讯飞语点的应用,官网下载网址如下:http://yudian.voicecloud.cn/yudian.htm,支持Android和Iphone两大平台。
2、讯飞输入法应用:http://ime.voicecloud.cn/index.html
3、讯飞语音输入法应用:http://kouxun.voicecloud.cn/index.html
4、开辟者社区:http://open.voicecloud.cn/index.php
四、官网的Windows平台-语音合成和识别示例代码
网址如下:http://open.voicecloud.cn/developer.php?category=b3RoZXI%3D&column=c2FtcGxl&type=YXBp
以Windows下的开辟为例,给出了语音合成、语音识别和语音听写的编程示例。
1、语音合成开辟例程
#include<stdio.h>
#include<string.h>
#include"qtts.h"
#defineEND_SYNTH(reason)\
{\
ret=QTTSSessionEnd(session_id,#reason);\
if(0!=ret)\
{\
printf("QTTSSessionEndfailed,errorcodeis%d",ret);\
}\
\
ret=QTTSFini();\
if(0!=ret)\
{\
printf("QTTSFinifailed,errorcodeis%d",ret);\
}\
}
intmain()
{
constchar*configs=NULL;
constchar*session_id=NULL;
constchar*synth_params=NULL;
constchar*synth_text=NULL;
unsignedinttext_len=0;
constchar*synth_speech=NULL;
unsignedintsynth_speech_len=0;
FILE*f_speech=NULL;
intsynth_status=0;
intret=0;
printf("===================================================================\n"
"MobileSpeechPlatform2.0ClientSDKDemoforTTS\n"
"===================================================================\n");
/*初始化*/
configs="server_url=dev.voicecloud.cn/index.htm,timeout=10000,coding_libs=speex.dll";
ret=QTTSInit(configs);
if(0!=ret)
{
printf("QTTSInitfailed,errorcodeis%d",ret);
return-1;
}
/*开始一路会话,应用会话模式*/
synth_params="ssm=1,auf=audio/L16;rate=16000,aue=speex-wb;7,ent=intp65";
session_id=QTTSSessionBegin(synth_params,&ret);
if(0!=ret)
{
printf("QTTSSessionBeginfailed,errorcodeis%d",ret);
return-1;
}
/*写入合成文本*/
synth_text="讯飞语音云为您提供了最新最好的语音技术休会,"
"我们在互联网上开放科大讯飞最新研发的各种语音技术,"
"包含世界领先的语音合成技术、语音识别技术、声纹识别技术等。";
text_len=strlen(synth_text);
ret=QTTSTextPut(session_id,synth_text,text_len,NULL);
if(0!=ret)
{
printf("QTTSTextPutfailed,errorcodeis%d",ret);
END_SYNTH(QTTSTextPutfailed!);
return-1;
}
/*获取合成音频*/
f_speech=fopen("synth_speech.pcm","wb");
if(NULL==f_speech)
{
printf("Cannotopenfile\"synth_speech.pcm\"");
END_SYNTH(openfile);
return-1;
}
while(TTS_FLAG_DATA_END!=synth_status)
{
synth_speech=QTTSAudioGet(session_id,&synth_speech_len,&synth_status,&ret);
if(0!=ret)
{
printf("QTTSAudioGetfailed,errorcodeis:%d",ret);
break;
}
printf("QTTSAudioGetok,speechlength=%d\n",synth_speech_len);
if(NULL!=synth_speech&&0!=synth_speech_len)
{
fwrite(synth_speech,1,synth_speech_len,f_speech);
}
}
fclose(f_speech);
/*结束会话,释放资源*/
ret=QTTSSessionEnd(session_id,"normalend");
if(NULL==f_speech)
{
printf("QTTSSessionEndfailed,errorcodeis%d",ret);
}
session_id=NULL;
ret=QTTSFini();
if(0!=ret)
{
printf("QTTSFinifailed,errorcodeis%d",ret);
}
return0;
}
2、语音识别开辟例程
每日一道理
流逝的日子像一片片凋零的枯叶与花瓣,渐去渐远的是青春的纯情与浪漫。不记得曾有多少雨飘在胸前风响在耳畔,只知道沧桑早已漫进了我的心爬上了我的脸。当一个人与追求同行,便坎坷是伴,磨难也是伴。
#include<stdio.h>
#include<string.h>
#include<Windows.h>
#include"qisr.h"
#defineEND_RECOG(reason)\
{\ret=QISRSessionEnd(session_id,#reason);\
if(0!=ret)\
{\printf("QISRSessionEndfailed,errorcodeis%d",ret);\
}\
\
ret=QISRFini();\
if(0!=ret)\
{\
printf("QISRFinifailed,errorcodeis%d",ret);\
}\
}
#defineBLOCK_LEN5*1024
intmain()
{
constchar*configs=NULL;
constchar*session_id=NULL;
constchar*recog_grammar=NULL;
constchar*recog_params=NULL;
charrecog_audio[BLOCK_LEN];
FILE*f_speech=NULL;
intaudio_status=0;
intep_status=0;
intrec_status=0;
intrslt_status=0;
constchar*rec_result=NULL;
unsignedintaudio_len=0;
intret=0;
printf("===================================================================\n"
"MobileSpeechPlatform2.0ClientSDKDemoforIAT\n"
"===================================================================\n");
/*初始化*/
configs="server_url=dev.voicecloud.cn/index.htm,coding_libs=speex.dll,vad_enable=true";
ret=QISRInit(configs);
if(0!=ret)
{
printf("QISRInitfailed,errorcodeis%d\n",ret);
return-1;
}
/*开始一路会话,应用会话模式,应用引擎内置的语法停止识别*/
recog_grammar="builtin:grammar/../search/location.abnf?language=zh-cn";
recog_params="ssm=1,aue=speex-wb;7,auf=audio/L16;rate=16000,“
”ent=map,vad_speech_tail=900";
session_id=QISRSessionBegin(recog_grammar,recog_params,&ret);
if(0!=ret)
{
printf("QISRSessionBeginfailed,errorcodeis%d\n",ret);
return-1;
}
/*打开用来停止识别的语音文件,用户可以采取其他的获取音频的方式比如实时采集音频*/
f_speech=fopen("sxk_16k.pcm","rb");
if(NULL==f_speech)
{
printf("Cannotopenfile\"sxk_16k.pcm\"\n");
END_RECOG(openfile);
return-1;
}
/*发送音频数据,获取语音听写结果*/
while(ISR_AUDIO_SAMPLE_LAST!=audio_status)
{
audio_len=fread(recog_audio,1,BLOCK_LEN,f_speech);
audio_status=(audio_len==BLOCK_LEN)?
ISR_AUDIO_SAMPLE_CONTINUE:ISR_AUDIO_SAMPLE_LAST;
ret=QISRAudioWrite(session_id,recog_audio,audio_len
,audio_status,&ep_status,&rslt_status);
if(0!=ret)
{
printf("QISRSessionBeginfailed,errorcodeis%d\n",ret);
rslt_status=ISR_REC_STATUS_SPEECH_COMPLETE;
break;
}
printf("writeaudiodataok!len=%d,status=%d\n",audio_len,audio_status);
/*已经有结果缓存在MSC中了,可以获取了*/
if(ISR_REC_STATUS_SUCCESS==rslt_status)
{
rec_result=QISRGetResult(session_id,&rslt_status,5000,&ret);
if(0!=ret)
{
printf("QISRGetResultfailed,errorcodeis%d\n",ret);
rslt_status=ISR_REC_STATUS_SPEECH_COMPLETE;
break;
}
if(NULL!=rec_result)
{printf("gotaresult:%s\n",rec_result);
}
/*全部结果已经取完了*/
if(ISR_REC_STATUS_SPEECH_COMPLETE==rslt_status)
{
printf("theresulthasbeengotcompletely!\n");
break;
}
}
/*检测到音频后端点,结束音频发送*/
if(ISR_EP_AFTER_SPEECH==ep_status)
{printf("endpointofspeechhasbeendetected!\n");
break;
}
Sleep(160);
}
fclose(f_speech);
/*获取余下的识别结果*/
while(ISR_REC_STATUS_SPEECH_COMPLETE!=rslt_status)
{
rec_result=QISRGetResult(session_id,&rslt_status,5000,&ret);
if(0!=ret)
{
printf("QISRGetResultfailed,errorcodeis:%d\n",ret);
break;
}
if(NULL!=rec_result)
{
printf("gotaresult:%s\n",rec_result);
}
/*sleep一下很有必要,防止MSC端无缓存的识别结果时浪费CPU资源*/
Sleep(200);
}
/*结束会话,释放资源*/
ret=QISRSessionEnd(session_id,"normalend");
if(NULL==f_speech)
{
printf("QISRSessionEndfailed,errorcodeis%d\n",ret);
}
session_id=NULL;
ret=QISRFini();
if(0!=ret)
{
printf("QISRFinifailed,errorcodeis%d\n",ret);
}
return0;
}
3、语音听写开辟例程
#include<stdio.h>
#include<string.h>
#include<Windows.h>
#include"qisr.h"
#defineEND_RECOG(reason)\
{\
ret=QISRSessionEnd(session_id,#reason);\
if(0!=ret)\
{\
printf("QISRSessionEndfailed,errorcodeis%d",ret);\
}\
\
ret=QISRFini();\
if(0!=ret)\
{\
printf("QISRFinifailed,errorcodeis%d",ret);\
}\
}
#defineBLOCK_LEN5*1024
intmain()
{
constchar*configs=NULL;
constchar*session_id=NULL;
constchar*recog_params=NULL;
charrecog_audio[BLOCK_LEN];
FILE*f_speech=NULL;
intaudio_status=0;
intep_status=0;
intrec_status=0;
intrslt_status=0;
constchar*rec_result=NULL;
unsignedintaudio_len=0;
intret=0;
printf("===================================================================\n"
"MobileSpeechPlatform2.0ClientSDKDemoforIAT\n"
"===================================================================\n");
/*初始化*/
configs="server_url=dev.voicecloud.cn/index.htm,coding_libs=speex.dll,vad_enable=true";
ret=QISRInit(configs);
if(0!=ret)
{
printf("QISRInitfailed,errorcodeis%d\n",ret);
return-1;
}
/*开始一路会话*/
recog_params="ssm=1,sub=iat,aue=speex-wb;7,auf=audio/L16;rate=16000,“
“ent=sms16k,rst=plain,vad_speech_tail=1500";
session_id=QISRSessionBegin(NULL,recog_params,&ret);
if(0!=ret)
{
printf("QISRSessionBeginfailed,errorcodeis%d\n",ret);
return-1;
}
/*打开用来停止识别的语音文件,用户可以采取其他的获取音频的方式比如实时采集音频*/
f_speech=fopen("IAT_16KPCM_10s_0.pcm","rb");
if(NULL==f_speech)
{
printf("Cannotopenfile\"IAT_16KPCM_10s_0.pcm\"\n");
END_RECOG(openfile);
return-1;
}
/*发送音频数据,获取语音听写结果*/
while(ISR_AUDIO_SAMPLE_LAST!=audio_status)
{
audio_len=fread(recog_audio,1,BLOCK_LEN,f_speech);
audio_status=(audio_len==BLOCK_LEN)?
ISR_AUDIO_SAMPLE_CONTINUE:ISR_AUDIO_SAMPLE_LAST;
ret=QISRAudioWrite(session_id,recog_audio,audio_len,audio_status,&ep_status,&rslt_status);
if(0!=ret)
{
printf("QISRSessionBeginfailed,errorcodeis%d\n",ret);
rslt_status=ISR_REC_STATUS_SPEECH_COMPLETE;
break;
}
printf("writeaudiodataok!len=%d,status=%d\n",audio_len,audio_status);
/*已经有结果缓存在MSC中了,可以获取了*/
if(ISR_REC_STATUS_SUCCESS==rslt_status)
{rec_result=QISRGetResult(session_id,&rslt_status,5000,&ret);
if(0!=ret)
{
printf("QISRGetResultfailed,errorcodeis%d\n",ret);
rslt_status=ISR_REC_STATUS_SPEECH_COMPLETE;
break;
}
if(NULL!=rec_result)
{
printf("gotaresult:%s\n",rec_result);
}
/*全部结果已经取完了*/
if(ISR_REC_STATUS_SPEECH_COMPLETE==rslt_status)
{
printf("theresulthasbeengotcompletely!\n");
break;
}
}
/*检测到音频后端点,结束音频发送*/
if(ISR_EP_AFTER_SPEECH==ep_status)
{
printf("endpointofspeechhasbeendetected!\n");
break;
}
Sleep(160);
}
fclose(f_speech);
/*获取余下的识别结果*/
while(ISR_REC_STATUS_SPEECH_COMPLETE!=rslt_status)
{
rec_result=QISRGetResult(session_id,&rslt_status,5000,&ret);
if(0!=ret)
{
printf("QISRGetResultfailed,errorcodeis:%d\n",ret);
break;
}
if(NULL!=rec_result)
{
printf("gotaresult:%s\n",rec_result);
}
/*sleep一下很有必要,防止MSC端无缓存的识别结果时浪费CPU资源*/
Sleep(200);
}
/*结束会话,释放资源*/
ret=QISRSessionEnd(session_id,"normalend");
if(NULL==f_speech)
{
printf("QISRSessionEndfailed,errorcodeis%d\n",ret);
}
session_id=NULL;
ret=QISRFini();
if(0!=ret)
{
printf("QISRFinifailed,errorcodeis%d\n",ret);
}
return0;
}
五、Tizen(泰泽)提供的TTS和STT语音合成、语音识别接口
泰泽是三星和英特尔合作开辟的一款操作系统。
1、TizenSDK官网:https://developer.tizen.org/downloads/tizen-sdk
2、Tizen项目:https://review.tizen.org/git/
3、tts-api:https://review.tizen.org/git/?p=framework/api/tts-api.git;a=summary
其对应的tts.h头文件api接口在线网址为:https://review.tizen.org/git/?p=framework/api/tts-api.git;a=blob;f=include/tts.h;h=636470d923555a30d164cc09ceff841b72187e20;hb=98aee0bab00a418af162a0314ef931f8fd620892
4、stt-api:https://review.tizen.org/git/?p=framework/api/stt-api.git;a=summary
文章结束给大家分享下程序员的一些笑话语录:
问路
有一个驾驶热气球的人发现他迷路了。他降低了飞行的高度,并认出了地面上的一个人。他继续下降高度并对着那个人大叫,“打扰一下,你能告诉我我在哪吗?”
下面那个人说:“是的。你在热气球里啊,盘旋在30英尺的空中”。
热气球上的人说:“你一定是在IT部门做技术工作”。
“没错”,地面上的人说到,“你是怎么知道的?”
“呵呵”,热气球上的人说,“你告诉我的每件事在技术上都是对的,但对都没有用”。
地面上的人说,“你一定是管理层的人”。
“没错”,热气球上的人说,“可是你是怎么知道的?”
“呵呵”,地面上的那人说到,“你不知道你在哪里,你也不知道你要去哪,你总希望我能帮你。你现在和我们刚见面时还在原来那个地方,但现在却是我错了”。
---------------------------------
原创文章By
语音和语音合成
---------------------------------
最近在做一个文本转语音TTS(TexttoSpeech)的第三方软件封装,应用的是海内语音技术龙头安徽科大讯飞公司提供的离线引擎AiSound5.0,重要用于汽车导航用途。科大讯飞还提供了AiTalk用于语音识别,AiWrite用于手写识别服务等。另外还有针对6种平台的SDK和开辟示例。
一、科大讯飞语音平台
科大讯飞目前有不少产品应用在移动终端上了,比如说用在手机上的讯飞语点,可方便语音拨打电话和发送短信,查气候、股票等信息。
在上面讯飞语音云这个网站可以找到科大讯飞针对6种平台的SDK,
二、科大讯飞语音合成、识别-在线文档和应用程序示例网址
从这里可以查看在线的开辟文档
Android平台的开辟文档和应用程序示例:
Windows和Linux平台的开辟文档和程序示例:
三、科大讯飞语音产品的移动应用
这里有一个科大讯飞的在线语音合成系统演示程序:ViViVoice2.1在线演示系统
1、讯飞语点的应用,官网下载网址如下:
2、讯飞输入法应用:
3、讯飞语音输入法应用:
4、开辟者社区:
四、官网的Windows平台-语音合成和识别示例代码
网址如下:
以Windows下的开辟为例,给出了语音合成、语音识别和语音听写的编程示例。
1、语音合成开辟例程
2、语音识别开辟例程
每日一道理
流逝的日子像一片片凋零的枯叶与花瓣,渐去渐远的是青春的纯情与浪漫。不记得曾有多少雨飘在胸前风响在耳畔,只知道沧桑早已漫进了我的心爬上了我的脸。当一个人与追求同行,便坎坷是伴,磨难也是伴。
#include<string.h>
#include<Windows.h>
#include"qisr.h"
#defineEND_RECOG(reason)\
{\ret=QISRSessionEnd(session_id,#reason);\
if(0!=ret)\
{\printf("QISRSessionEndfailed,errorcodeis%d",ret);\
}\
\
ret=QISRFini();\
if(0!=ret)\
{\
printf("QISRFinifailed,errorcodeis%d",ret);\
}\
}
#defineBLOCK_LEN5*1024
intmain()
{
constchar*configs=NULL;
constchar*session_id=NULL;
constchar*recog_grammar=NULL;
constchar*recog_params=NULL;
charrecog_audio[BLOCK_LEN];
FILE*f_speech=NULL;
intaudio_status=0;
intep_status=0;
intrec_status=0;
intrslt_status=0;
constchar*rec_result=NULL;
unsignedintaudio_len=0;
intret=0;
printf("===================================================================\n"
"MobileSpeechPlatform2.0ClientSDKDemoforIAT\n"
"===================================================================\n");
/*初始化*/
configs="server_url=dev.voicecloud.cn/index.htm,coding_libs=speex.dll,vad_enable=true";
ret=QISRInit(configs);
if(0!=ret)
{
printf("QISRInitfailed,errorcodeis%d\n",ret);
return-1;
}
/*开始一路会话,应用会话模式,应用引擎内置的语法停止识别*/
recog_grammar="builtin:grammar/../search/location.abnf?language=zh-cn";
recog_params="ssm=1,aue=speex-wb;7,auf=audio/L16;rate=16000,“
”ent=map,vad_speech_tail=900";
session_id=QISRSessionBegin(recog_grammar,recog_params,&ret);
if(0!=ret)
{
printf("QISRSessionBeginfailed,errorcodeis%d\n",ret);
return-1;
}
/*打开用来停止识别的语音文件,用户可以采取其他的获取音频的方式比如实时采集音频*/
f_speech=fopen("sxk_16k.pcm","rb");
if(NULL==f_speech)
{
printf("Cannotopenfile\"sxk_16k.pcm\"\n");
END_RECOG(openfile);
return-1;
}
/*发送音频数据,获取语音听写结果*/
while(ISR_AUDIO_SAMPLE_LAST!=audio_status)
{
audio_len=fread(recog_audio,1,BLOCK_LEN,f_speech);
audio_status=(audio_len==BLOCK_LEN)?
ISR_AUDIO_SAMPLE_CONTINUE:ISR_AUDIO_SAMPLE_LAST;
ret=QISRAudioWrite(session_id,recog_audio,audio_len
,audio_status,&ep_status,&rslt_status);
if(0!=ret)
{
printf("QISRSessionBeginfailed,errorcodeis%d\n",ret);
rslt_status=ISR_REC_STATUS_SPEECH_COMPLETE;
break;
}
printf("writeaudiodataok!len=%d,status=%d\n",audio_len,audio_status);
/*已经有结果缓存在MSC中了,可以获取了*/
if(ISR_REC_STATUS_SUCCESS==rslt_status)
{
rec_result=QISRGetResult(session_id,&rslt_status,5000,&ret);
if(0!=ret)
{
printf("QISRGetResultfailed,errorcodeis%d\n",ret);
rslt_status=ISR_REC_STATUS_SPEECH_COMPLETE;
break;
}
if(NULL!=rec_result)
{printf("gotaresult:%s\n",rec_result);
}
/*全部结果已经取完了*/
if(ISR_REC_STATUS_SPEECH_COMPLETE==rslt_status)
{
printf("theresulthasbeengotcompletely!\n");
break;
}
}
/*检测到音频后端点,结束音频发送*/
if(ISR_EP_AFTER_SPEECH==ep_status)
{printf("endpointofspeechhasbeendetected!\n");
break;
}
Sleep(160);
}
fclose(f_speech);
/*获取余下的识别结果*/
while(ISR_REC_STATUS_SPEECH_COMPLETE!=rslt_status)
{
rec_result=QISRGetResult(session_id,&rslt_status,5000,&ret);
if(0!=ret)
{
printf("QISRGetResultfailed,errorcodeis:%d\n",ret);
break;
}
if(NULL!=rec_result)
{
printf("gotaresult:%s\n",rec_result);
}
/*sleep一下很有必要,防止MSC端无缓存的识别结果时浪费CPU资源*/
Sleep(200);
}
/*结束会话,释放资源*/
ret=QISRSessionEnd(session_id,"normalend");
if(NULL==f_speech)
{
printf("QISRSessionEndfailed,errorcodeis%d\n",ret);
}
session_id=NULL;
ret=QISRFini();
if(0!=ret)
{
printf("QISRFinifailed,errorcodeis%d\n",ret);
}
return0;
}
3、语音听写开辟例程
#include<string.h>
#include<Windows.h>
#include"qisr.h"
#defineEND_RECOG(reason)\
{\
ret=QISRSessionEnd(session_id,#reason);\
if(0!=ret)\
{\
printf("QISRSessionEndfailed,errorcodeis%d",ret);\
}\
\
ret=QISRFini();\
if(0!=ret)\
{\
printf("QISRFinifailed,errorcodeis%d",ret);\
}\
}
#defineBLOCK_LEN5*1024
intmain()
{
constchar*configs=NULL;
constchar*session_id=NULL;
constchar*recog_params=NULL;
charrecog_audio[BLOCK_LEN];
FILE*f_speech=NULL;
intaudio_status=0;
intep_status=0;
intrec_status=0;
intrslt_status=0;
constchar*rec_result=NULL;
unsignedintaudio_len=0;
intret=0;
printf("===================================================================\n"
"MobileSpeechPlatform2.0ClientSDKDemoforIAT\n"
"===================================================================\n");
/*初始化*/
configs="server_url=dev.voicecloud.cn/index.htm,coding_libs=speex.dll,vad_enable=true";
ret=QISRInit(configs);
if(0!=ret)
{
printf("QISRInitfailed,errorcodeis%d\n",ret);
return-1;
}
/*开始一路会话*/
recog_params="ssm=1,sub=iat,aue=speex-wb;7,auf=audio/L16;rate=16000,“
“ent=sms16k,rst=plain,vad_speech_tail=1500";
session_id=QISRSessionBegin(NULL,recog_params,&ret);
if(0!=ret)
{
printf("QISRSessionBeginfailed,errorcodeis%d\n",ret);
return-1;
}
/*打开用来停止识别的语音文件,用户可以采取其他的获取音频的方式比如实时采集音频*/
f_speech=fopen("IAT_16KPCM_10s_0.pcm","rb");
if(NULL==f_speech)
{
printf("Cannotopenfile\"IAT_16KPCM_10s_0.pcm\"\n");
END_RECOG(openfile);
return-1;
}
/*发送音频数据,获取语音听写结果*/
while(ISR_AUDIO_SAMPLE_LAST!=audio_status)
{
audio_len=fread(recog_audio,1,BLOCK_LEN,f_speech);
audio_status=(audio_len==BLOCK_LEN)?
ISR_AUDIO_SAMPLE_CONTINUE:ISR_AUDIO_SAMPLE_LAST;
ret=QISRAudioWrite(session_id,recog_audio,audio_len,audio_status,&ep_status,&rslt_status);
if(0!=ret)
{
printf("QISRSessionBeginfailed,errorcodeis%d\n",ret);
rslt_status=ISR_REC_STATUS_SPEECH_COMPLETE;
break;
}
printf("writeaudiodataok!len=%d,status=%d\n",audio_len,audio_status);
/*已经有结果缓存在MSC中了,可以获取了*/
if(ISR_REC_STATUS_SUCCESS==rslt_status)
{rec_result=QISRGetResult(session_id,&rslt_status,5000,&ret);
if(0!=ret)
{
printf("QISRGetResultfailed,errorcodeis%d\n",ret);
rslt_status=ISR_REC_STATUS_SPEECH_COMPLETE;
break;
}
if(NULL!=rec_result)
{
printf("gotaresult:%s\n",rec_result);
}
/*全部结果已经取完了*/
if(ISR_REC_STATUS_SPEECH_COMPLETE==rslt_status)
{
printf("theresulthasbeengotcompletely!\n");
break;
}
}
/*检测到音频后端点,结束音频发送*/
if(ISR_EP_AFTER_SPEECH==ep_status)
{
printf("endpointofspeechhasbeendetected!\n");
break;
}
Sleep(160);
}
fclose(f_speech);
/*获取余下的识别结果*/
while(ISR_REC_STATUS_SPEECH_COMPLETE!=rslt_status)
{
rec_result=QISRGetResult(session_id,&rslt_status,5000,&ret);
if(0!=ret)
{
printf("QISRGetResultfailed,errorcodeis:%d\n",ret);
break;
}
if(NULL!=rec_result)
{
printf("gotaresult:%s\n",rec_result);
}
/*sleep一下很有必要,防止MSC端无缓存的识别结果时浪费CPU资源*/
Sleep(200);
}
/*结束会话,释放资源*/
ret=QISRSessionEnd(session_id,"normalend");
if(NULL==f_speech)
{
printf("QISRSessionEndfailed,errorcodeis%d\n",ret);
}
session_id=NULL;
ret=QISRFini();
if(0!=ret)
{
printf("QISRFinifailed,errorcodeis%d\n",ret);
}
return0;
}
五、Tizen(泰泽)提供的TTS和STT语音合成、语音识别接口
泰泽是三星和英特尔合作开辟的一款操作系统。
1、TizenSDK官网:
2、Tizen项目:
3、tts-api:
其对应的tts.h头文件api接口在线网址为:
4、stt-api:
文章结束给大家分享下程序员的一些笑话语录:
问路
有一个驾驶热气球的人发现他迷路了。他降低了飞行的高度,并认出了地面上的一个人。他继续下降高度并对着那个人大叫,“打扰一下,你能告诉我我在哪吗?”
下面那个人说:“是的。你在热气球里啊,盘旋在30英尺的空中”。
热气球上的人说:“你一定是在IT部门做技术工作”。
“没错”,地面上的人说到,“你是怎么知道的?”
“呵呵”,热气球上的人说,“你告诉我的每件事在技术上都是对的,但对都没有用”。
地面上的人说,“你一定是管理层的人”。
“没错”,热气球上的人说,“可是你是怎么知道的?”
“呵呵”,地面上的那人说到,“你不知道你在哪里,你也不知道你要去哪,你总希望我能帮你。你现在和我们刚见面时还在原来那个地方,但现在却是我错了”。
---------------------------------
原创文章By
语音和语音合成
---------------------------------
相关文章推荐
- 科大讯飞和Tizen-TTS语音合成引擎
- WINCE TTS语音合成引擎SDK
- WINCE TTS语音合成引擎
- 安卓TTS语音合成经验分享(科大讯飞语音+)集成
- C#调用科大讯飞离线语音合成TTS
- C#调用科大讯飞离线语音合成TTS
- C#调用科大讯飞离线语音合成TTS
- 更换微软TTS语音引擎切换
- IOS开发之语音合成(科大讯飞)详解
- Android开发集成科大讯飞语音识别+语音合成功能
- 【VC++技术杂谈004】使用微软TTS语音引擎实现文本朗读
- Android开发 语音识别技术之科大讯飞语音识别(二) — 语音合成
- 简单的语音合成与语音识别(科大讯飞)
- 中文语音合成引擎_Easytts_易言语音合成中文优化版
- 交互系统的构建之(三)TTS语音合成的加盟
- 科大讯飞文字合成语音 html5
- HTML5语音播报引发的:关于TTS引擎扩展及修复注意事项
- 有关集成科大讯飞sdk的语音(三)语音合成
- TTS什么意思,缩写,微软TTS语音引擎(中文)5.1 “TTS”是“文本到语音(Text To Sound)”的简称
- Android开发集成科大讯飞语音识别+语音合成功能