From 4acb5f924a5c8c469240789c11344acfae9f532b Mon Sep 17 00:00:00 2001 From: hrz <1710360675@qq.com> Date: Sun, 23 Mar 2025 22:40:31 +0800 Subject: [PATCH] =?UTF-8?q?update:=E5=A2=9E=E5=8A=A0=E7=A7=81=E6=9C=89?= =?UTF-8?q?=E5=94=A4=E9=86=92=E7=AD=94=E5=A4=8D=E6=96=87=E4=BB=B6=20(#488)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/handle/helloHandle.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main/xiaozhi-server/core/handle/helloHandle.py b/main/xiaozhi-server/core/handle/helloHandle.py index b978b4af..9eed6a0a 100644 --- a/main/xiaozhi-server/core/handle/helloHandle.py +++ b/main/xiaozhi-server/core/handle/helloHandle.py @@ -31,7 +31,7 @@ async def checkWakeupWords(conn, text): conn.tts_last_text_index = 0 conn.llm_finish_task = True - file = getWakeupWordFile() + file = getWakeupWordFile(WAKEUP_CONFIG["file_name"]) if file is None: asyncio.create_task(wakeupWordsResponse(conn)) return False @@ -43,10 +43,14 @@ async def checkWakeupWords(conn, text): return False -def getWakeupWordFile(): +def getWakeupWordFile(file_name): + for file in os.listdir(WAKEUP_CONFIG["dir"]): + if "my_"+file_name in file: + return f"config/assets/{file}" + """查找config/assets/目录下名称为wakeup_words的文件""" for file in os.listdir(WAKEUP_CONFIG["dir"]): - if WAKEUP_CONFIG["file_name"] in file: + if file_name in file: return f"config/assets/{file}" return None @@ -60,9 +64,9 @@ async def wakeupWordsResponse(conn): file_type = os.path.splitext(tts_file)[1] if file_type: file_type = file_type.lstrip('.') - old_file = getWakeupWordFile() + old_file = getWakeupWordFile("my_" +WAKEUP_CONFIG["file_name"]) if old_file is not None: os.remove(old_file) """将文件挪到"wakeup_words.mp3""" - shutil.move(tts_file, WAKEUP_CONFIG["dir"] + WAKEUP_CONFIG["file_name"] + "." + file_type) + shutil.move(tts_file, WAKEUP_CONFIG["dir"] + "my_" +WAKEUP_CONFIG["file_name"] + "." + file_type) WAKEUP_CONFIG["create_time"] = time.time()