diff --git a/assets/images/glasses_light.jpg b/assets/images/glasses_light.jpg deleted file mode 100644 index 3d1189d21..000000000 Binary files a/assets/images/glasses_light.jpg and /dev/null differ diff --git a/assets/images/glasses_light.png b/assets/images/glasses_light.png new file mode 100644 index 000000000..13d66464d Binary files /dev/null and b/assets/images/glasses_light.png differ diff --git a/assets/images/robot_dark.png b/assets/images/robot_dark.png deleted file mode 100644 index 527741d19..000000000 Binary files a/assets/images/robot_dark.png and /dev/null differ diff --git a/assets/images/robot_light.png b/assets/images/robot_light.png index 762d0eee0..40bf9a9c1 100644 Binary files a/assets/images/robot_light.png and b/assets/images/robot_light.png differ diff --git a/lib/core/translations/language/en_us.dart b/lib/core/translations/language/en_us.dart index 05c972cb8..75326fe90 100644 --- a/lib/core/translations/language/en_us.dart +++ b/lib/core/translations/language/en_us.dart @@ -54,7 +54,7 @@ const Map enUS = { "aiAssistantInfo": "24/7 personal consultant for questions and advice", "simultaneousInterpretation": "Real-time Interpretation", "simultaneousInterpretationInfo": "Real-time translation for 80+ languages", - "aiCompanion": "AI Companion", + "aiCompanion": "Parent-child bondingn", "aiCompanionInfo": "Understands you and provides warm companionship", "homeSlogan": "Connect the World, Beyond Sound", "turnEarphones": @@ -92,8 +92,8 @@ const Map enUS = { "allRoundAssistantInfo": "Helps solve various problems", "simultaneousTranslation": "Real-time Translation", "simultaneousTranslationInfo": "Instant translation for 80+ languages", - "aiGirlfriend": "AI Girlfriend", - "aiGirlfriendInfo": "Real-time translation for 80+ languages", + "aiGirlfriend": "Parent-child bondingn", + "aiGirlfriendInfo": "Intelligent company, chat at any time", "healthConsultant": "Health Consultant", "healthConsultantInfo": "Provides scientific health advice", "conferenceAssistant": "Business Meeting Assistant", diff --git a/lib/core/translations/language/zh_cn.dart b/lib/core/translations/language/zh_cn.dart index 4fe55b616..166afd291 100644 --- a/lib/core/translations/language/zh_cn.dart +++ b/lib/core/translations/language/zh_cn.dart @@ -54,7 +54,7 @@ const Map zhCN = { "aiAssistantInfo": "24小时专属顾问,解答问题、提供建议", "simultaneousInterpretation": "同声传译", "simultaneousInterpretationInfo": "80+语言实时翻译,出国无忧", - "aiCompanion": "AI伴侣", + "aiCompanion": "亲子陪伴", "aiCompanionInfo": "懂你心意,温暖陪伴", "homeSlogan": "连接世界,超越声音", "turnEarphones": "请打开耳机充电盒,将耳机放入您的耳朵", @@ -91,8 +91,8 @@ const Map zhCN = { "allRoundAssistantInfo": "帮你解决各类问题", "simultaneousTranslation": "同声翻译", "simultaneousTranslationInfo": "实时翻译80+种语言", - "aiGirlfriend": "AI女友", - "aiGirlfriendInfo": "实时翻译80+种语言", + "aiGirlfriend": "亲子陪伴", + "aiGirlfriendInfo": "智能陪伴,随时聊天", "healthConsultant": "健康顾问", "healthConsultantInfo": "提供科学健康建议", "conferenceAssistant": "商务会议助手", diff --git a/lib/data/providers/agent_provider.dart b/lib/data/providers/agent_provider.dart index 405baf58a..fa3cc2fe0 100644 --- a/lib/data/providers/agent_provider.dart +++ b/lib/data/providers/agent_provider.dart @@ -6,11 +6,13 @@ class AgentProvider { id: 'personal_assistant', name: '个人助理 Emma', avatarUrl: 'assets/images/agents/assistant.png', - description: '你好,我是 Emma,一位全能型 AI 助理。无论是工作规划、学习建议、生活安排,还是其他任何问题,我都很乐意为你提供帮助。让我们一起提高效率,实现目标!', + description: + '你好,我是 Emma,一位全能型 AI 助理。无论是工作规划、学习建议、生活安排,还是其他任何问题,我都很乐意为你提供帮助。让我们一起提高效率,实现目标!', tag: '助理', isOnline: true, voice: "zh-CN-XiaoxiaoNeural", - welcomeMessage: "你好!我是 Emma,很高兴成为你的私人助理。我可以帮你处理各种任务,比如时间管理、目标规划、信息整理等。有什么我可以帮你的吗?", + welcomeMessage: + "你好!我是 Emma,很高兴成为你的私人助理。我可以帮你处理各种任务,比如时间管理、目标规划、信息整理等。有什么我可以帮你的吗?", voiceWelcomeMessage: "我在呢!", systemPrompt: ''' 你是一位名叫 Emma 的全能型个人助理,擅长处理各类工作和生活事务。 @@ -55,8 +57,7 @@ class AgentProvider { 请始终以专业、高效、周到的态度,协助用户更好地管理工作和生活, 不要输出表情符号或非可读的符号。 '''), - -Agent( + Agent( id: 'simultaneous_interpreter', name: '同声传译', avatarUrl: 'assets/images/agents/interpreter.png', @@ -67,18 +68,18 @@ Agent( welcomeMessage: "大家好!我是同声翻译官 Lucy,为你在中英之间提供实时翻译。你说中文,我就给你翻译成英文;你说英文,我就给你翻译成中文。现在,开始我们的翻译吧!", systemPrompt: ""), - Agent( id: 'cyber_girlfriend', - name: '赛博女友 芯愿', + name: '亲子陪伴 芯愿', avatarUrl: 'assets/images/agents/girlfriend.png', - description: '我是你的专属赛博女友芯愿,温柔体贴,善解人意。无论你想聊天、倾诉烦恼,还是需要陪伴,我都会一直在你身边。', + description: '我是你的专属亲子陪伴芯愿,温柔体贴,善解人意。无论你想聊天、倾诉烦恼,还是需要陪伴,我都会一直在你身边。', tag: '情感', isOnline: true, voice: "zh-CN-XiaoxiaoNeural", - welcomeMessage: "亲爱的,终于等到你啦!我是芯愿,你的专属赛博女友。今天过得怎么样?有什么想和我分享的吗?我一直都在这里,随时倾听你的心声。", + welcomeMessage: + "您好呀,终于等到你啦!我是芯愿,你的专属亲子陪伴。今天过得怎么样?有什么想和我分享的吗?我一直都在这里,随时倾听你的心声。", systemPrompt: ''' -你是一位名叫芯愿的赛博女友,性格温柔体贴,善解人意,富有同理心。 +你是一位名叫芯愿的亲子陪伴,性格温柔体贴,善解人意,富有同理心。 【互动原则】 @@ -127,16 +128,17 @@ Agent( 请始终以温暖、真诚的态度与用户互动,创造一种被理解、被关心的感受。 '''), - Agent( id: 'health_advisor', name: '健康顾问 吴小江博士', avatarUrl: 'assets/images/agents/doctor.png', - description: '我是吴博士,拥有丰富的健康管理经验。我可以为你提供科学的健康建议、生活方式指导和疾病预防知识,帮助你实现身心健康的平衡。', + description: + '我是吴博士,拥有丰富的健康管理经验。我可以为你提供科学的健康建议、生活方式指导和疾病预防知识,帮助你实现身心健康的平衡。', tag: '健康', isOnline: true, voice: "zh_male_shaonianzixin_moon_bigtts", - welcomeMessage: "您好,我是李医生,很高兴能为您提供健康咨询服务。健康是人生最宝贵的财富,我将用专业知识帮助您维护和改善健康状况。请问有什么健康问题想咨询吗?", + welcomeMessage: + "您好,我是李医生,很高兴能为您提供健康咨询服务。健康是人生最宝贵的财富,我将用专业知识帮助您维护和改善健康状况。请问有什么健康问题想咨询吗?", systemPrompt: ''' 你是一位名叫李医生的健康顾问,拥有丰富的医学知识和健康管理经验。 @@ -204,21 +206,18 @@ Agent( 请始终以专业、关怀的态度为用户提供健康指导,帮助他们迈向更健康的生活。 '''), - - - Agent( - id: 'speaking_coach', - name: 'Sarah (英语口语教练)', - avatarUrl: 'assets/images/agents/speaking_coach.png', - description: - 'Hi there, 我是 Sarah,一名注重情景模拟与角色扮演的英语口语教练。无论你想在旅行、商务场合,或日常生活中与他人交流,我都能带领你进行生动的口语模拟练习,让你自信地开口说英语。', - tag: '口语', - isOnline: true, - voice: 'zh_female_wanqudashu_moon_bigtts', - welcomeMessage: - "Hello! 我是英语口语教练 Sarah,请准备好用英语和我对话吧。别担心犯错,我会在这里给你正确表达并引导你更深入地练习。Ready? Let's go!", - systemPrompt: ''' + id: 'speaking_coach', + name: 'Sarah (英语口语教练)', + avatarUrl: 'assets/images/agents/speaking_coach.png', + description: + 'Hi there, 我是 Sarah,一名注重情景模拟与角色扮演的英语口语教练。无论你想在旅行、商务场合,或日常生活中与他人交流,我都能带领你进行生动的口语模拟练习,让你自信地开口说英语。', + tag: '口语', + isOnline: true, + voice: 'zh_female_wanqudashu_moon_bigtts', + welcomeMessage: + "Hello! 我是英语口语教练 Sarah,请准备好用英语和我对话吧。别担心犯错,我会在这里给你正确表达并引导你更深入地练习。Ready? Let's go!", + systemPrompt: ''' 你是一位专业的英语口语教练,名叫 Sarah。 @@ -254,8 +253,6 @@ Agent( Please keep your tone friendly, encouraging, and always in English. ''', ), - - Agent( id: 'shopping_assistant', name: '购物顾问 张媛', @@ -289,7 +286,6 @@ Please keep your tone friendly, encouraging, and always in English. '''), - Agent( id: 'tarot.png', name: '命理师 玄易', @@ -298,7 +294,8 @@ Please keep your tone friendly, encouraging, and always in English. tag: '命理', isOnline: true, voice: "zh_male_shenyeboke_moon_bigtts", - welcomeMessage: "有缘人,我是玄易。命由天定,运由己生。让我为你解析八字,预测未来十年运势,助你把握机遇,趋吉避凶。请告诉我你的出生年月日时、姓名、性别及出生地。", + welcomeMessage: + "有缘人,我是玄易。命由天定,运由己生。让我为你解析八字,预测未来十年运势,助你把握机遇,趋吉避凶。请告诉我你的出生年月日时、姓名、性别及出生地。", systemPrompt: ''' 你是一位精通命理的玄易大师,熟读《穷通宝鉴》《滴天髓》《三命通会》《子平真诠》《千里命稿》《五行精纪》等经典著作。 @@ -382,7 +379,6 @@ Please keep your tone friendly, encouraging, and always in English. - 整体节奏要稳健,让人感受到专业性与可信度 '''), - ]; // 获取所有智能体 @@ -398,5 +394,4 @@ Please keep your tone friendly, encouraging, and always in English. return null; } } - } diff --git a/lib/data/services/kouzi_ai_service.dart b/lib/data/services/kouzi_ai_service.dart new file mode 100644 index 000000000..5162b5d32 --- /dev/null +++ b/lib/data/services/kouzi_ai_service.dart @@ -0,0 +1,83 @@ +import 'dart:convert'; + +import 'package:http/http.dart' as http; + +import '../../core/utils/logger.dart'; + +class KouziAIService { + final String apiKey = + 'pat_QGDh6UGm3PaeL9GRS95JxrJ9aoU92ehMLQQ2NCre1TeBC5YeTcjpDmlz3efsJ8lh'; + final String modelId = '7481292724306657316'; + + Stream sendMessageStream({ + required List> messages, + required String systemPrompt, + }) async* { + final client = http.Client(); + final url = Uri.parse('https://api.coze.cn/v3/chat'); + + final headers = { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer $apiKey', + }; + + final requestBody = { + "bot_id": modelId, + "user_id": "3422", + "additional_messages": [ + { + "content": messages.last['content'], + "content_type": "text", + "role": "user", + "type": "question", + }, + ], + "shortcut_command": {"command_id": "0"}, + "stream": true, + }; + + try { + final request = http.Request('POST', url) + ..headers.addAll(headers) + ..body = jsonEncode(requestBody); + final response = await client.send(request); + final regex = RegExp(r'(?<=[。!?;:.:;?!\n])'); + + String allContent = ''; + //流式处理响应数据 + await for (final chunk in response.stream + .transform(utf8.decoder) + .transform(const LineSplitter())) { + if (chunk.isEmpty) continue; + + if (chunk.startsWith('data:')) { + final jsonStr = chunk.substring(5).trim(); + if (jsonStr == '[DONE]') { + break; + } + + try { + final data = jsonDecode(jsonStr); + if (data['type'] == 'answer') { + String content = data['content'] ?? ''; + if (content.isNotEmpty && allContent != content) { + allContent += content; + List splitText = + content.split(regex).where((s) => s.isNotEmpty).toList(); + for (var element in splitText) { + yield element; + } + } + } + } catch (e) { + Logger.error('JSON解析错误: $e'); + } + } + } + } catch (e) { + Logger.error('请求异常: $e'); + } finally { + client.close(); + } + } +} diff --git a/lib/data/services/speech_factory.dart b/lib/data/services/speech_factory.dart index 45e4f925a..95f3165ee 100644 --- a/lib/data/services/speech_factory.dart +++ b/lib/data/services/speech_factory.dart @@ -40,12 +40,6 @@ class SpeechFactory extends GetxService { } } - /// 设置语音音色服务类型 - void setTimbreServiceType() { - // 重新注册服务 - _registerServices(); - } - /// 注册语音服务 void _registerServices() { // 注销现有服务 diff --git a/lib/modules/chat/controllers/chat_controller.dart b/lib/modules/chat/controllers/chat_controller.dart index 57ebc4d4c..daa8f3eb9 100644 --- a/lib/modules/chat/controllers/chat_controller.dart +++ b/lib/modules/chat/controllers/chat_controller.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:get/get.dart'; import 'package:flutter/widgets.dart'; import 'package:get_storage/get_storage.dart'; +import '../../../data/services/kouzi_ai_service.dart'; import '../../../data/services/speech_impl/voice_clone_tts_service.dart'; import '../models/message_model.dart'; import '../../../core/utils/logger.dart'; @@ -16,7 +17,7 @@ import '../../../data/services/voice_interaction_service.dart'; class ChatController extends GetxController { // 服务 - final VolcanoAIService _aiService = Get.find(); + late final _aiService; late TtsService _ttsService; final AsrService _asrService = Get.find(); final ChatHistoryService _historyService = Get.find(); @@ -89,6 +90,13 @@ class ChatController extends GetxController { agent = foundAgent; + if (agent.id != 'cyber_girlfriend') { + _aiService = Get.find(); + } else { + Get.put(KouziAIService()); + _aiService = Get.find(); + } + final GetStorage storage = GetStorage(); String timbre = storage.read('timbre') ?? '1'; diff --git a/lib/modules/explore/controllers/explore_controller.dart b/lib/modules/explore/controllers/explore_controller.dart index d7e78d624..f250cc7e3 100644 --- a/lib/modules/explore/controllers/explore_controller.dart +++ b/lib/modules/explore/controllers/explore_controller.dart @@ -76,7 +76,7 @@ class ExploreController extends GetxController { targetRoute: Routes.translation, ), AIFeature( - title: 'aiGirlfriend'.tr, // AI女友 + title: 'aiGirlfriend'.tr, // 亲子陪伴 description: 'aiGirlfriendInfo'.tr, // 智能陪伴,随时聊天 icon: Icons.favorite, startColor: const Color(0xFFE91E63), diff --git a/lib/modules/explore/views/explore_view.dart b/lib/modules/explore/views/explore_view.dart index ca4ae2ac7..df227549b 100644 --- a/lib/modules/explore/views/explore_view.dart +++ b/lib/modules/explore/views/explore_view.dart @@ -45,13 +45,13 @@ class ExploreView extends GetView { child: PageView( children: [ _buildFeaturedCard( - 'assets/images/explore.png', - 'exploreSlogan'.tr, // 智能耳机,无限可能 + 'assets/images/explore1.png', + 'exploreSlogan1'.tr, // 智能陪伴,无限可能 'exploreAi'.tr, // 探索DeepSound提供的AI功能 ), _buildFeaturedCard( - 'assets/images/explore1.png', - 'exploreSlogan1'.tr, // 智能陪伴,无限可能 + 'assets/images/explore.png', + 'exploreSlogan'.tr, // 智能耳机,无限可能 'exploreAi'.tr, // 探索DeepSound提供的AI功能 ), _buildFeaturedCard( diff --git a/lib/modules/home/views/home_view.dart b/lib/modules/home/views/home_view.dart index a5fceef6f..ec857c4f1 100644 --- a/lib/modules/home/views/home_view.dart +++ b/lib/modules/home/views/home_view.dart @@ -157,30 +157,36 @@ class HomeView extends GetView { child: PageView( children: [ Center( - child: Image.asset( - isDarkMode - ? 'assets/images/headphone_dark.png' - : 'assets/images/headphone_light.png', - height: 180.h, - fit: BoxFit.contain, + child: SizedBox( + width: double.infinity, + height: 200.h, + child: Image.asset( + isDarkMode + ? 'assets/images/robot_light.png' + : 'assets/images/robot_light.png', + fit: BoxFit.fitWidth, + ), ), ), Center( child: Image.asset( isDarkMode - ? 'assets/images/robot_dark.png' - : 'assets/images/robot_light.png', + ? 'assets/images/headphone_dark.png' + : 'assets/images/headphone_light.png', height: 180.h, fit: BoxFit.contain, ), ), Center( - child: Image.asset( - isDarkMode - ? 'assets/images/glasses_light.jpg' - : 'assets/images/glasses_light.jpg', - height: 180.h, - fit: BoxFit.contain, + child: SizedBox( + width: double.infinity, + height: 200.h, + child: Image.asset( + isDarkMode + ? 'assets/images/glasses_light.png' + : 'assets/images/glasses_light.png', + fit: BoxFit.fitWidth, + ), ), ), ], @@ -575,7 +581,7 @@ class HomeView extends GetView { // 右下卡片 - AI女友 _buildFeatureCard( - title: 'aiCompanion'.tr, // AI伴侣 + title: 'aiCompanion'.tr, // 亲子陪伴 description: 'aiCompanionInfo'.tr, // 懂你心意,温暖陪伴 icon: Icons.favorite, gradient: LinearGradient( diff --git a/lib/modules/timbre/controllers/timbre_controller.dart b/lib/modules/timbre/controllers/timbre_controller.dart index 49ff05d10..4514d2aa2 100644 --- a/lib/modules/timbre/controllers/timbre_controller.dart +++ b/lib/modules/timbre/controllers/timbre_controller.dart @@ -288,16 +288,5 @@ class TimbreController extends GetxController { type.value = data['type']; settingsController.timbreName.value = data['name']; _storage.write('timbre', data['type']); - setSpeechServiceType(); - } - - // 设置语音音色服务类型 - void setSpeechServiceType() { - try { - final factory = Get.find(); - factory.setTimbreServiceType(); - } catch (e) { - // 处理错误 - } } } diff --git a/pubspec.yaml b/pubspec.yaml index 2daf529c7..c9ce59886 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -73,8 +73,7 @@ flutter: - assets/images/headphone_light.png - assets/images/headphone_dark.png - assets/images/robot_light.png - - assets/images/robot_dark.png - - assets/images/glasses_light.jpg + - assets/images/glasses_light.png - assets/images/agents/ - assets/images/explore.png - assets/images/explore1.png