From d7e8e492e993fc9a6d5169b0d2c694c4ece7d6ff Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Thu, 24 Jul 2025 17:22:37 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B3=E8=AF=B4=E8=AF=9D=E4=B8=80?= =?utf8?q?=E4=B8=AA=E9=97=AE=E9=A2=98=E6=97=B6=E5=BF=AB=E9=80=9F=E7=82=B9?= =?utf8?q?=E5=87=BB=E8=AF=B4=E8=AF=9D=E5=AE=8C=E6=AF=95=E6=8C=89=E9=92=AE?= =?utf8?q?=E5=AF=BC=E8=87=B4=E5=8F=AA=E6=9C=89=E9=97=AE=E9=A2=98=E8=80=8C?= =?utf8?q?=E6=B2=A1=E6=9C=89=E7=AD=94=E6=A1=88bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aivoice/src/AiVoiceModel.cpp | 24 +++++++++++++++-- .../nativeui/aivoice/src/AiVoicePresenter.cpp | 1 + .../slip/cat1Service/cat1_ai_server.cpp | 26 ++++++++++++++----- 3 files changed, 43 insertions(+), 8 deletions(-) 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 a20a80d0d..f9f595364 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -526,6 +526,25 @@ namespace OHOS /*设置用户问题的字符串*/ void AiVoiceModel::SetUserQuestionStr(std::string str) { + if (GetSelect4gorbt() == AI_SELECT_4G) + { + if(str.empty()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "传入的问题为空"); + return; + } + userQuestionStr = str; + if (!entryTextViewState) + { + SendMsgToUIService(UI_AI_JUMP_TO_RESULT_VIEW, 0, nullptr, 0); + entryTextViewState = true; // 进入返回结果界面的标志 避免重复发消息 + usleep(50000); // 延时等待创建完成,0.05秒 + } + /* -------------------------------------------------------------------------- */ + SendMsgToUIService(UI_UPDATE_USER_QUESTION_STR, 0, nullptr, 0); + } + else if (GetSelect4gorbt() == AI_SELECT_BT) + { if (!entryTextViewState) { SendMsgToUIService(UI_AI_JUMP_TO_RESULT_VIEW, 0, nullptr, 0); @@ -538,6 +557,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "拼接的问题:%s", userQuestionStr.c_str()); /* -------------------------------------------------------------------------- */ SendMsgToUIService(UI_UPDATE_USER_QUESTION_STR, 0, nullptr, 0); + } } /*获取Ai回答的字符串*/ @@ -1878,11 +1898,11 @@ namespace OHOS int textId = 0; selectAiModelToTextId = { {0, {STR_DEEPSEEK, 4}}, - {1, {STR_AIMODES_CHATGPT, 1}}, + {1, {STR_JIUTIAN, 5}}, {2, {STR_AIMODELS_DOUBAO, 3}}, {3, {STR_AIMODES_WENXINYIYAN, 0}}, {4, {STR_AIMODES_KIMI, 2}}, - {5, {STR_IFLYTEK_SPARK, 5}}, + {5, {STR_AIMODES_CHATGPT, 1}}, }; textId = STR_DEEPSEEK; 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 8f950bca8..bbde5aa1a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -557,6 +557,7 @@ namespace OHOS if (model->GetSelect4gorbt() == AI_SELECT_4G) { uapi_UI_stop_asr(); + usleep(10000); if (!model->is_need_to_jump_result_view()) //没有数据就跳转到思考中界面 { ChangeViewAndLogicOperator(AIVOICE_LISTENING_VIEWID, AIVOICE_THINKING_VIEWID); diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp index c257d3ffc..7481446fb 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp @@ -130,13 +130,20 @@ char result_str_asr[AI_RESULT_STR_LEN]={0}; static uint8_t type_ai=0; uint8_t chat_reconnect=0; +#if 1 +#define ASR_HODE +static uint8_t asr_is_stop=0; +#endif + void uapi_UI_start_asr(uint8_t type) { memset_s(result_str_asr,AI_RESULT_STR_LEN,0,AI_RESULT_STR_LEN); // uapi_stop_tts(); - + #ifdef ASR_HODE + asr_is_stop=0; + #endif type_ai=type; if(chat_client) @@ -177,9 +184,7 @@ void uapi_UI_stop_start_asr_timeout(void) { asr_need_stop=1; } -#if 1 -#define ASR_HODE -#endif + void uapi_UI_stop_asr(void) { @@ -196,8 +201,7 @@ void uapi_UI_stop_asr(void) if(stop_AudioCaptureProcess_AI()) { - - + asr_is_stop=1; } } @@ -720,6 +724,16 @@ bool aer_result_analysis(char *buf) #ifdef ASR_HODE memcpy_s(&result_str_asr[strlen(result_str_asr)],AI_RESULT_STR_LEN/2,result_str,strlen(result_str)); + + if(asr_is_stop==1 && strlen(result_str_asr)) + { + send_ai_txt(0,result_str_asr); + ble_set_ai_Question_str(result_str_asr); + + memset_s(result_str_asr,AI_RESULT_STR_LEN,0,AI_RESULT_STR_LEN); + } + + #else memset_s(result_str_asr,256,0,256); memcpy_s(result_str_asr,256,result_str,strlen(result_str)); -- 2.17.1