mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
修复 alillm functions/play_music.py 连续播放音乐问题
This commit is contained in:
parent
37a1dfa96b
commit
347aefaa9f
3 changed files with 13 additions and 7 deletions
|
|
@ -722,7 +722,6 @@ class ConnectionHandler:
|
|||
|
||||
for response in llm_responses:
|
||||
content, tools_call = response
|
||||
|
||||
if "content" in response:
|
||||
content = response["content"]
|
||||
tools_call = None
|
||||
|
|
@ -813,8 +812,8 @@ class ConnectionHandler:
|
|||
self.dialogue.put(
|
||||
Message(role="assistant", content="".join(response_message))
|
||||
)
|
||||
self.ttsClient.send(json.dumps( { "type": 'finish' }))
|
||||
|
||||
self.ttsClient.send(json.dumps( { "type": 'finish' }))
|
||||
self.logger.bind(tag=TAG).info("TTS流结束")
|
||||
self.llm_finish_task = True
|
||||
self.logger.bind(tag=TAG).debug(
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import difflib
|
|||
import traceback
|
||||
from pathlib import Path
|
||||
from core.utils import p3
|
||||
from core.utils.dialogue import Message, Dialogue
|
||||
from core.handle.sendAudioHandle import send_stt_message
|
||||
from plugins_func.register import register_function, ToolType, ActionResponse, Action
|
||||
import json
|
||||
|
|
@ -65,10 +66,16 @@ def play_music(conn, song_name: str):
|
|||
|
||||
future.add_done_callback(handle_done)
|
||||
|
||||
conn.dialogue.put(
|
||||
Message(role="assistant", content="".join("音乐播放成功"))
|
||||
)
|
||||
return ActionResponse(
|
||||
action=Action.NONE, result="指令已接收", response="正在为您播放音乐"
|
||||
)
|
||||
except Exception as e:
|
||||
conn.dialogue.put(
|
||||
Message(role="assistant", content="".join("音乐播放失败"))
|
||||
)
|
||||
logger.bind(tag=TAG).error(f"处理音乐意图错误: {e}")
|
||||
return ActionResponse(
|
||||
action=Action.RESPONSE, result=str(e), response="播放音乐时出错了"
|
||||
|
|
@ -224,9 +231,9 @@ async def play_local_music(conn, specific_file=None):
|
|||
opus_packets, _ = conn.tts.audio_to_opus_data(tts_file)
|
||||
conn.audio_play_queue.put((opus_packets, None, 0))
|
||||
os.remove(tts_file)
|
||||
# else:
|
||||
# conn.ttsClient.send(json.dumps({ "type": 'text',"text": text }))
|
||||
# conn.ttsClient.send(json.dumps( { "type": 'finish' }))
|
||||
else:
|
||||
conn.ttsClient.send(json.dumps({ "type": 'text',"text": text }))
|
||||
conn.ttsClient.send(json.dumps( { "type": 'finish' }))
|
||||
|
||||
conn.llm_finish_task = True
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>小智服务器测试页面</title>
|
||||
<title>深塔服务器测试页面</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
||||
|
|
@ -436,7 +436,7 @@
|
|||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>小智服务器测试页面</h1>
|
||||
<h1>深塔服务器测试页面</h1>
|
||||
|
||||
<div id="scriptStatus" style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);">
|
||||
正在加载Opus库...</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue