From ac1e254eedc523af92487a395c931dc8b5118de8 Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Sun, 8 Jun 2025 11:50:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?update:=E6=99=BA=E6=8E=A7=E5=8F=B0=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E5=94=A4=E9=86=92=E8=AF=8D=E5=8A=A0=E9=80=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/xiaozhi/common/constant/Constant.java | 2 +- .../src/main/resources/db/changelog/202506080955.sql | 3 +++ .../main/resources/db/changelog/db.changelog-master.yaml | 9 ++++++++- main/xiaozhi-server/config/logger.py | 2 +- main/xiaozhi-server/core/handle/helloHandle.py | 8 +++++--- main/xiaozhi-server/core/handle/sendAudioHandle.py | 1 + .../core/providers/tts/huoshan_double_stream.py | 2 -- main/xiaozhi-server/core/providers/tts/linkerai.py | 2 ++ 8 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 main/manager-api/src/main/resources/db/changelog/202506080955.sql diff --git a/main/manager-api/src/main/java/xiaozhi/common/constant/Constant.java b/main/manager-api/src/main/java/xiaozhi/common/constant/Constant.java index 2590a566..44294756 100644 --- a/main/manager-api/src/main/java/xiaozhi/common/constant/Constant.java +++ b/main/manager-api/src/main/java/xiaozhi/common/constant/Constant.java @@ -227,7 +227,7 @@ public interface Constant { /** * 版本号 */ - public static final String VERSION = "0.5.4"; + public static final String VERSION = "0.5.5"; /** * 无效固件URL diff --git a/main/manager-api/src/main/resources/db/changelog/202506080955.sql b/main/manager-api/src/main/resources/db/changelog/202506080955.sql new file mode 100644 index 00000000..5f5e799e --- /dev/null +++ b/main/manager-api/src/main/resources/db/changelog/202506080955.sql @@ -0,0 +1,3 @@ +-- 智控台开启唤醒词加速 +update `sys_params` set param_value = '你好小智;你好小志;小爱同学;你好小鑫;你好小新;小美同学;小龙小龙;喵喵同学;小滨小滨;小冰小冰;嘿你好呀' where param_code = 'wakeup_words'; +update `sys_params` set param_value = 'true' where param_code = 'enable_wakeup_words_response_cache'; diff --git a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml b/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml index cb3007aa..f33d28a2 100755 --- a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml @@ -197,4 +197,11 @@ databaseChangeLog: changes: - sqlFile: encoding: utf8 - path: classpath:db/changelog/202506051538.sql \ No newline at end of file + path: classpath:db/changelog/202506051538.sql + - changeSet: + id: 202506080955 + author: hrz + changes: + - sqlFile: + encoding: utf8 + path: classpath:db/changelog/202506080955.sql \ No newline at end of file diff --git a/main/xiaozhi-server/config/logger.py b/main/xiaozhi-server/config/logger.py index 7bd22c43..a99013aa 100644 --- a/main/xiaozhi-server/config/logger.py +++ b/main/xiaozhi-server/config/logger.py @@ -5,7 +5,7 @@ from config.config_loader import load_config from config.settings import check_config_file from datetime import datetime -SERVER_VERSION = "0.5.4" +SERVER_VERSION = "0.5.5" _logger_initialized = False diff --git a/main/xiaozhi-server/core/handle/helloHandle.py b/main/xiaozhi-server/core/handle/helloHandle.py index 0232c9ac..1edeefcd 100644 --- a/main/xiaozhi-server/core/handle/helloHandle.py +++ b/main/xiaozhi-server/core/handle/helloHandle.py @@ -3,7 +3,7 @@ import json import random import asyncio from core.utils.util import audio_to_data -from core.handle.sendAudioHandle import send_stt_message +from core.handle.sendAudioHandle import sendAudioMessage, send_stt_message from core.utils.util import remove_punctuation_and_length, opus_datas_to_wav_bytes from core.providers.tts.dto.dto import ContentType, SentenceType from core.handle.mcpHandle import ( @@ -74,8 +74,10 @@ async def checkWakeupWords(conn, text): # 播放唤醒词回复 conn.client_abort = False opus_packets, _ = audio_to_data(response["file_path"]) - conn.tts.tts_audio_queue.put((SentenceType.FIRST, opus_packets, response["text"])) - conn.tts.tts_audio_queue.put((SentenceType.LAST, [], None)) + + conn.logger.bind(tag=TAG).info(f"播放唤醒词回复: {response['text']}") + await sendAudioMessage(conn, SentenceType.FIRST, opus_packets, response["text"]) + await sendAudioMessage(conn, SentenceType.LAST, [], None) # 检查是否需要更新唤醒词回复 if time.time() - response["time"] > WAKEUP_CONFIG["refresh_time"]: diff --git a/main/xiaozhi-server/core/handle/sendAudioHandle.py b/main/xiaozhi-server/core/handle/sendAudioHandle.py index ea81b7ed..2bf55e65 100644 --- a/main/xiaozhi-server/core/handle/sendAudioHandle.py +++ b/main/xiaozhi-server/core/handle/sendAudioHandle.py @@ -34,6 +34,7 @@ emoji_map = { async def sendAudioMessage(conn, sentenceType, audios, text): # 发送句子开始消息 + conn.logger.bind(tag=TAG).info(f"发送音频消息: {sentenceType}, {text}") if text is not None: emotion = analyze_emotion(text) emoji = emoji_map.get(emotion, "🙂") # 默认使用笑脸 diff --git a/main/xiaozhi-server/core/providers/tts/huoshan_double_stream.py b/main/xiaozhi-server/core/providers/tts/huoshan_double_stream.py index 8245b754..83a2d83a 100644 --- a/main/xiaozhi-server/core/providers/tts/huoshan_double_stream.py +++ b/main/xiaozhi-server/core/providers/tts/huoshan_double_stream.py @@ -188,10 +188,8 @@ class TTSProvider(TTSProviderBase): def tts_text_priority_thread(self): """火山引擎双流式TTS的文本处理线程""" - logger.bind(tag=TAG).info("TTS文本处理线程启动") while not self.conn.stop_event.is_set(): try: - logger.bind(tag=TAG).debug("等待TTS文本队列消息...") message = self.tts_text_queue.get(timeout=1) logger.bind(tag=TAG).debug( f"收到TTS任务|{message.sentence_type.name} | {message.content_type.name} | 会话ID: {self.conn.sentence_id}" diff --git a/main/xiaozhi-server/core/providers/tts/linkerai.py b/main/xiaozhi-server/core/providers/tts/linkerai.py index 649ed51d..69127e8a 100644 --- a/main/xiaozhi-server/core/providers/tts/linkerai.py +++ b/main/xiaozhi-server/core/providers/tts/linkerai.py @@ -93,6 +93,8 @@ class TTSProvider(TTSProviderBase): self.processed_chars += len(full_text) else: self._process_before_stop_play_files() + else: + self._process_before_stop_play_files() def to_tts_single_stream(self, text, is_last=False): try: From 1d57e75d28bc1da8632e0dd5e11d998ba6c1936e Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Sun, 8 Jun 2025 11:59:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?update:=E5=8D=95=E6=B5=81=E5=BC=8Ftts?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E8=AE=B0=E5=BD=95=E4=B8=8A=E6=8A=A5=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/providers/tts/linkerai.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main/xiaozhi-server/core/providers/tts/linkerai.py b/main/xiaozhi-server/core/providers/tts/linkerai.py index 69127e8a..7493764f 100644 --- a/main/xiaozhi-server/core/providers/tts/linkerai.py +++ b/main/xiaozhi-server/core/providers/tts/linkerai.py @@ -173,6 +173,8 @@ class TTSProvider(TTSProviderBase): self.pcm_buffer.clear() opus_datas_cache = [] + self.tts_audio_queue.put((SentenceType.FIRST, [], text)) + # 兼容 iter_chunked / iter_chunks / iter_any async for chunk in resp.content.iter_any(): data = chunk[0] if isinstance(chunk, (list, tuple)) else chunk @@ -193,7 +195,7 @@ class TTSProvider(TTSProviderBase): if opus: if self.segment_count < 10: # 前10个片段直接发送 self.tts_audio_queue.put( - (SentenceType.MIDDLE, opus, text) + (SentenceType.MIDDLE, opus, None) ) self.segment_count += 1 else: @@ -208,7 +210,7 @@ class TTSProvider(TTSProviderBase): if self.segment_count < 10: # 前10个片段直接发送 # 直接发送 self.tts_audio_queue.put( - (SentenceType.MIDDLE, opus, text) + (SentenceType.MIDDLE, opus, None) ) self.segment_count += 1 else: @@ -219,7 +221,7 @@ class TTSProvider(TTSProviderBase): # 如果不是前10个片段,发送缓存的数据 if self.segment_count >= 10 and opus_datas_cache: self.tts_audio_queue.put( - (SentenceType.MIDDLE, opus_datas_cache, text) + (SentenceType.MIDDLE, opus_datas_cache, None) ) # 如果是最后一段,输出音频获取完毕