From: luozheng <1732036298@qq.com> Date: Thu, 22 May 2025 02:14:46 +0000 (+0800) Subject: AI 九天大模型代码合并,待测试 X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~289 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=4f3fc70e0e0fcfc614b8a8bd005df89713318d09;p=mirrors%2FFD230.git AI 九天大模型代码合并,待测试 --- diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/ui_resource_string.h b/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/ui_resource_string.h index 7127be443..58639fba8 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/ui_resource_string.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativelauncher/include/ui_resource_string.h @@ -1,15 +1,15 @@ -/* -* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved. -* Description: language -* Author: Graphic develop team -* Create: 2021-07-06 -*/ - -#ifndef UI_RESOURCE_STRING_H -#define UI_RESOURCE_STRING_H -#include -namespace OHOS { -enum UIResourceTextId : uint16_t { +/* +* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved. +* Description: language +* Author: Graphic develop team +* Create: 2021-07-06 +*/ + +#ifndef UI_RESOURCE_STRING_H +#define UI_RESOURCE_STRING_H +#include +namespace OHOS { +enum UIResourceTextId : uint16_t { STR_EXERCISE_OUTDOORWALKING = 0, STR_EXERCISE_OUTDOORRUNNING = 1, STR_EXERCISE_OUTDOORBIKING = 2, @@ -652,10 +652,11 @@ enum UIResourceTextId : uint16_t { STR_RECORD_MAX = 639, STR_CLEAR_ALL_RECORDS = 640, STR_DEEPSEEK = 641, - STR_MAX_ID = 642, + STR_AIMODES_LINGXI = 642, + STR_MAX_ID = 643, }; // UIResourceTextId - -enum FontLanguageId : uint8_t { + +enum FontLanguageId : uint8_t { LANGUAGE_ID_AR, LANGUAGE_ID_AZ, LANGUAGE_ID_CS, diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/include/AiVoicePresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/include/AiVoicePresenter.h index ede8f78ba..2b162eae9 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/include/AiVoicePresenter.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/include/AiVoicePresenter.h @@ -32,7 +32,7 @@ namespace OHOS AIMODES_KIMI, /*KIMI*/ AIMODES_DOUBAO, /*豆包*/ AIMODES_TONGYI_QIANWEN, /*通义千问->DeepSeek*/ - AIMODES_IFLYTEK_SPARK, /*讯飞星火*/ + AIMODES_IFLYTEK_SPARK, /*讯飞星火->lingxi*/ AIMODES_CHATGPT, /*chatgpt*/ AIMODES_MAX_NUM, } aimodels; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/include/AiVoiceView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/include/AiVoiceView.h index 99616406e..fc65f5595 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/include/AiVoiceView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/include/AiVoiceView.h @@ -39,6 +39,7 @@ namespace OHOS static constexpr const char *AIMODEL_TONGYI_QIANWEN_PATH = "/user/res/AIVoice/aimodels/aimodes_tongyi_qianwen.bin"; /*通义千问*/ static constexpr const char *AIMODEL_IFLYTEK_SPARK_PATH = "/user/res/AIVoice/aimodels/aimodes_iflytek_spark.bin"; /*讯飞星火*/ static constexpr const char *AIMODEL_DEEPSEEK_PATH = "/user/res/AIVoice/aimodels/aimodes_deepseek.bin"; /*deepseek*/ + static constexpr const char *AIMODEL_LINGXI_PATH = "/user/res/AIVoice/aimodels/aimodels_lingxi.bin"; /*lingxi*/ /*组件ID*/ static constexpr const char *AIVOICE_START_CHAT_BUTTON_VIEW_ID = "aivoice_start_chat_button_view_id"; // 开始对话 @@ -69,7 +70,8 @@ namespace OHOS {STR_AIMODELS_DOUBAO, AIMODEL_DOUBAO_PATH}, // {STR_TONGYI_QIANWEN, AIMODEL_TONGYI_QIANWEN_PATH}, {STR_DEEPSEEK, AIMODEL_DEEPSEEK_PATH}, - {STR_IFLYTEK_SPARK, AIMODEL_IFLYTEK_SPARK_PATH}, + // {STR_IFLYTEK_SPARK, AIMODEL_IFLYTEK_SPARK_PATH}, + {STR_AIMODES_LINGXI, AIMODEL_LINGXI_PATH}, {STR_AIMODES_CHATGPT, AIMODEL_CHATGPT_ON_PATH}, }; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceBluetoothFailedStartView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceBluetoothFailedStartView.cpp index 42f982951..37c2407ba 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceBluetoothFailedStartView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceBluetoothFailedStartView.cpp @@ -11,6 +11,7 @@ #include "wearable_log.h" #include "ui_resource_string.h" #include +#include "ConfigModel.h" namespace OHOS { @@ -92,8 +93,19 @@ namespace OHOS //TOOD: 待优化 if(labelconfig.textId == STR_DEEPSEEK) { label->SetText("DeepSeek"); - } else + }else if(labelconfig.textId == STR_AIMODES_LINGXI) { + int language = ConfigModel::GetInstance()->GetLanguage(); + if (language == 0) // 如果当前系统为中文 + { + label->SetText("九天大模型"); + } + else + { + label->SetText("jiutian"); + } + } else{ label->SetTextId(labelconfig.textId); + } label->SetLineBreakMode(labelconfig.lineBreakMode); label->SetRollSpeed(23); label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); @@ -278,15 +290,23 @@ namespace OHOS { if (title) { - if(textId == STR_DEEPSEEK) - { + if(textId == STR_DEEPSEEK) { title->SetText("DeepSeek"); - } - else - { - title->SetTextId(textId); - title->ForceResetText(); + }else if(textId == STR_AIMODES_LINGXI) { + int language = ConfigModel::GetInstance()->GetLanguage(); + if (language == 0) // 如果当前系统为中文 + { + title->SetText("九天大模型"); + } + else + { + title->SetText("jiutian"); + } + } else{ + title->SetTextId(textId); } + + title->ForceResetText(); } } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceModel.cpp index 2da9b74f5..8bcb8ae7c 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceModel.cpp @@ -179,7 +179,8 @@ namespace OHOS } // 获取当前正在使用的AI模型 - uint8_t AiVoiceModel::GetCurUsingAiModelType(void){ + uint8_t AiVoiceModel::GetCurUsingAiModelType(void) + { auto it = selectAiModelToTextId.find(GetSelectAiModel()); if (it != selectAiModelToTextId.end()) @@ -193,9 +194,7 @@ namespace OHOS void AiVoiceModel::CancelCurAIChat(void) { // cancel_AI_cur_chat(); //线程发送取消当前对话 - #ifdef SUPPORT_BLE_SERVICE cancel_AI_cur_chat_();// 直接发送取消当前对话 - #endif } int AiVoiceModel::GetAIResponseType(void) @@ -499,7 +498,7 @@ namespace OHOS if (!entryTextViewState) { #ifdef SUPPORT_BLE_SERVICE - //SendMsgToUIService(UI_AI_JUMP_TO_RESULT_VIEW, 0, nullptr, 0); + SendMsgToUIService(UI_AI_JUMP_TO_RESULT_VIEW, 0, nullptr, 0); #endif entryTextViewState = true; // 进入返回结果界面的标志 避免重复发消息 usleep(50000); // 延时等待创建完成,0.05秒 @@ -510,7 +509,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "拼接的问题:%s",userQuestionStr.c_str()); /* -------------------------------------------------------------------------- */ #ifdef SUPPORT_BLE_SERVICE - //SendMsgToUIService(UI_UPDATE_USER_QUESTION_STR, 0, nullptr, 0); + SendMsgToUIService(UI_UPDATE_USER_QUESTION_STR, 0, nullptr, 0); #endif } @@ -526,7 +525,9 @@ namespace OHOS void AiVoiceModel::SetAiAnswerStrStr(std::string str) { aiAnswerStr += str; - //SendMsgToUIService(UI_UPDATE_AI_ANSWER_STR, 0, nullptr, 0); + #ifdef SUPPORT_BLE_SERVICE + SendMsgToUIService(UI_UPDATE_AI_ANSWER_STR, 0, nullptr, 0); + #endif } void AiVoiceModel::SetAiAnswerStrStr(std::string str, uint8_t type) @@ -538,7 +539,9 @@ namespace OHOS if (AIResponseType == AiVoiceModel::AI_RECORDING_PARSING_ERROR || AIResponseType == AiVoiceModel::AI_RESPONSE_ERROR || AIResponseType == AiVoiceModel::AI_BLE_ERROR) { - //SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)errnote.c_str(), errnote.length()); + #ifdef SUPPORT_BLE_SERVICE + SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)errnote.c_str(), errnote.length()); + #endif return; } else if (AiVoiceModel::AI_RESPONSE_END) // 如果是AI 回应结束 @@ -548,7 +551,9 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::GetErrnote is empty!!"); AiVoiceModel::GetInstance().SetErrnote("响应内容为空"); std::string str = AiVoiceModel::GetInstance().GetErrnote(); - //SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)str.c_str(), str.length()); + #ifdef SUPPORT_BLE_SERVICE + SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)str.c_str(), str.length()); + #endif return; } } @@ -561,7 +566,9 @@ namespace OHOS { aiAnswerStr += str; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "接受字的符串:%s", aiAnswerStr.c_str()); - //SendMsgToUIService(UI_UPDATE_AI_ANSWER_STR, 0, nullptr, 0); + #ifdef SUPPORT_BLE_SERVICE + SendMsgToUIService(UI_UPDATE_AI_ANSWER_STR, 0, nullptr, 0); + #endif } } } @@ -609,8 +616,7 @@ namespace OHOS int type = GetCurUsingAiModelType(); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "type = %d", type); #ifdef SUPPORT_BLE_SERVICE - // streamingRecordAndSend_AI(type);//实时发送录音数据 - #endif + streamingRecordAndSend_AI(type);//实时发送录音数据 #else std::string audioPath = AiVoiceModel::GetInstance().GetAIAudioPath(); if (uapi_delete_files(audioPath.c_str())) // 先删除文件 @@ -630,6 +636,7 @@ namespace OHOS #endif uapi_save_runtime_log(RUNTIME_LOG_RECORD_START_AI);//TOOD* AudioCaptureSample(6, (const char **)defaultArgs); +#endif #endif } return; @@ -736,7 +743,9 @@ namespace OHOS AiVoiceModel::GetInstance().AIVoice_StopTimer(); AiVoiceModel::GetInstance().SetErrnote("连接超时,请重新开始对话"); std::string str = AiVoiceModel::GetInstance().GetErrnote(); - //SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)str.c_str(), str.length()); + #ifdef SUPPORT_BLE_SERVICE + SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)str.c_str(), str.length()); + #endif } else { @@ -747,7 +756,9 @@ namespace OHOS { AiVoiceModel::GetInstance().SetErrnote("手机蓝牙已断开"); std::string str = AiVoiceModel::GetInstance().GetErrnote(); - // SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)str.c_str(), str.length()); + #ifdef SUPPORT_BLE_SERVICE + SendMsgToUIService(UI_AI_JUMP_TO_RESPONDERR_VIEW, 0, (void *)str.c_str(), str.length()); + #endif } #endif } @@ -1107,7 +1118,8 @@ namespace OHOS {2, {STR_AIMODELS_DOUBAO, 3}}, // {3, {STR_TONGYI_QIANWEN, 4}}, {3, {STR_DEEPSEEK, 4}}, - {4, {STR_IFLYTEK_SPARK, 5}}, + // {4, {STR_IFLYTEK_SPARK, 5}}, + {4, {STR_AIMODES_LINGXI, 5}}, {5, {STR_AIMODES_CHATGPT, 1}}, }; textId = STR_AIMODES_WENXINYIYAN; @@ -1121,7 +1133,8 @@ namespace OHOS {3, {STR_AIMODELS_DOUBAO, 3}}, // {4, {STR_TONGYI_QIANWEN, 4}}, {4, {STR_DEEPSEEK, 4}}, - {5, {STR_IFLYTEK_SPARK, 5}}, + // {5, {STR_IFLYTEK_SPARK, 5}}, + {5, {STR_AIMODES_LINGXI, 5}}, }; textId = STR_AIMODES_CHATGPT; } @@ -1134,7 +1147,8 @@ namespace OHOS {2, {STR_AIMODELS_DOUBAO, 3}}, {3, {STR_AIMODES_WENXINYIYAN, 0}}, {4, {STR_AIMODES_KIMI, 2}}, - {5, {STR_IFLYTEK_SPARK, 5}}, + // {5, {STR_IFLYTEK_SPARK, 5}}, + {5, {STR_AIMODES_LINGXI, 5}}, }; textId = STR_DEEPSEEK; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceView.cpp index 92f05dbe6..e5922c9d1 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceView.cpp @@ -157,8 +157,19 @@ namespace OHOS //TOOD: 待优化 if(labelconfig.textId == STR_DEEPSEEK) { label->SetText("DeepSeek"); - } else + }else if(labelconfig.textId == STR_AIMODES_LINGXI) { + int language = ConfigModel::GetInstance()->GetLanguage(); + if (language == 0) // 如果当前系统为中文 + { + label->SetText("九天大模型"); + } + else + { + label->SetText("jiutian"); + } + } else{ label->SetTextId(labelconfig.textId); + } label->SetLineBreakMode(labelconfig.lineBreakMode); label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label->SetRollSpeed(23); @@ -409,9 +420,11 @@ namespace OHOS aiModelPicker->SetRotateFactor(1.0); aiModelPicker->RequestFocus(); aiModelPicker->RegisterSelectedListener(presenter_); - aiModelPicker->SetTextColor(Color::GetColorFromRGBA(0x00, 0x00, 0x00, 0xff), Color::GetColorFromRGBA(0xff, 0x00, 0x00, 0xff)); + // 设置文本颜色为透明 + aiModelPicker->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x00), Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x00)); const char *uiPicker1Data[] = {"0", "1", "2", "3", "4", "5"}; aiModelPicker->SetValues(uiPicker1Data, sizeof(uiPicker1Data) / sizeof(uiPicker1Data[0])); + // aiModelPicker->SetVisible(false);//屏蔽picker组件 } return true; @@ -902,15 +915,23 @@ namespace OHOS int textId = AiVoiceModel::GetInstance().GetAiModelTextId(); if (title) { - if(textId == STR_DEEPSEEK) - { + if(textId == STR_DEEPSEEK) { title->SetText("DeepSeek"); - } - else - { - title->SetTextId(textId); - title->ForceResetText(); + }else if(textId == STR_AIMODES_LINGXI) { + int language = ConfigModel::GetInstance()->GetLanguage(); + if (language == 0) // 如果当前系统为中文 + { + title->SetText("九天大模型"); + } + else + { + title->SetText("jiutian"); + } + } else{ + title->SetTextId(textId); } + + title->ForceResetText(); } if (aiModelImage) { diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AivoiceConnectTimeoutView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AivoiceConnectTimeoutView.cpp index babb77944..517752f38 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AivoiceConnectTimeoutView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AivoiceConnectTimeoutView.cpp @@ -11,6 +11,7 @@ #include "wearable_log.h" #include "ui_resource_string.h" #include +#include "ConfigModel.h" namespace OHOS { static constexpr const int16_t LABEL_ROLL_SPEED = 70; @@ -84,8 +85,19 @@ namespace OHOS //TOOD: 待优化 if(labelconfig.textId == STR_DEEPSEEK) { label->SetText("DeepSeek"); - } else + }else if(labelconfig.textId == STR_AIMODES_LINGXI) { + int language = ConfigModel::GetInstance()->GetLanguage(); + if (language == 0) // 如果当前系统为中文 + { + label->SetText("九天大模型"); + } + else + { + label->SetText("jiutian"); + } + } else{ label->SetTextId(labelconfig.textId); + } label->SetLineBreakMode(labelconfig.lineBreakMode); label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); @@ -269,15 +281,23 @@ namespace OHOS { if (title) { - if(textId == STR_DEEPSEEK) - { + if(textId == STR_DEEPSEEK) { title->SetText("DeepSeek"); - } - else - { - title->SetTextId(textId); - title->ForceResetText(); + }else if(textId == STR_AIMODES_LINGXI) { + int language = ConfigModel::GetInstance()->GetLanguage(); + if (language == 0) // 如果当前系统为中文 + { + title->SetText("九天大模型"); + } + else + { + title->SetText("jiutian"); + } + } else{ + title->SetTextId(textId); } + + title->ForceResetText(); } } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AivoiceMobileDataFailedStartView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AivoiceMobileDataFailedStartView.cpp index 554cab823..4f9646455 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AivoiceMobileDataFailedStartView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AivoiceMobileDataFailedStartView.cpp @@ -11,6 +11,7 @@ #include "wearable_log.h" #include "ui_resource_string.h" #include +#include "ConfigModel.h" namespace OHOS { @@ -89,11 +90,22 @@ namespace OHOS label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); - //TOOD: 待优化 - if(labelconfig.textId == STR_DEEPSEEK) { + //TOOD: 待优化 + if(labelconfig.textId == STR_DEEPSEEK) { label->SetText("DeepSeek"); - } else + }else if(labelconfig.textId == STR_AIMODES_LINGXI) { + int language = ConfigModel::GetInstance()->GetLanguage(); + if (language == 0) // 如果当前系统为中文 + { + label->SetText("九天大模型"); + } + else + { + label->SetText("jiutian"); + } + } else{ label->SetTextId(labelconfig.textId); + } label->SetLineBreakMode(labelconfig.lineBreakMode); label->SetRollSpeed(23); label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); @@ -279,15 +291,23 @@ namespace OHOS { if (title) { - if(textId == STR_DEEPSEEK) - { + if(textId == STR_DEEPSEEK) { title->SetText("DeepSeek"); - } - else - { - title->SetTextId(textId); - title->ForceResetText(); + }else if(textId == STR_AIMODES_LINGXI) { + int language = ConfigModel::GetInstance()->GetLanguage(); + if (language == 0) // 如果当前系统为中文 + { + title->SetText("九天大模型"); + } + else + { + title->SetText("jiutian"); + } + } else{ + title->SetTextId(textId); } + + title->ForceResetText(); } } } \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp index 0d5611b31..1e0b85d3a 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp @@ -13,7 +13,7 @@ #include #include #include "string" - +#include "ConfigModel.h" namespace OHOS { @@ -129,8 +129,19 @@ namespace OHOS //TOOD: 待优化 if(labelconfig.textId == STR_DEEPSEEK) { label->SetText("DeepSeek"); - } else + }else if(labelconfig.textId == STR_AIMODES_LINGXI) { + int language = ConfigModel::GetInstance()->GetLanguage(); + if (language == 0) // 如果当前系统为中文 + { + label->SetText("九天大模型"); + } + else + { + label->SetText("jiutian"); + } + } else{ label->SetTextId(labelconfig.textId); + } label->SetLineBreakMode(labelconfig.lineBreakMode); label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); @@ -353,15 +364,23 @@ namespace OHOS { if (title) { - if(textId == STR_DEEPSEEK) - { + if(textId == STR_DEEPSEEK) { title->SetText("DeepSeek"); - } - else - { - title->SetTextId(textId); - title->ForceResetText(); + }else if(textId == STR_AIMODES_LINGXI) { + int language = ConfigModel::GetInstance()->GetLanguage(); + if (language == 0) // 如果当前系统为中文 + { + title->SetText("九天大模型"); + } + else + { + title->SetText("jiutian"); + } + } else{ + title->SetTextId(textId); } + + title->ForceResetText(); } } diff --git a/code/sdk/files/fd230/fs/user/res/AIVoice/aimodels/aimodels_lingxi.bin b/code/sdk/files/fd230/fs/user/res/AIVoice/aimodels/aimodels_lingxi.bin new file mode 100644 index 000000000..a1cbcf37f Binary files /dev/null and b/code/sdk/files/fd230/fs/user/res/AIVoice/aimodels/aimodels_lingxi.bin differ diff --git a/code/sdk/files/fd230/fs/user/res/AIVoice/aimodels/aimodes_deepseek.bin b/code/sdk/files/fd230/fs/user/res/AIVoice/aimodels/aimodes_deepseek.bin new file mode 100644 index 000000000..0c32be31b Binary files /dev/null and b/code/sdk/files/fd230/fs/user/res/AIVoice/aimodels/aimodes_deepseek.bin differ diff --git a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_capture_wrapper.cpp b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_capture_wrapper.cpp index a7b90b214..791048adf 100644 --- a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_capture_wrapper.cpp +++ b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_capture_wrapper.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,7 +41,8 @@ using Audio::AudioInterrupt; using Audio::AudioManager; #define PLAYER_CONTROL_CMD_LEN 20 #define READ_RETRY_TIME_US 10000 -#define READ_COUNT_MAX 1000 +// #define READ_COUNT_MAX 1000 //原 +#define READ_COUNT_MAX 17000*2 //改过的 20分钟 #define GET_AUDIO_TIME_INTERVAL_TIMES 100 #define MAX_ARGC 5 @@ -99,7 +100,8 @@ static NameAudioFormat g_audioCodecFormat[] = { {"g711a", G711A}, {"aaceld", AAC_ELD}, {"silk", SILK}, - {"pcm", PCM} + {"pcm", PCM}, + {"sbc",SBC} }; class CaptureInterruptListener : public InterruptListener { @@ -189,7 +191,7 @@ static void* AudioCaptureProcess(void* arg) fclose(pfd); AudioCaptureStop(); MEDIA_INFO_LOG("AudioCaptureProcess end"); - return nullptr; + return NULL; } static void AudioCaptureGetFormat(const char **argv, AudioCodecFormat &audioFormat) @@ -291,6 +293,7 @@ static int32_t AudioCaptureSetInfo(SampleAudioCapturerInfo audioCapturerInfo) { AudioCapturerInfo info = {}; ConvertCaptureInfo(info, audioCapturerInfo); + printf("info.audioFormat = %d\n",info.audioFormat); if (g_audioCap->SetCapturerInfo(info) != 0) { MEDIA_ERR_LOG("Can't SetCapturerInfo"); return -1; @@ -341,7 +344,6 @@ static int32_t ActivateAudioInterrupt(AudioSession &sessionId) static int32_t CheckInputParam(int32_t argc, const char **argv) { - MEDIA_UNUSED(argv); if (argc != 0x6) { // must be 6 parameters MEDIA_ERR_LOG("argc:%d is invalid, record start must be 6 parameters", argc); return -1; @@ -414,6 +416,145 @@ EXIT: return -1; } +/* ------------------------------- AI录音数据上传接口 ------------------------------- */ +#define AI_RECORD_TEST 0 //若需要调试可以打开该宏 +#include "bleService.h" +static uint32_t AI_audio_size=0; +static uint8_t Cur_AI_Model= 0; +static void* AudioCaptureProcess_AI(void* arg) +{ + #if AI_RECORD_TEST + FILE *pfd = (FILE *)arg; + #endif + int32_t readCnt = 0; + Timestamp timeStamp; + g_audioSourceProcessInput.bThreadRun = true; + uint8_t start_data[19]={0}; + + AI_data_assembly(1,start_data, Cur_AI_Model); + send_msg_data_into_Ai_msg_queue((void *)start_data,19,1); + AI_audio_size=0; + + while (!g_sample.needStop && !g_interruptHintStop) { + int32_t ret = g_audioCap->Read(g_audioSourceProcessInput.buffer, g_audioSourceProcessInput.framesize, false); + if (ret == -1) { + MEDIA_ERR_LOG("audioCap Read failed:0x%x", ret); + continue; + } + if (ret == ERR_RETRY_READ) { + usleep(READ_RETRY_TIME_US); + continue; + } + #if AI_RECORD_TEST + int32_t writeLen = fwrite(g_audioSourceProcessInput.buffer, 1, ret, pfd); + if (writeLen != ret) { + MEDIA_ERR_LOG("errno:%d, errmsg:%s", errno, strerror(errno)); + break; + } + #endif + AI_audio_size+=ret; + + + // 蓝牙接口发送实时录音数据 + send_msg_data_into_Ai_msg_queue((void *)g_audioSourceProcessInput.buffer,(uint16_t)ret,0); + + if (readCnt++ > READ_COUNT_MAX) { + break; + } + #if AI_RECORD_TEST + if (readCnt % GET_AUDIO_TIME_INTERVAL_TIMES == 0) { + if (g_audioCap->GetAudioTime(timeStamp, Timestamp::Timebase::MONOTONIC)) { + MEDIA_INFO_LOG("read %d frames timestamp seconds:%ld, nanoseconds:%ld", + readCnt, timeStamp.time.tv_sec, timeStamp.time.tv_nsec); + } + } + MEDIA_INFO_LOG("audioCap Read readCnt = %d, size = %d", readCnt, ret); + #endif + } + #if AI_RECORD_TEST + fclose(pfd); + #endif + MEDIA_ERR_LOG("AI_audio_size %d",AI_audio_size); + + AI_data_assembly(0,start_data,Cur_AI_Model); + send_msg_data_into_Ai_msg_queue((void *)start_data,19,2); + + + AudioCaptureStop(); + MEDIA_INFO_LOG("AudioCaptureProcess end"); + return NULL; +} + +int32_t streamingRecordAndSend_AI(int type) +{ + const char *argv[] = {"01", "sbc", "16000", "1", "16", "/user/aiRecord.sbc"}; + int32_t argc = 6; + Cur_AI_Model = type; + if (g_audioSourceProcessInput.bThreadRun) { + return HandleAudioCaptureCmd(argc, argv); + } + std::string filePath = ""; + g_sample.needStop = false; + g_interruptHintStop = false; + g_sample.mutex = MediaMutexCreate(nullptr); + if (g_sample.mutex == nullptr) { + MEDIA_ERR_LOG("create mutex failed"); + g_audioSourceProcessInput.bThreadRun = false; + return -1; + } + SampleAudioCapturerInfo audioCapturerInfo = {}; + AudioSession sessionId = AUDIO_SESSION_ID_NONE; + FILE *pfd = nullptr; + MediaThreadattr attr = { "AudioCaptureTask", 0x2000, THREAD_SCHED_INVALID, 0, true }; + int32_t ret = CheckInputParam(argc, argv); + if (ret != 0) { + goto EXIT; + } + ret = AudioCaptureGetInfo(argv, audioCapturerInfo, filePath); + if (ret != 0) { + goto EXIT; + } + ret = ActivateAudioInterrupt(sessionId); + if (ret != 0) { + goto EXIT; + } + g_audioCap = std::make_shared(); + if (g_audioCap == nullptr || g_audioCap.get() == nullptr) { + MEDIA_ERR_LOG("audio capture is nullptr"); + (void)g_amInstance.DeactivateAudioInterrupt(g_sample.interrupt); + goto EXIT; + } + #if AI_RECORD_TEST + pfd = fopen(filePath.c_str(), "w+"); + if (pfd == NULL) { + MEDIA_ERR_LOG("open file failed"); + g_audioCap.reset(); + (void)g_amInstance.DeactivateAudioInterrupt(g_sample.interrupt); + goto EXIT; + } + #endif + audioCapturerInfo.sessionID = sessionId; + audioCapturerInfo.inputSource = AUDIO_MIC; + audioCapturerInfo.streamType = AUDIO_STREAM_VOICE_RECORD; + ret = AudioCaptureSetInfo(audioCapturerInfo); + if (ret != 0) { + #if AI_RECORD_TEST + fclose(pfd); + #endif + g_audioCap.reset(); + (void)g_amInstance.DeactivateAudioInterrupt(g_sample.interrupt); + goto EXIT; + } + g_sample.audioCaptureProcess = MediaThreadCreate(AudioCaptureProcess_AI, pfd, &attr); + if (g_sample.audioCaptureProcess == nullptr) { + MEDIA_ERR_LOG("thread create failed"); + goto EXIT; + } + return 0; +EXIT: + g_audioSourceProcessInput.bThreadRun = false; + return -1; +} #ifdef __cplusplus }; #endif diff --git a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_capture_wrapper.h b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_capture_wrapper.h index 11337f116..fbc42bd57 100644 --- a/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_capture_wrapper.h +++ b/code/sdk/middleware/services/media/foundation/sample/wrapper/audio_capture_wrapper.h @@ -16,6 +16,8 @@ extern "C" { int32_t AudioCaptureSample(int32_t argc, const char *argv[]); +int32_t streamingRecordAndSend_AI(int type); + #ifdef __cplusplus }; #endif