From 93a1145cf392fe9a1e97303be07c788c8a36beec Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 25 Jul 2025 09:59:27 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96AI=E7=AD=94=E6=A1=88=E6=9B=B4?= =?utf8?q?=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aivoice/src/AiVoiceModel.cpp | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 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 ee4c8c4cb..12880bdda 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -528,7 +528,7 @@ namespace OHOS { if (GetSelect4gorbt() == AI_SELECT_4G) { - if(str.empty()) + if (str.empty()) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "传入的问题为空"); return; @@ -545,18 +545,18 @@ namespace OHOS } else if (GetSelect4gorbt() == AI_SELECT_BT) { - 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); + 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); } } @@ -895,21 +895,20 @@ namespace OHOS AiVoiceView *view_ = AiVoiceView::GetInstance(); if (GetSelect4gorbt() == AI_SELECT_4G) // 4G { + if (!OHOS::AiVoiceModel::GetInstance().GetIsLimitDisplayed()) // 如果ai答案没有显示到极限了,就更新ai答案字符串 + { + aiAnswerStr += str; + /* -------------------------------------------------------------------------- */ + // 累积接收到的文本 + accumulatedText += str; + /* -------------------------------------------------------------------------- */ + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "接受字的符串:%s", aiAnswerStr.c_str()); + } if (view_ != nullptr) { if (view_->GetAiVoiceScrollView(AIVOICE_RETURN_RESULT_TEXT_VIEWID) && view_->GetAiVoiceScrollView(AIVOICE_RETURN_RESULT_TEXT_VIEWID)->IsVisible()) { - start_ai4g_tts_play_timer(); // 开启一个定时器,用于播放tts音频 - if (!OHOS::AiVoiceModel::GetInstance().GetIsLimitDisplayed()) // 如果ai答案没有显示到极限了,就更新ai答案字符串 - { - aiAnswerStr += str; - /* -------------------------------------------------------------------------- */ - // 累积接收到的文本 - accumulatedText += str; - /* -------------------------------------------------------------------------- */ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "接受字的符串:%s", aiAnswerStr.c_str()); - // SendMsgToUIService(UI_UPDATE_AI_ANSWER_STR, 0, nullptr, 0); - } + start_ai4g_tts_play_timer(); // 开启一个定时器,用于播放tts音频 start_update_ai_answer_timer(); } } -- 2.17.1