mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
feat: TTS播放结束提示音
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
Reference in New Issue
Block a user