From a13409d2d8f1e242eff558ab45d76ddd4bffbf0b Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 11 Jul 2025 09:46:49 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96tts=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aivoice/include/AiVoiceModelC.h | 2 ++ .../nativeui/aivoice/src/AiVoiceModel.cpp | 12 ++++++++++++ .../nativeui/aivoice/src/AiVoicePresenter.cpp | 8 ++++++-- .../ble_service/bleservice/bleService.c | 18 ++++++++++++++++++ .../peripheral/slip/cat1Service/cat1_ws.cpp | 2 ++ 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModelC.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModelC.h index be87d5074..c74b0bebe 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModelC.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModelC.h @@ -10,6 +10,8 @@ extern "C" #include uint8_t getselect4gorbtai(void); + uint8_t get_clear_queue_stream(void); + void set_clear_queue_stream(uint8_t); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp index 286d86136..934f9c41b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -1803,6 +1803,18 @@ extern "C" return 0; } + static uint8_t clear_queue_stream = 0; + uint8_t get_clear_queue_stream(void) + { + return clear_queue_stream; + } + + // 清空队列中可能存在的音频数据 + void set_clear_queue_stream(uint8_t state) + { + clear_queue_stream = state; + } + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp index 852d99f02..c0690d679 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -38,6 +38,7 @@ namespace OHOS #include "pm.h" #include "pm_veto.h" #include +#include void remove_4GAI_vote(void) { @@ -405,7 +406,8 @@ namespace OHOS if (model->GetSelect4gorbt() == AI_SELECT_4G) { AiVoiceModel::GetInstance().stop_ai4g_tts_play_timer(); - usleep(50000); + // usleep(50000); + LOS_Msleep(50); uapi_UI_start_asr(); ChangeViewAndLogicOperator(AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_AIMODE_CONNECTING); return true; @@ -422,8 +424,10 @@ namespace OHOS { AiVoiceModel::GetInstance().stop_ai4g_tts_play_timer(); // model->cancel_tts_play(); + set_clear_queue_stream(1); + // usleep(50000); + LOS_Msleep(50); dinit_ai_task(); - usleep(50000); } } ChangeViewAndLogicOperator(it->second.first, it->second.second); diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index 12e926e1c..4ba80ef34 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -2447,6 +2447,24 @@ static void blesrvAi_send_service_task(void const *arg) if(getselect4gorbtai() == 1) //选择的是4g { + if(get_clear_queue_stream()) + { + // osal_msg_queue_write_head_copy(g_ble_Ai_record_queue, (void *)&mail,sizeof(blesrv_custom_cmd_t), 0); + int quesize = osal_msg_queue_get_msg_num(g_ble_Ai_record_queue); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,"do_uart_slip_cmd quesize %d\n",quesize); + while(quesize) + { + osal_msg_queue_read_copy(g_ble_Ai_record_queue, (void *)&mail, &msgsize, + OSAL_MSGQ_WAIT_FOREVER); + if(mail.msg_data) + { + free(mail.msg_data); + mail.msg_data = NULL; + } + quesize--; + } + set_clear_queue_stream(0); + } if(mail.msg_data && mail.msg_len!=0) { if(server_handle == 200 ||server_handle == 201 ) diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp index 4ad686766..048ee9afc 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp @@ -1226,6 +1226,7 @@ void bk_websocket_demo(void *data) { #include "soc_osal.h" #include "common_def.h" #include "los_printf.h" +#include #define CAT1_SERVICE_TASK_SIZE (2048) #define CAT1_SERVICE_TASK_PRIO 5 @@ -1966,6 +1967,7 @@ void bk_websocket_tts(void *data) { { if(disconnect_server==0) { + set_clear_queue_stream(1); goto TTS_SATRT; } tts_reconnect=0; -- 2.17.1