ROS結合科大訊飛語音簡單控制機械人

2021-09-30 18:23:37 字數 2682 閱讀 7604

這是科大訊飛的語音sdk包做了一點修改,加上自己的語音控制**

/** 語音聽寫(ifly auto transform)技術能夠實時地將語音轉換成對應的文字。

*/#include

#include

#include

#include

#include "robot_voice/qisr.h"

#include "robot_voice/msp_cmn.h"

#include "robot_voice/msp_errors.h"

#include "robot_voice/speech_recognizer.h"

#include

#include "ros/ros.h"

#include "std_msgs/string.h"

#define frame_len   640

#define buffer_size 4096

int wakeupflag   = 1 ;

int resultflag   = 0 ;

static void show_result(char *string, char is_over)

static char *g_result = null;

static unsigned int g_buffersize = buffer_size;

void on_result(const char *result, char is_last)

}strncat(g_result, result, size);

show_result(g_result, is_last);}}

void on_speech_begin()

g_result = (char*)malloc(buffer_size);

g_buffersize = buffer_size;

memset(g_result, 0, g_buffersize);

printf("start listening...\n");

}void on_speech_end(int reason)

/* demo recognize the audio from microphone */

static void demo_mic(const char* session_begin_params)

;errcode = sr_init(&iat, session_begin_params, sr_mic, &recnotifier);

if (errcode)

errcode = sr_start_listening(&iat);

if (errcode)

/* demo 10 seconds recording */

while(i++ < 3)

sleep(1);

errcode = sr_stop_listening(&iat);

if (errcode)

sr_uninit(&iat);

}/* main thread: start/stop record ; query the result of recgonization.

* record thread: record callback(data write)

* helper thread: ui(keystroke detection)

*/void wakeup(const std_msgs::string::constptr& msg)

int main(int argc, char* ar**)

printf("demo recognizing the speech from microphone\n");

printf("speak in 10 seconds\n");

demo_mic(session_begin_params);

printf("10 sec passed\n");

wakeupflag=1;

msplogout();

}// 語音識別完成

科大訊飛語音識別

2.登陸訊飛伺服器 建立乙個訊飛語音識別物件,可以對他進行一系列的呼叫 objc view plain copy 帶介面的識別物件 property nonatomic,strong iflyrecognizerview iflyrecognizerview objc view plain copy...

科大訊飛語音合成 iOS

使用示例如下 c c code 標頭檔案定義 需要實現iflyspeechsynthesizerdelegate,為合成會話的服務 inte ce ttsviewcontroller uiviewcontroller 建立合成物件,為單例模式 iflyspeechsynthesizer iflysp...

科大訊飛語音識別demo

2017年12月,雲 社群對外發布,從最開始的技術部落格到現在擁有多個社群產品。未來,我們一起乘風破浪,創造無限可能。最近在做乙個文字轉語音tts text to speech 的第三方軟體封裝,使用的是國內語音技術龍頭安徽科大訊飛公司提供的離線引擎aisound5.0,主要用於汽車導航用途。科大訊...