From ea7e1dc3d183349daca06cd048359bcffe0e41a5 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Wed, 23 Jul 2025 18:23:26 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B3=EF=BC=9A=E8=AF=A2=E9=97=AE?= =?utf8?q?=E9=97=AE=E9=A2=98=E7=A8=8D=E5=BE=AE=E5=81=9C=E9=A1=BF=E4=B8=80?= =?utf8?q?=E4=B8=8B=EF=BC=8C=E5=B0=B1=E4=BC=9A=E8=87=AA=E5=8A=A8=E8=AF=86?= =?utf8?q?=E5=88=AB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aivoice/include/AiVoiceModel.h | 2 +- .../nativeui/aivoice/src/AiVoiceModel.cpp | 54 +++++++++---------- .../nativeui/aivoice/src/AiVoicePresenter.cpp | 13 ++++- .../slip/cat1Service/cat1_ai_server.cpp | 3 +- .../voice_call_volte_sample_wrapper.cpp | 2 +- 5 files changed, 39 insertions(+), 35 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h index 6f1a8d0cf..ffa79fd35 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h @@ -156,7 +156,7 @@ namespace OHOS std::string GetAccumulatedText(void); void sendSegment(const std::string &text, size_t pos); - static bool cur_ai_4g_answer_update; + bool is_need_to_jump_result_view(void); private: AiVoiceModel(); 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 a2a91eeed..a20a80d0d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -526,26 +526,18 @@ namespace OHOS /*设置用户问题的字符串*/ void AiVoiceModel::SetUserQuestionStr(std::string str) { - if (GetSelect4gorbt() == AI_SELECT_4G) // 4G - { - userQuestionStr = str; - SendMsgToUIService(UI_UPDATE_USER_QUESTION_STR, 0, nullptr, 0); - } - else if (GetSelect4gorbt() == AI_SELECT_BT) // 蓝牙 + if (!entryTextViewState) { - if (!entryTextViewState) - { - SendMsgToUIService(UI_AI_JUMP_TO_RESULT_VIEW, 0, nullptr, 0); - entryTextViewState = true; // 进入返回结果界面的标志 避免重复发消息 - usleep(50000); // 延时等待创建完成,0.05秒 - } - /* -------------------------------------------------------------------------- */ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "传入的问题:%s", str.c_str()); - userQuestionStr = str; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "拼接的问题:%s", userQuestionStr.c_str()); - /* -------------------------------------------------------------------------- */ - SendMsgToUIService(UI_UPDATE_USER_QUESTION_STR, 0, nullptr, 0); + SendMsgToUIService(UI_AI_JUMP_TO_RESULT_VIEW, 0, nullptr, 0); + entryTextViewState = true; // 进入返回结果界面的标志 避免重复发消息 + usleep(50000); // 延时等待创建完成,0.05秒 } + /* -------------------------------------------------------------------------- */ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "传入的问题:%s", str.c_str()); + userQuestionStr = str; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "拼接的问题:%s", userQuestionStr.c_str()); + /* -------------------------------------------------------------------------- */ + SendMsgToUIService(UI_UPDATE_USER_QUESTION_STR, 0, nullptr, 0); } /*获取Ai回答的字符串*/ @@ -1128,7 +1120,10 @@ namespace OHOS { if (AiVoiceModel::GetInstance().GetSelect4gorbt() == AI_SELECT_4G) { - // AiVoiceModel::GetInstance().AIVoice_StopTimer();//TOOD:之后修改 + if (AiVoiceModel::GetInstance().is_need_to_jump_result_view()) + { + SendMsgToUIService(UI_AI_JUMP_TO_RESULT_VIEW, 0, nullptr, 0); // 跳转到结果界面 + } return; } else if (AiVoiceModel::GetInstance().GetSelect4gorbt() == AI_SELECT_BT) @@ -1676,7 +1671,6 @@ namespace OHOS static osTimerId_t g_start_ai_answer_update_Handle = nullptr; static constexpr const int8_t NUMBER_THREE = 3; static int8_t START_UPDATE_AIANSWER_CNT = NUMBER_THREE; - bool AiVoiceModel::cur_ai_4g_answer_update = false; static void AI4G_START_AI_ANSWER_CallbackProc(int data) { START_UPDATE_AIANSWER_CNT--; @@ -1687,15 +1681,6 @@ namespace OHOS else { SendMsgToUIService(UI_UPDATE_AI_ANSWER_STR, 0, nullptr, 0); - // if(!AiVoiceModel::cur_ai_4g_answer_update) - // { - // AiVoiceModel::cur_ai_4g_answer_update = true; - // if(AiVoiceModel::GetInstance().UpdateAiAnswerStr()) - // { - // AiVoiceModel::cur_ai_4g_answer_update = false; - // LOS_Msleep(10); - // } - // } } } @@ -1755,7 +1740,6 @@ namespace OHOS } g_start_ai_answer_update_Handle = nullptr; START_UPDATE_AIANSWER_CNT = NUMBER_THREE; - AiVoiceModel::cur_ai_4g_answer_update = false; } } @@ -1828,6 +1812,16 @@ namespace OHOS tts_server_deinit(); } + // 是否需要跳转到结果视图 + bool AiVoiceModel::is_need_to_jump_result_view(void) + { + if (userQuestionStr.empty()) + { + return false; + } + return true; + } + /*获取已选择的ai模型的textid*/ int AiVoiceModel::GetAiModelTextId() { 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 fdaeaecce..8f950bca8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -554,7 +554,18 @@ namespace OHOS } else if (viewId == FINISH_SPEAKING_BUTTON_VIEW_ID) // 如果点击的是说话完毕按钮 { - ChangeViewAndLogicOperator(AIVOICE_LISTENING_VIEWID, AIVOICE_THINKING_VIEWID); + if (model->GetSelect4gorbt() == AI_SELECT_4G) + { + uapi_UI_stop_asr(); + if (!model->is_need_to_jump_result_view()) //没有数据就跳转到思考中界面 + { + ChangeViewAndLogicOperator(AIVOICE_LISTENING_VIEWID, AIVOICE_THINKING_VIEWID); + } + } + else if (model->GetSelect4gorbt() == AI_SELECT_BT) + { + ChangeViewAndLogicOperator(AIVOICE_LISTENING_VIEWID, AIVOICE_THINKING_VIEWID); + } return true; } else if (viewId == AIVOICE_SELECT_VIEW_BUTTON4G_VIEW_ID) // 如果点击的是4G连接方式 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 ff6c82cba..c257d3ffc 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp @@ -177,14 +177,13 @@ void uapi_UI_stop_start_asr_timeout(void) { asr_need_stop=1; } -#if 0 +#if 1 #define ASR_HODE #endif void uapi_UI_stop_asr(void) { #ifdef ASR_HODE - SendMsgToUIService(UI_AI_JUMP_TO_RESULT_VIEW, 0, nullptr, 0);//先跳转到结果界面 if(strlen(result_str_asr)) { diff --git a/code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_sample_wrapper.cpp b/code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_sample_wrapper.cpp index 620013627..702b2a2d9 100755 --- a/code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_sample_wrapper.cpp +++ b/code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_sample_wrapper.cpp @@ -1331,7 +1331,7 @@ static void AudioCaptureProcess_AI(void* arg) g_sample_needStop=1; } #else - if(record_size>=1024*40) + if(record_size>=1024*90) { g_sample_needStop=1; } -- 2.17.1