解决:询问问题稍微停顿一下,就会自动识别问题
authorluozheng <1732036298@qq.com>
Wed, 23 Jul 2025 10:23:26 +0000 (18:23 +0800)
committerluozheng <1732036298@qq.com>
Wed, 23 Jul 2025 10:23:26 +0000 (18:23 +0800)
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
code/sdk/drivers/peripheral/slip/cat1Service/cat1_ai_server.cpp
code/sdk/middleware/services/media/foundation/sample/wrapper/voice_call_volte_sample_wrapper.cpp

index 6f1a8d0..ffa79fd 100644 (file)
@@ -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();
index a2a91ee..a20a80d 100644 (file)
@@ -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()
     {
index fdaeaec..8f950bc 100644 (file)
@@ -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连接方式
index ff6c82c..c257d3f 100644 (file)
@@ -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))
     {
index 6200136..702b2a2 100755 (executable)
@@ -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;
             }