feat: TTS播放结束提示音

This commit is contained in:
Jad
2025-03-23 01:26:29 +08:00
parent 5a05a68524
commit 0bf0b0d381
4 changed files with 14 additions and 1 deletions
+1
View File
@@ -145,6 +145,7 @@ tmp
.history
.DS_Store
main/xiaozhi-server/data
!main/xiaozhi-server/data/tts_notify.mp3
main/manager-web/node_modules
.config.yaml
.secrets.yaml
+2
View File
@@ -57,6 +57,8 @@ delete_audio: true
close_connection_no_voice_time: 120
# TTS请求超时时间(秒)
tts_timeout: 10
# TTS播放结束提示音
tts_notify: "data/tts_notify.mp3"
CMD_exit:
- "退出"
@@ -60,9 +60,19 @@ async def send_tts_message(conn, state, text=None):
if text is not None:
message["text"] = text
await conn.websocket.send(json.dumps(message))
# TTS播放结束
if state == "stop":
# 清除服务端讲话状态
conn.clearSpeakStatus()
# 播放提示音
tts_notify = conn.config.get("tts_notify", "")
if tts_notify:
opus_packets, duration = conn.tts.audio_to_opus_data(tts_notify)
for opus_packet in opus_packets:
await conn.websocket.send(opus_packet)
# 发送消息到客户端
await conn.websocket.send(json.dumps(message))
async def send_stt_message(conn, text):
Binary file not shown.