讯飞的语音识别技术VC源码
来源:互联网 发布:怎么安装cad2007软件 编辑:程序博客网 时间:2024/05/22 02:27
#include "stdafx.h"#include <string>#include <cstdio>#include "windows.h"#include "qisr.h"#include <conio.h>#pragma comment(lib,"msc.lib") void run_iat();const int BUFFER_NUM = 1024 * 4;const int AMR_HEAD_SIZE = 6; int _tmain(int argc, _TCHAR* argv[]){ run_iat(); printf("Press any key to exit."); char key = _getche(); printf("结果就是 %d /n",key); return 0;} void run_iat(){ bool error = false; int ret = MSP_SUCCESS; int i = 0; char* guowei ="VC做控件好难啊....啊啊啊啊啊"; FILE* fp = NULL; FILE* fout = NULL; char buff[BUFFER_NUM]; int len; int status = MSP_AUDIO_SAMPLE_CONTINUE, ep_status = -1, rec_status = -1, rslt_status = -1; ///APPID请勿随意改动 ret = QISRInit("appid=123456"); //这里是授权ID,最好作为参数传入 const char* param = "sub=iat,ssm=1,auf=audio/L16;rate=16000,aue=speex,ent=sms16k,rst=plain"; const char* sess_id = QISRSessionBegin(NULL, param, &ret); if ( MSP_SUCCESS != ret ) { printf("QISRSessionBegin err %d\n", ret); error = true; } if (error == false) { fp = fopen( "a.wav", "rb");//这里是需要打开的音频文件,也作为参数传入 if ( NULL == fp ) { printf("failed to open file,please check the file.\n"); error = true; } } if (error == false) { fout = fopen("iat_result.txt", "ab"); if( NULL == fout ) { printf("failed to open file,please check the file.\n"); error = true; } } if (error == false) { printf("writing audio...\n"); char param_value[32] = "";//参数值的字符串形式 size_t value_len = 32; //字符串长度或buffer长度 int volume = 0;//音量数值 while ( !feof(fp) ) { len = fread(buff, 1, BUFFER_NUM, fp); // printf("."); ret = QISRAudioWrite(sess_id, buff, len, status, &ep_status, &rec_status); if ( ret != MSP_SUCCESS ) { printf("\nQISRAudioWrite err %d\n", ret); error = true; break; } value_len = 32; ret = QISRGetParam(sess_id,"volume",param_value,&value_len); if ( ret != MSP_SUCCESS ) { printf("QISRGetParam: qisr get param failed Error code %d.\n",ret); char key = _getch(); break; } volume = atoi(param_value); //printf("volume== %d \n",volume); for (int i=0;i<volume;i++) { //printf("."); } // printf("\n"); if (ep_status == MSP_EP_AFTER_SPEECH) { printf("QISRAudioWrite: ep_status == MSP_EP_AFTER_SPEECH.\n"); break; } if ( rec_status == MSP_REC_STATUS_SUCCESS ) { const char* result = QISRGetResult(sess_id, &rslt_status, 0, &ret) ; if( rslt_status == MSP_REC_STATUS_NO_MATCH ) printf("get result nomatch\n"); else { if ( result != NULL ) fwrite( result, 1, strlen(result), fout); // guowei = result ; printf("get guowei[%d/%d]: %s\n", ret, rslt_status, guowei); printf("get result[%d/%d]: %s\n", ret, rslt_status, result); } } Sleep(200); } printf("\n"); fclose(fp); } if (error == false) { status = MSP_AUDIO_SAMPLE_LAST; ret = QISRAudioWrite(sess_id, buff, 1, status, &ep_status, &rec_status); if ( ret != MSP_SUCCESS ) { printf("QISRAudioWrite write last audio err %d\n", ret); error = true; } } if (error == false) { printf("get reuslt\n"); int loop_count = 0; do { const char* result = QISRGetResult(sess_id, &rslt_status, 0, &ret); if ( ret != MSP_SUCCESS ) { printf("QISRGetResult err %d\n", ret); error = true; break; } if( rslt_status == MSP_REC_STATUS_NO_MATCH ) printf("get result nomatch\n"); else { if ( result != NULL ) fwrite(result, 1, strlen(result), fout); printf("[%d]:get result[%d/%d]: %s\n", (loop_count), ret, rslt_status, result); } Sleep(500); } while (rslt_status != MSP_REC_STATUS_COMPLETE && loop_count++ < 30); } if( NULL != fout ) { fclose(fout); } ret = QISRSessionEnd(sess_id, NULL); if ( ret != MSP_SUCCESS ) { printf("QISRSessionEnd err %d\n", ret); return; } printf("QISRSessionEnd.\n"); ret = QISRFini(); return;}
from : http://bbs.csdn.net/topics/390428493
- 讯飞的语音识别技术VC源码
- 语音识别技术的基础
- 语音识别技术的先锋
- 语音识别的技术原理
- 语音识别技术的最新进展
- 基于DBN的语音识别技术分析
- 基于DBN的语音识别技术分析
- 语音识别的技术原理是什么?
- Atitit 语音识别的技术原理
- 关于语音识别技术的初探
- 语音识别的技术原理是什么?
- 语音识别的技术原理是什么?
- 语音识别的技术路线学习笔记
- 使用科大讯飞的语音技术实现语音识别
- 使用科大讯飞的语音技术实现语音识别
- 语音识别技术简述
- 语音识别技术
- 语音识别编程技术
- SqlServer中增加一列递增的序号
- Android 学习笔记——利用JNI技术在Android中调用、调试C++代码
- Python 特殊语法filter、map、reduce、lambda
- 计算最大序列和算法
- Python正则表达式--无捕获组和命名组
- 讯飞的语音识别技术VC源码
- SqlServer数据类型、C#SqlDbType对应关系及转换
- BoradcastReceiver 研究
- cocos2d-x配置Android项目相关事宜
- 关于 logging 的一些琐事
- git checkout -B android 5648d4e 不行啊。
- ONGL表达式的用法(精)
- Python的map函数实现代码
- ActiveMQ5.0实战三:使用Spring发送,消费topic和queue消息