mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 18:23:59 +08:00
Merge branch 'main' into develop
# Conflicts: # core/connection.py # core/handle/audioHandle.py # core/utils/util.py
This commit is contained in:
@@ -27,7 +27,6 @@ async def handleAudioMessage(conn, audio):
|
|||||||
conn.asr_server_receive = False
|
conn.asr_server_receive = False
|
||||||
text, file_path = conn.asr.speech_to_text(conn.asr_audio, conn.session_id)
|
text, file_path = conn.asr.speech_to_text(conn.asr_audio, conn.session_id)
|
||||||
logger.info(f"识别文本: {text}")
|
logger.info(f"识别文本: {text}")
|
||||||
|
|
||||||
text_len, text_without_punctuation = remove_punctuation_and_length(text)
|
text_len, text_without_punctuation = remove_punctuation_and_length(text)
|
||||||
if text_len <= conn.max_cmd_length and await handleCMDMessage(conn, text_without_punctuation):
|
if text_len <= conn.max_cmd_length and await handleCMDMessage(conn, text_without_punctuation):
|
||||||
return
|
return
|
||||||
@@ -38,6 +37,28 @@ async def handleAudioMessage(conn, audio):
|
|||||||
conn.asr_audio.clear()
|
conn.asr_audio.clear()
|
||||||
conn.reset_vad_states()
|
conn.reset_vad_states()
|
||||||
|
|
||||||
|
async def handleCMDMessage(conn, text):
|
||||||
|
cmd_exit = conn.cmd_exit
|
||||||
|
for cmd in cmd_exit:
|
||||||
|
if text == cmd:
|
||||||
|
logger.info("识别到明确的退出命令".format(text))
|
||||||
|
await finishToChat(conn)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def finishToChat(conn):
|
||||||
|
await conn.close()
|
||||||
|
|
||||||
|
async def isLLMWantToFinsih(conn):
|
||||||
|
first_text = conn.tts_first_text
|
||||||
|
last_text = conn.tts_last_text
|
||||||
|
_, last_text_without_punctuation = remove_punctuation_and_length(last_text)
|
||||||
|
if "再见" in last_text_without_punctuation or "拜拜" in last_text_without_punctuation:
|
||||||
|
return True
|
||||||
|
_, first_text_without_punctuation = remove_punctuation_and_length(first_text)
|
||||||
|
if "再见" in first_text_without_punctuation or "拜拜" in first_text_without_punctuation:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
async def handleCMDMessage(conn, text):
|
async def handleCMDMessage(conn, text):
|
||||||
cmd_exit = conn.cmd_exit
|
cmd_exit = conn.cmd_exit
|
||||||
|
|||||||
Reference in New Issue
Block a user