From 05398b820aa37a50123d9f424c12c2c8bf66af28 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 20 Jun 2025 10:38:28 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A04GAI=E5=92=8C=E8=93=9D?= =?utf8?q?=E7=89=99AI=E5=88=87=E6=8D=A2=E9=80=BB=E8=BE=91=EF=BC=8C?= =?utf8?q?=E7=9B=AE=E5=89=8D=E6=B5=8B=E8=AF=954GAI=E5=87=BA=E7=8E=B0?= =?utf8?q?=E4=B8=80=E5=8F=A5=E8=AF=9D=E8=AF=86=E5=88=AB=E4=B8=8D=E5=85=A8?= =?utf8?q?=EF=BC=8C=E8=BF=98=E6=9C=89=E8=AF=86=E5=88=AB=E4=B8=8D=E4=BA=86?= =?utf8?q?=EF=BC=8C=E6=98=93=E6=AD=BB=E6=9C=BA=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aivoice/src/AiVoiceModel.cpp | 4 ++-- .../nativeui/aivoice/src/AiVoicePresenter.cpp | 17 ++++++++++++----- .../peripheral/slip/cat1Service/cat1_ws.cpp | 1 + .../peripheral/slip/cat1Service/cat1_ws.h | 1 + 4 files changed, 16 insertions(+), 7 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 9ffb8cbc3..a2ca19cda 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -1216,7 +1216,7 @@ namespace OHOS // 检查定时器是否存在 if (g_ai4g_is_suc_connected_Handle != nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::stop_ai_isready_timer"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::stop_ai4g_connect_timer"); osTimerStop(g_ai4g_is_suc_connected_Handle); // 删除定时器并置为 nullptr osStatus_t ret = osTimerDelete(g_ai4g_is_suc_connected_Handle); @@ -1298,7 +1298,7 @@ namespace OHOS // 检查定时器是否存在 if (g_ai4g_is_start_tts_play_Handle != nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::stop_ai_isready_timer"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::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); 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 33f1135c4..23835cdac 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -131,6 +131,7 @@ namespace OHOS model->stop_ai4g_connect_timer(); model->stop_ai4g_tts_play_timer(); remove_4GAI_vote(); // 移除4g投票 + dinit_ai_task(); uapi_ble_connect_param_update(BLE_CONNECT_INTERVAL_SLOW); } @@ -298,10 +299,10 @@ namespace OHOS switch (hideView) { case AIVOICE_STARTCHAT_VIEWID: - if (model->GetAI_4G_state() == true || model->GetAI_BT_state() == true) - { - model->QuerySelectedAiModelIsConnect(); /*查询用户选择的AI模型是否已经连接*/ - } + // if (model->GetAI_4G_state() == true || model->GetAI_BT_state() == true) + // { + // model->QuerySelectedAiModelIsConnect(); /*查询用户选择的AI模型是否已经连接*/ + // } if (showView == AIVOICE_LISTENING_VIEWID) { model->StartListenAndRecordingUserQuestion(); @@ -340,6 +341,10 @@ namespace OHOS { model->StartListenAndRecordingUserQuestion(); } + else if (showView == AIVOICE_AIMODE_CONNECTING) + { + model->start_ai_isready_timer(); /*开启一个查询AI模型是否连接成功定时器*/ + } break; default: @@ -403,7 +408,6 @@ namespace OHOS if (model->GetSelect4gorbt() == AI_SELECT_4G) { uapi_start_asr(); - usleep(50000); ChangeViewAndLogicOperator(AIVOICE_RETURN_RESULT_TEXT_VIEWID, AIVOICE_AIMODE_CONNECTING); return true; } @@ -473,6 +477,7 @@ namespace OHOS } else { + model->QuerySelectedAiModelIsConnect(); ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_AIMODE_CONNECTING); // LOADING } } @@ -480,6 +485,7 @@ namespace OHOS { // 通过蓝牙连接APP调用大模型 model->SetSelect4gorbt(AI_SELECT_BT); + model->QuerySelectedAiModelIsConnect(); ChangeViewAndLogicOperator(AIVOICE_STARTCHAT_VIEWID, AIVOICE_AIMODE_CONNECTING); // LOADING } else // 4.两者连接都异常 @@ -515,6 +521,7 @@ namespace OHOS else if (viewId == AIVOICE_SELECT_VIEW_BUTTONBT_VIEW_ID) // 如果点击的是蓝牙连接方式 { model->SetSelect4gorbt(AI_SELECT_BT); + dinit_ai_task(); model->QuerySelectedAiModelIsConnect(); /*查询用户选择的AI模型是否已经连接*/ ChangeViewAndLogicOperator(model->GetCurView(), AIVOICE_AIMODE_CONNECTING); } diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp index f3dc0373f..5afbc9afa 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp @@ -1135,6 +1135,7 @@ void uapi_start_asr(void) { // bool state = true; // SendMsgToUIService(UI_AI_JUMP_TO_LISTENING_VIEW, 0, &state, sizeof(bool)); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"查询uapi_start_asr是否可用\n"); char *jsonString = "{\"header\":{\"event\":\"StartTranscription\",\"trace_id\": \ \"3fa6b9e6a30b407ea38ad7ae69e6c291\"},\"payload\":{\"format\":\"MP3\",\"sample_rate\":16000}}"; diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.h b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.h index 9ae2c7f60..c08dcce7c 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.h +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.h @@ -11,6 +11,7 @@ void uapi_start_asr(void); void uapi_stop_asr(void); bool init_ai_task(void); +bool dinit_ai_task(void); void uapi_start_tts_single_txt(char *buf); -- 2.17.1