资源简介
离线语音识别,树莓派语音识别科大讯飞语音识别离线包。
代码片段和文件信息
/*
* 语音识别(Automatic Speech Recognition)技术能够从语音中识别出特定的命令词或语句模式。
*/
#include
#include
#include
#include
#include “qisr.h“
#include “msp_cmn.h“
#include “msp_errors.h“
#define BUFFER_SIZE 2048
#define HINTS_SIZE 100
#define GRAMID_LEN 128
#define frame_LEN 640
int get_grammar_id(char* grammar_id unsigned int id_len)
{
FILE* fp = NULL;
char* grammar = NULL;
unsigned int grammar_len = 0;
unsigned int read_len = 0;
const char* ret_id = NULL;
unsigned int ret_id_len = 0;
int ret = -1;
if (NULL == grammar_id)
goto grammar_exit;
fp = fopen(“gm_continuous_digit.abnf“ “rb“);
if (NULL == fp)
{
printf(“\nopen grammar file failed!\n“);
goto grammar_exit;
}
fseek(fp 0 SEEK_END);
grammar_len = ftell(fp); //获取语法文件大小
fseek(fp 0 SEEK_SET);
grammar = (char*)malloc(grammar_len + 1);
if (NULL == grammar)
{
printf(“\nout of memory!\n“);
goto grammar_exit;
}
read_len = fread((void *)grammar 1 grammar_len fp); //读取语法内容
if (read_len != grammar_len)
{
printf(“\nread grammar error!\n“);
goto grammar_exit;
}
grammar[grammar_len] = ‘\0‘;
ret_id = MSPUploadData(“usergram“ grammar grammar_len “dtt = abnf sub = asr“ &ret); //上传语法
if (MSP_SUCCESS != ret)
{
printf(“\nMSPUploadData failed error code: %d.\n“ ret);
goto grammar_exit;
}
ret_id_len = strlen(ret_id);
if (ret_id_len >= id_len)
{
printf(“\nno enough buffer for grammar_id!\n“);
goto grammar_exit;
}
strncpy(grammar_id ret_id ret_id_len);
printf(“grammar_id: \“%s\“ \n“ grammar_id); //下次可以直接使用该ID,不必重复上传语法。
grammar_exit:
if (NULL != fp)
{
fclose(fp);
fp = NULL;
}
if (NULL!= grammar)
{
free(grammar);
grammar = NULL;
}
return ret;
}
void run_asr(const char* audio_file const char* params char* grammar_id)
{
const char* session_id = NULL;
char rec_result[BUFFER_SIZE] = {‘\0‘};
char hints[HINTS_SIZE] = {‘\0‘}; //hints为结束本次会话的原因描述,由用户自定义
unsigned int total_len = 0;
int aud_stat = MSP_AUDIO_SAMPLE_CONTINUE; //音频状态
int ep_stat = MSP_EP_LOOKING_FOR_SPEECH; //端点检测
int rec_stat = MSP_REC_STATUS_SUCCESS; //识别状态
int errcode = MSP_SUCCESS;
FILE* f_pcm = NULL;
char* p_pcm = NULL;
long pcm_count = 0;
long pcm_size = 0;
long read_size = 0;
if (NULL == audio_file)
goto asr_exit;
f_pcm = fopen(audio_file “rb“);
if (NULL == f_pcm)
{
printf(“\nopen [%s] failed!\n“ audio_file);
goto asr_exit;
}
fseek(f_pcm 0 SEEK_END);
pcm_size = ftell(f_pcm); //获取音频文件大小
fseek(f_pcm 0 SEEK_SET);
p_pcm = (char*)malloc(pcm_size);
if (NULL == p_pcm)
{
printf(“\nout of memory!\n“);
goto asr_exit;
}
read_size = fread((void *)p_pcm 1 pcm_size f_pcm); //读取音频文件内容
if (read_size != pcm_size)
{
printf(“\nread [%
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-06-17 21:35 Linux_voice_1.109\
文件 1407 2015-11-23 14:40 Linux_voice_1.109\README.txt
目录 0 2016-06-17 21:35 Linux_voice_1.109\bin\
文件 376 2015-09-17 20:33 Linux_voice_1.109\bin\gm_continuous_digit.abnf
目录 0 2016-06-17 21:35 Linux_voice_1.109\bin\msc\
文件 743 2015-09-17 20:57 Linux_voice_1.109\bin\msc\msc.cfg
文件 242 2015-09-17 20:33 Linux_voice_1.109\bin\userwords.txt
目录 0 2016-06-17 21:35 Linux_voice_1.109\bin\wav\
文件 139442 2015-01-26 17:12 Linux_voice_1.109\bin\wav\iflytek01.wav
文件 148220 2015-09-16 18:01 Linux_voice_1.109\bin\wav\iflytek02.wav
目录 0 2016-06-17 21:35 Linux_voice_1.109\doc\
文件 80978 2014-08-09 07:22 Linux_voice_1.109\doc\Grammar Development Guidelines.chm
文件 755702 2015-07-19 22:13 Linux_voice_1.109\doc\MSC Novice Manual for Linux.pdf
文件 2836511 2015-09-16 17:08 Linux_voice_1.109\doc\Open Semantic Platform API Documents.pdf
目录 0 2016-06-17 21:35 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\
文件 246 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\arrowdown.png
文件 229 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\arrowright.png
文件 676 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\bc_s.png
文件 147 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\bdwn.png
文件 132 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\closed.png
文件 5113 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\dir_aec8ed7db4e023b762de5ebd500ab794.html
文件 746 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\doc.png
文件 25493 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\doxygen.css
文件 3779 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\doxygen.png
文件 3140 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\dynsections.js
文件 5245 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\files.html
文件 616 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\folderclosed.png
文件 597 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\folderopen.png
文件 5494 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\globals.html
文件 5409 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\globals_func.html
文件 3443 2016-01-11 09:23 Linux_voice_1.109\doc\iFlytek MSC Reference Manual\index.html
............此处省略76个文件信息
- 上一篇:gdal工具exe
- 下一篇:Total Commander v9.21a最新破解版
相关资源
- 基于STM32和树莓派的四足人形机器人系
- 基于Arduino的智能家居语音识别系统设
- 语音识别资料和源码
- LD3320语音识别模块
- building the web of things Dominique D. Guina
- 组合数学第四版答案
- 语音识别基本法
- 树莓派开始玩转linux.pdf
- qt实现科大讯飞在线语音识别
- 极简单的讯飞语音识别Demo
- 基于STM32F429的语音识别交互系统
- putty+VNC+Win32DiskImager
- 语音识别数据集-speech analytic--性别识
- WIN732位语音识别组件包
- 树莓派实战指南100个案例
- 说话人识别数据集--Spoken Speaker Ident
- 语音识别demo
- STM32语音识别资料
- FOCAS2 Library.zip
- YM_TCPtool树莓派网络调试助手_免安装
- 安卓socket控制树莓派GPIO(含server及
- 基于STM32F4VET6开发板的智能语音识别系
- 威凯特ISD9160语音识别例程
- YS-V0.7语音识别模块_配套资料
- Arduino HBR740语音识别
- win32DiskImager
- 实用语音识别基础电子版
- 语音识别 自然语言信号处理 Speech a
- 百度语音识别/唤醒Test
- 树莓派Chromium-browser离线安装包66.0.3
评论
共有 条评论