diff --git a/assets/images/ai0_hd_en.png b/assets/images/ai0_hd_en.png new file mode 100644 index 0000000..43d852e Binary files /dev/null and b/assets/images/ai0_hd_en.png differ diff --git a/assets/images/ai1_hd_en.png b/assets/images/ai1_hd_en.png new file mode 100644 index 0000000..abd6bc0 Binary files /dev/null and b/assets/images/ai1_hd_en.png differ diff --git a/lib/screens/full_screen.dart b/lib/screens/full_screen.dart index ed9d22e..ff7b280 100644 --- a/lib/screens/full_screen.dart +++ b/lib/screens/full_screen.dart @@ -67,12 +67,12 @@ class _FullScreenState extends State { _scrollToBottom(); }); if (messageService.messages.isEmpty) { - // Future.delayed(const Duration(milliseconds: 500), () { + Future.delayed(const Duration(milliseconds: 500), () { String text = Intl.getCurrentLocale().startsWith('zh') ? "您好,我是众众,请问有什么可以帮您?" : "Hi, I'm Zhongzhong, may I help you ? "; messageService.addMessage(text, false, MessageStatus.normal); - // }); + }); } return ChatBox( scrollController: _scrollController, diff --git a/lib/services/chat_sse_service.dart b/lib/services/chat_sse_service.dart index c95680b..493779f 100644 --- a/lib/services/chat_sse_service.dart +++ b/lib/services/chat_sse_service.dart @@ -59,8 +59,7 @@ class ChatSseService { txt = txt.substring(0, imgStart) + txt.substring(imgEnd + 1); imgStart = txt.indexOf('!['); } - // 彻底移除 markdown 有序/无序列表序号(如 1.、2.、-、*、+) - txt = txt.replaceAll(RegExp(r'(^|\n)[ \t]*[0-9]+\.[ \t]*'), '\n'); + txt = txt.replaceAll(RegExp(r'(^|\n)[ \t]*[-\*\+][ \t]+'), '\n'); // 分句符 RegExp enders = isChinese ? zhEnders : enEnders; @@ -77,8 +76,14 @@ class ChatSseService { } // 只在达到完整句子时调用 TtsUtil.send for (final s in sentences) { - String ttsStr=CommonUtil.cleanText(s, true); - // print("发送数据到TTS: $ttsStr"); + String ttsStr=CommonUtil.cleanText(s, true)+"\n"; + + ttsStr = ttsStr.replaceAllMapped( + RegExp(r'(? ' ${m.group(1)} ', + ); + + print("发送数据到TTS: $ttsStr"); TtsUtil.send(ttsStr); } // 缓存剩余不完整部分 diff --git a/lib/widgets/floating_icon.dart b/lib/widgets/floating_icon.dart index 1bce012..a091b22 100644 --- a/lib/widgets/floating_icon.dart +++ b/lib/widgets/floating_icon.dart @@ -5,6 +5,7 @@ import '../screens/full_screen.dart'; import '../screens/part_screen.dart'; import 'floating_icon_with_wave.dart'; import 'dart:async'; // 添加此行 +import 'package:basic_intl/intl.dart'; class FloatingIcon extends StatefulWidget { const FloatingIcon({super.key}); @@ -27,6 +28,11 @@ class _FloatingIconState extends State 'assets/images/ai1_hd.png', 'assets/images/ai0_hd.png', ]; + + late final List _iconImagesEn = [ + 'assets/images/ai1_hd_en.png', + 'assets/images/ai0_hd_en.png', + ]; Timer? _imageTimer; // 用于定时切换图片 @override @@ -130,7 +136,8 @@ class _FloatingIconState extends State waveColor: Colors.white, ) : Image.asset( - _iconImages[_imageIndex], + Intl.getCurrentLocale().startsWith('zh') + ? _iconImages[_imageIndex]:_iconImagesEn[_imageIndex], width: iconSize, height: iconSize, ),