优化tts播放 1949/1
authorluozheng <1732036298@qq.com>
Thu, 10 Jul 2025 02:15:23 +0000 (10:15 +0800)
committerluozheng <1732036298@qq.com>
Thu, 10 Jul 2025 02:15:23 +0000 (10:15 +0800)
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp

index 11585bc..286d861 100644 (file)
@@ -755,7 +755,7 @@ namespace OHOS
     {
         const std::string punctuation = ",。!?;:))”、"; // 要替换的中文标点
         const char replacement = ',';                         // 替换为英文逗号
-        const size_t MAX_SEGMENT_LENGTH = 120;                // 最大分段长度
+        const size_t MAX_SEGMENT_LENGTH = 90;                // 最大分段长度
         const size_t MIN_SEGMENT_LENGTH = 1;                  // 最小发送长度(可调整)
 
         if (accumulatedText.empty())
@@ -1568,7 +1568,8 @@ namespace OHOS
         }
         if (get_bk_websocket_tts_tick() == 0) // 代表可以发录音文本
         {
-            AiVoiceModel::GetInstance().ProcessTextByPunctuation();
+            if (AiVoiceModel::GetInstance().GetInit_4gai_task())
+                AiVoiceModel::GetInstance().ProcessTextByPunctuation();
         }
         else
         {
@@ -1630,7 +1631,7 @@ namespace OHOS
         // 检查定时器是否存在
         if (g_ai4g_is_start_tts_play_Handle != nullptr)
         {
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "stop_ai4g_tts_play_timer");
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stop_ai4g_tts_play_timer");
             osTimerStop(g_ai4g_is_start_tts_play_Handle);
             // 删除定时器并置为 nullptr
             osStatus_t ret = osTimerDelete(g_ai4g_is_start_tts_play_Handle);
index 27c3b0c..852d99f 100644 (file)
@@ -405,8 +405,8 @@ namespace OHOS
                 if (model->GetSelect4gorbt() == AI_SELECT_4G)
                 {
                     AiVoiceModel::GetInstance().stop_ai4g_tts_play_timer();
-                    uapi_UI_start_asr();
                     usleep(50000);
+                    uapi_UI_start_asr();
                     ChangeViewAndLogicOperator(AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_AIMODE_CONNECTING);
                     return true;
                 }