mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 07:03:55 +08:00
update:旧非流失兼容改造
This commit is contained in:
@@ -110,12 +110,9 @@ async def no_voice_close_connect(conn):
|
||||
async def max_out_size(conn):
|
||||
text = "不好意思,我现在有点事情要忙,明天这个时候我们再聊,约好了哦!明天不见不散,拜拜!"
|
||||
await send_stt_message(conn, text)
|
||||
conn.tts_first_text_index = 0
|
||||
conn.tts_last_text_index = 0
|
||||
conn.llm_finish_task = True
|
||||
file_path = "config/assets/max_output_size.wav"
|
||||
opus_packets, _ = audio_to_data(file_path)
|
||||
conn.tts.audio_play_queue.put((opus_packets, text, 0))
|
||||
conn.tts.tts_audio_queue.put((opus_packets, text, 0))
|
||||
conn.close_after_chat = True
|
||||
|
||||
|
||||
@@ -130,14 +127,11 @@ async def check_bind_device(conn):
|
||||
|
||||
text = f"请登录控制面板,输入{conn.bind_code},绑定设备。"
|
||||
await send_stt_message(conn, text)
|
||||
conn.tts_first_text_index = 0
|
||||
conn.tts_last_text_index = 6
|
||||
conn.llm_finish_task = True
|
||||
|
||||
# 播放提示音
|
||||
music_path = "config/assets/bind_code.wav"
|
||||
opus_packets, _ = audio_to_data(music_path)
|
||||
conn.tts.audio_play_queue.put((opus_packets, text, 0))
|
||||
conn.tts.tts_audio_queue.put((opus_packets, text, 0))
|
||||
|
||||
# 逐个播放数字
|
||||
for i in range(6): # 确保只播放6位数字
|
||||
@@ -145,16 +139,13 @@ async def check_bind_device(conn):
|
||||
digit = conn.bind_code[i]
|
||||
num_path = f"config/assets/bind_code/{digit}.wav"
|
||||
num_packets, _ = audio_to_data(num_path)
|
||||
conn.tts.audio_play_queue.put((num_packets, None, i + 1))
|
||||
conn.tts.tts_audio_queue.put((num_packets, None, i + 1))
|
||||
except Exception as e:
|
||||
conn.logger.bind(tag=TAG).error(f"播放数字音频失败: {e}")
|
||||
continue
|
||||
else:
|
||||
text = f"没有找到该设备的版本信息,请正确配置 OTA地址,然后重新编译固件。"
|
||||
await send_stt_message(conn, text)
|
||||
conn.tts_first_text_index = 0
|
||||
conn.tts_last_text_index = 0
|
||||
conn.llm_finish_task = True
|
||||
music_path = "config/assets/bind_not_found.wav"
|
||||
opus_packets, _ = audio_to_data(music_path)
|
||||
conn.tts.audio_play_queue.put((opus_packets, text, 0))
|
||||
conn.tts.tts_audio_queue.put((opus_packets, text, 0))
|
||||
|
||||
Reference in New Issue
Block a user