awaken_offline.h
Go to the documentation of this file.
1 
7 #ifndef AWAKEN_OFFLINE_H_
8 #define AWAKEN_OFFLINE_H_
9 #include <iostream>
10 #include "file_operation.h"
11 #include "linuxrec.h"
14 {
15 public:
23  void loginAndSetParams(const std::string base_path, const std::string pcm_file, const int channel);
24 
29  void awakenInit();
30 
35  void uninitAsr();
36 
41  void getPcmFileData();
42 
49  void writeAudioData(const char* audio_data, unsigned int audio_len);
50 
55  void dataLoopAwaken();
56 
61  void saveRecordDataToFile();
62 
69  void recordThroughMIC(const float record_time, bool enable_audio_save);
70 
75  void stopRecordThroughMIC();
76 
81  void checkIsAwaken();
82 
83  static char* awaken_result_;
84  static bool is_awaken;
85 
86 private:
87  const int FRAME_LEN = 640; // 16k采样率的16bit音频,一帧的大小为640B, 时长20ms
88  const char* awaken_params_;
89  struct DataBuff pcm_data_ = { NULL, 0 }; // 存储pcm音频数据
90  std::string pcm_file_; // 保存的音频文件
91  std::string base_path_; // 表示到xbot_talker的绝对路径
92  const char* session_id_ = NULL;
94  struct recorder* awaken_record_ = NULL;
95  static int cb_ivw_msg_proc(const char* sessionID, int msg, int param1, int param2, const void* info, void* userData);
98  int channel_;
100  struct DataBuff getOneChannelData();
101 };
102 
103 #endif
static bool is_awaken
std::string base_path_
void checkIsAwaken()
检测是否唤醒.
const char * session_id_
std::string pcm_file_
void recordThroughMIC(const float record_time, bool enable_audio_save)
录音并进行语音唤醒.
void writeAudioData(const char *audio_data, unsigned int audio_len)
将pcm音频写入科大讯飞QIVWAudioWrite接口.
void dataLoopAwaken()
将音频数据循环写入科大讯飞接口进行离线唤醒.
void uninitAsr()
一次离线唤醒结束后释放资源.
void awakenInit()
科大讯飞离线唤醒模块的初始化.
struct recorder * awaken_record_
const int FRAME_LEN
void getPcmFileData()
读取pcm文件里的音频数据,并将数据的内容和数据大小存入pcm_data_结构体.
const char * awaken_params_
void loginAndSetParams(const std::string base_path, const std::string pcm_file, const int channel)
科大讯飞离线唤醒登录以及参数设置.
static int cb_ivw_msg_proc(const char *sessionID, int msg, int param1, int param2, const void *info, void *userData)
static char * awaken_result_
void saveRecordDataToFile()
把录音数据存入/cache/pcm/目录下的pcm文件里,以次序和时间命名.
const std::string base_path
void stopRecordThroughMIC()
关闭录音设备.
struct DataBuff getOneChannelData()
FileOperation file_operation
RecordAlsaAPI record_alsa
struct DataBuff pcm_data_


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