mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-24 04:19:48 +01:00
fix:播放音乐不会停
This commit is contained in:
parent
347fc4ca44
commit
cd3e9ed494
3 changed files with 17 additions and 8 deletions
|
|
@ -199,9 +199,9 @@ class ConnectionHandler:
|
|||
if self.private_config:
|
||||
self.prompt = self.private_config.private_config.get("prompt", self.prompt)
|
||||
|
||||
# self.client_ip_info = get_ip_info(self.client_ip)
|
||||
# self.logger.bind(tag=TAG).info(f"Client ip info: {self.client_ip_info}")
|
||||
# self.prompt = self.prompt + f"\n我在:{self.client_ip_info}"
|
||||
self.client_ip_info = get_ip_info(self.client_ip)
|
||||
self.logger.bind(tag=TAG).info(f"Client ip info: {self.client_ip_info}")
|
||||
self.prompt = self.prompt + f"\n我在:{self.client_ip_info}"
|
||||
self.dialogue.put(Message(role="system", content=self.prompt))
|
||||
|
||||
self.func_handler = FunctionHandler(self.config)
|
||||
|
|
|
|||
|
|
@ -98,11 +98,12 @@ class TTSProviderBase(ABC):
|
|||
async def finish_session(self, session_id):
|
||||
pass
|
||||
|
||||
async def tts_one_sentence(self,text):
|
||||
uuid_str = str(uuid.uuid4()).replace("-", "")
|
||||
self.tts.tts_text_queue.put(TTSMessageDTO(u_id=uuid_str, msg_type=MsgType.START_TTS_REQUEST, content=''))
|
||||
self.tts.tts_text_queue.put(TTSMessageDTO(u_id=uuid_str, msg_type=MsgType.TTS_TEXT_REQUEST, content=text))
|
||||
self.tts.tts_text_queue.put(TTSMessageDTO(u_id=uuid_str, msg_type=MsgType.STOP_TTS_REQUEST, content=text))
|
||||
async def tts_one_sentence(self, text, u_id=None):
|
||||
if not u_id:
|
||||
u_id = str(uuid.uuid4()).replace("-", "")
|
||||
self.tts.tts_text_queue.put(TTSMessageDTO(u_id=u_id, msg_type=MsgType.START_TTS_REQUEST, content=''))
|
||||
self.tts.tts_text_queue.put(TTSMessageDTO(u_id=u_id, msg_type=MsgType.TTS_TEXT_REQUEST, content=text))
|
||||
self.tts.tts_text_queue.put(TTSMessageDTO(u_id=u_id, msg_type=MsgType.STOP_TTS_REQUEST, content=text))
|
||||
|
||||
def _enable_two_way_tts(self):
|
||||
while not self.stop_event.is_set():
|
||||
|
|
|
|||
|
|
@ -196,6 +196,14 @@ async def play_local_music(conn, specific_file=None):
|
|||
tts_finish_text="", sentence_type=None, duration=0
|
||||
)
|
||||
)
|
||||
conn.tts.tts_audio_queue.put(
|
||||
TTSMessageDTO(
|
||||
u_id=conn.u_id, msg_type=MsgType.STOP_TTS_RESPONSE, content=[],
|
||||
tts_finish_text='',
|
||||
sentence_type=None
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"播放音乐失败: {str(e)}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue