fix(audio): isolate conversation timeouts by round
This commit is contained in:
@@ -43,7 +43,9 @@ static uint8_t vad_leave_message_flag = 0;//留言模式vad只做单次
|
||||
static Fvad *fvad_inst = NULL;
|
||||
extern struct ringbuffer *ring_sender;
|
||||
extern ql_sem_t sender_sem;
|
||||
extern unsigned char wss_connect_start; //表示vad拾音结束 开始等待后台返回 如果超过5s没有返回 则报超时语音
|
||||
extern void conversation_no_speech(void);
|
||||
extern void conversation_record_begin(void);
|
||||
extern void conversation_cancel_wait(void);
|
||||
|
||||
// 配置
|
||||
static int sample_rate = 16000; // FVAD 支持的采样率:8k/16k/32k/48k
|
||||
@@ -89,6 +91,12 @@ void vad_tts_playback_finished()
|
||||
vad_tts_playback_finished_status = 1;
|
||||
}
|
||||
|
||||
void vad_reset_conversation_flags(void)
|
||||
{
|
||||
no_speech_timeout = 0;
|
||||
vad_tts_playback_finished_status = 0;
|
||||
}
|
||||
|
||||
void vad_set_speech_timeout_flag(uint8_t value)
|
||||
{
|
||||
no_speech_timeout = value;
|
||||
@@ -216,7 +224,7 @@ int vad_audio_stop(void) {
|
||||
|
||||
ql_audio_record_close(record_hd, 1);
|
||||
|
||||
wss_connect_start = 1;//用于判断后台响应超时
|
||||
/* Reply timeout starts in the sender only after END is submitted. */
|
||||
|
||||
key_start_leave = 0;
|
||||
//ql_rtos_semaphore_release(sender_sem);
|
||||
@@ -226,6 +234,7 @@ int vad_audio_stop(void) {
|
||||
|
||||
// 停止录音
|
||||
int vad_audio_stop_no_wait_resp(void) {
|
||||
conversation_cancel_wait();
|
||||
|
||||
printf("Audio recording stopped no_wait_resp, frames: %d, speech: %d",
|
||||
frame_count, speech_frame_count);
|
||||
@@ -234,7 +243,7 @@ int vad_audio_stop_no_wait_resp(void) {
|
||||
|
||||
ql_audio_record_close(record_hd, 1);
|
||||
|
||||
wss_connect_start = 0;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -242,6 +251,7 @@ int vad_audio_stop_no_wait_resp(void) {
|
||||
|
||||
// 触发录音(按键触发)
|
||||
void vad_audio_trigger_record(void) {
|
||||
conversation_record_begin();
|
||||
g_triggered = true;
|
||||
printf("Record triggered");
|
||||
}
|
||||
@@ -449,6 +459,7 @@ void vad_audio_process(void) {
|
||||
if ((now - no_sound_start_time) > VAD_NO_SOUND_TIMEOUT_MS) {
|
||||
printf("No speech for timeout, stopping");
|
||||
no_speech_timeout = 1;
|
||||
conversation_no_speech();
|
||||
set_state(STATE_WAITING_COMMAND);
|
||||
vad_audio_stop();
|
||||
buffer_offset = 0;
|
||||
|
||||
Reference in New Issue
Block a user