Public Member Functions | Private Member Functions | Private Attributes | List of all members
XfeiSpeechRecog Class Reference

#include <xfei_speech_recog.h>

Public Member Functions

char * dataLoopRecog ()
 将全部音频数据循环写入科大讯飞接口进行识别并获取完整的json识别结果. More...
 
void getPCMData (struct DataBuff pcm_buff)
 获取pcm数据接口. More...
 
void getPcmFileData ()
 读取pcm文件里的音频数据,并将数据的内容和数据大小存入pcm_data_. More...
 
void initAsr ()
 科大讯飞识别模块的初始化. More...
 
struct DataBuff recordThroughMIC (const float record_time, bool enable_audio_save)
 录音接口. More...
 
std::vector< std::string > resultFromJson ()
 从完整的json语音识别结果中解析出需要的字符串结果和置信度值. More...
 
void setAsrParams (const std::string base_path, const std::string pcm_file, const std::string params, const int channel)
 设置语音模块需外部传入的路径等参数. More...
 
void stopRecordThroughMIC ()
 关闭录音设备. More...
 
void uninitAsr ()
 一次识别结束后释放资源. More...
 
void writeAudioData (const char *audio_data, unsigned int audio_len)
 将pcm音频写入科大讯飞QISRAudioWrite接口. More...
 
 XfeiSpeechRecog ()
 

Private Member Functions

struct DataBuff getOneChannelData ()
 从双声道数据中分离出单声道数据. More...
 
char * getRecogResultLoop ()
 获取完整的json语音识别结果. More...
 
void saveRecordDataToFile ()
 把录音数据存入/cache/pcm/目录下的pcm文件里,以次序和时间命名. More...
 

Private Attributes

std::string asr_params_
 
struct recorderasr_record_ = NULL
 
int audio_stat_
 
std::string base_path_
 
int channel_
 
std::string final_recog_result_
 
struct DataBuff pcm_data_ = { NULL, 0 }
 
std::string pcm_file_
 
FileOperation pcm_file_operation
 
char * rec_result_ = NULL
 
int recog_confidence_ = 0
 
std::vector< std::string > recog_result_vector
 
RecordAlsaAPI record_alsa
 
int record_loops_ = 0
 
const char * session_id_ = NULL
 
struct speech_recog speech_recog_
 

Detailed Description

Definition at line 24 of file xfei_speech_recog.h.

Constructor & Destructor Documentation

XfeiSpeechRecog::XfeiSpeechRecog ( )
inline

Definition at line 27 of file xfei_speech_recog.h.

Member Function Documentation

char * XfeiSpeechRecog::dataLoopRecog ( )

将全部音频数据循环写入科大讯飞接口进行识别并获取完整的json识别结果.

Returns
char* rec_result_ - 完整的json识别结果,若没有识别结果,返回NULL.

Definition at line 95 of file xfei_speech_recog.cpp.

struct DataBuff XfeiSpeechRecog::getOneChannelData ( )
private

从双声道数据中分离出单声道数据.

Returns
struct DataBuff pcm_data_ - 返回单声道的pcm数据和大小.

Definition at line 81 of file xfei_speech_recog.cpp.

void XfeiSpeechRecog::getPCMData ( struct DataBuff  pcm_buff)

获取pcm数据接口.

Parameters
pcm_buff- [in] pcm数据的内容和数据大小.

Definition at line 150 of file xfei_speech_recog.cpp.

void XfeiSpeechRecog::getPcmFileData ( )

读取pcm文件里的音频数据,并将数据的内容和数据大小存入pcm_data_.

Definition at line 34 of file xfei_speech_recog.cpp.

char * XfeiSpeechRecog::getRecogResultLoop ( )
private

获取完整的json语音识别结果.

Returns
char* rec_result_ - 返回语音识别的完整json结果,若没有识别结果,返回NULL.

Definition at line 52 of file xfei_speech_recog.cpp.

void XfeiSpeechRecog::initAsr ( )

科大讯飞识别模块的初始化.

Definition at line 22 of file xfei_speech_recog.cpp.

struct DataBuff XfeiSpeechRecog::recordThroughMIC ( const float  record_time,
bool  enable_audio_save 
)

录音接口.

Parameters
record_time- [in] 录音时长(s).
enable_audio_save- [in] 是否将录音保存到pcm文件.
Returns
struct DataBuff pcm_data_ - 返回录音的pcm数据和大小.

Definition at line 223 of file xfei_speech_recog.cpp.

std::vector< std::string > XfeiSpeechRecog::resultFromJson ( )

从完整的json语音识别结果中解析出需要的字符串结果和置信度值.

Returns
std::vector<std::string> recog_result_vector[2] - 返回保存识别结果和置信度值的变量.

Definition at line 178 of file xfei_speech_recog.cpp.

void XfeiSpeechRecog::saveRecordDataToFile ( )
private

把录音数据存入/cache/pcm/目录下的pcm文件里,以次序和时间命名.

Definition at line 214 of file xfei_speech_recog.cpp.

void XfeiSpeechRecog::setAsrParams ( const std::string  base_path,
const std::string  pcm_file,
const std::string  params,
const int  channel 
)

设置语音模块需外部传入的路径等参数.

Parameters
base_path- [in] 到/xbot_talker目录的结对路径.
pcm_file- [in] 用于进行语音识别的录音文件.
params- [in] 科大讯飞参数
channel- [in] 音频声道数.1表示单声道,2表示双声道.

Definition at line 13 of file xfei_speech_recog.cpp.

void XfeiSpeechRecog::stopRecordThroughMIC ( )

关闭录音设备.

Definition at line 330 of file xfei_speech_recog.cpp.

void XfeiSpeechRecog::uninitAsr ( )

一次识别结束后释放资源.

Definition at line 156 of file xfei_speech_recog.cpp.

void XfeiSpeechRecog::writeAudioData ( const char *  audio_data,
unsigned int  audio_len 
)

将pcm音频写入科大讯飞QISRAudioWrite接口.

Parameters
audio_data- [in] pcm音频数据.
audio_len- [in] pcm音频大小.

Definition at line 40 of file xfei_speech_recog.cpp.

Member Data Documentation

std::string XfeiSpeechRecog::asr_params_
private

Definition at line 136 of file xfei_speech_recog.h.

struct recorder* XfeiSpeechRecog::asr_record_ = NULL
private

Definition at line 138 of file xfei_speech_recog.h.

int XfeiSpeechRecog::audio_stat_
private

Definition at line 128 of file xfei_speech_recog.h.

std::string XfeiSpeechRecog::base_path_
private

Definition at line 134 of file xfei_speech_recog.h.

int XfeiSpeechRecog::channel_
private

Definition at line 137 of file xfei_speech_recog.h.

std::string XfeiSpeechRecog::final_recog_result_
private

Definition at line 132 of file xfei_speech_recog.h.

struct DataBuff XfeiSpeechRecog::pcm_data_ = { NULL, 0 }
private

Definition at line 129 of file xfei_speech_recog.h.

std::string XfeiSpeechRecog::pcm_file_
private

Definition at line 135 of file xfei_speech_recog.h.

FileOperation XfeiSpeechRecog::pcm_file_operation
private

Definition at line 139 of file xfei_speech_recog.h.

char* XfeiSpeechRecog::rec_result_ = NULL
private

Definition at line 131 of file xfei_speech_recog.h.

int XfeiSpeechRecog::recog_confidence_ = 0
private

Definition at line 133 of file xfei_speech_recog.h.

std::vector<std::string> XfeiSpeechRecog::recog_result_vector
private

Definition at line 126 of file xfei_speech_recog.h.

RecordAlsaAPI XfeiSpeechRecog::record_alsa
private

Definition at line 140 of file xfei_speech_recog.h.

int XfeiSpeechRecog::record_loops_ = 0
private

Definition at line 125 of file xfei_speech_recog.h.

const char* XfeiSpeechRecog::session_id_ = NULL
private

Definition at line 127 of file xfei_speech_recog.h.

struct speech_recog XfeiSpeechRecog::speech_recog_
private

Definition at line 130 of file xfei_speech_recog.h.


The documentation for this class was generated from the following files:


xbot_talker
Author(s): wangxiaoyun
autogenerated on Sat Oct 10 2020 03:27:54