mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 00:53:54 +08:00
update:去掉无用代码
This commit is contained in:
@@ -38,7 +38,7 @@ play_music_function_desc = {
|
||||
|
||||
|
||||
@register_function("play_music", play_music_function_desc, ToolType.SYSTEM_CTL)
|
||||
def play_music(conn, song_name: str):
|
||||
def play_music(conn, song_name=None):
|
||||
try:
|
||||
music_intent = (
|
||||
f"播放音乐 {song_name}" if song_name != "random" else "随机播放音乐"
|
||||
@@ -218,17 +218,8 @@ async def play_local_music(conn, specific_file=None):
|
||||
text = _get_random_play_prompt(selected_music)
|
||||
await send_stt_message(conn, text)
|
||||
conn.dialogue.put(Message(role="assistant", content=text))
|
||||
conn.tts_first_text_index = 0
|
||||
conn.tts_last_text_index = 0
|
||||
|
||||
tts_file = await asyncio.to_thread(conn.tts.to_tts, text)
|
||||
if tts_file is not None and os.path.exists(tts_file):
|
||||
conn.tts_last_text_index = 1
|
||||
opus_packets, _ = conn.tts.audio_to_opus_data(tts_file)
|
||||
conn.audio_play_queue.put((opus_packets, None, 0))
|
||||
os.remove(tts_file)
|
||||
|
||||
conn.llm_finish_task = True
|
||||
conn.tts.tts_one_sentence(conn, text)
|
||||
|
||||
if music_path.endswith(".p3"):
|
||||
opus_packets, _ = p3.decode_opus_from_file(music_path)
|
||||
|
||||
Reference in New Issue
Block a user