mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 18:23:59 +08:00
update:去掉无用代码
This commit is contained in:
@@ -869,19 +869,6 @@ class ConnectionHandler:
|
|||||||
|
|
||||||
self.logger.bind(tag=TAG).info("聊天记录上报线程已退出")
|
self.logger.bind(tag=TAG).info("聊天记录上报线程已退出")
|
||||||
|
|
||||||
def speak_and_play(self, text, text_index=0):
|
|
||||||
if text is None or len(text) <= 0:
|
|
||||||
self.logger.bind(tag=TAG).info(f"无需tts转换,query为空,{text}")
|
|
||||||
return None, text, text_index
|
|
||||||
tts_file = self.tts.to_tts(text)
|
|
||||||
if tts_file is None:
|
|
||||||
self.logger.bind(tag=TAG).error(f"tts转换失败,{text}")
|
|
||||||
return None, text, text_index
|
|
||||||
self.logger.bind(tag=TAG).debug(f"TTS 文件生成完毕: {tts_file}")
|
|
||||||
if self.max_output_size > 0:
|
|
||||||
add_device_output(self.headers.get("device-id"), len(text))
|
|
||||||
return tts_file, text, text_index
|
|
||||||
|
|
||||||
def clearSpeakStatus(self):
|
def clearSpeakStatus(self):
|
||||||
self.logger.bind(tag=TAG).debug(f"清除服务端讲话状态")
|
self.logger.bind(tag=TAG).debug(f"清除服务端讲话状态")
|
||||||
self.asr_server_receive = True
|
self.asr_server_receive = True
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ play_music_function_desc = {
|
|||||||
|
|
||||||
|
|
||||||
@register_function("play_music", play_music_function_desc, ToolType.SYSTEM_CTL)
|
@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:
|
try:
|
||||||
music_intent = (
|
music_intent = (
|
||||||
f"播放音乐 {song_name}" if song_name != "random" else "随机播放音乐"
|
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)
|
text = _get_random_play_prompt(selected_music)
|
||||||
await send_stt_message(conn, text)
|
await send_stt_message(conn, text)
|
||||||
conn.dialogue.put(Message(role="assistant", content=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)
|
conn.tts.tts_one_sentence(conn, 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
|
|
||||||
|
|
||||||
if music_path.endswith(".p3"):
|
if music_path.endswith(".p3"):
|
||||||
opus_packets, _ = p3.decode_opus_from_file(music_path)
|
opus_packets, _ = p3.decode_opus_from_file(music_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user