mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-30 03:33:56 +08:00
Merge pull request #526 from xinnan-tech/fix-wakeup_words
Fix wakeup words
This commit is contained in:
@@ -155,3 +155,4 @@ main/manager-web/node_modules
|
|||||||
# model files
|
# model files
|
||||||
main/xiaozhi-server/models/SenseVoiceSmall/model.pt
|
main/xiaozhi-server/models/SenseVoiceSmall/model.pt
|
||||||
main/xiaozhi-server/models/sherpa-onnx*
|
main/xiaozhi-server/models/sherpa-onnx*
|
||||||
|
my_wakeup_words.mp3
|
||||||
|
|||||||
@@ -323,6 +323,8 @@ class ConnectionHandler:
|
|||||||
self.dialogue.put(Message(role="user", content=query))
|
self.dialogue.put(Message(role="user", content=query))
|
||||||
|
|
||||||
# Define intent functions
|
# Define intent functions
|
||||||
|
functions = None
|
||||||
|
if hasattr(self, 'func_handler'):
|
||||||
functions = self.func_handler.get_functions()
|
functions = self.func_handler.get_functions()
|
||||||
|
|
||||||
response_message = []
|
response_message = []
|
||||||
|
|||||||
@@ -45,12 +45,14 @@ async def checkWakeupWords(conn, text):
|
|||||||
|
|
||||||
def getWakeupWordFile(file_name):
|
def getWakeupWordFile(file_name):
|
||||||
for file in os.listdir(WAKEUP_CONFIG["dir"]):
|
for file in os.listdir(WAKEUP_CONFIG["dir"]):
|
||||||
if "my_"+file_name in file:
|
if file.startswith("my_" + file_name):
|
||||||
|
"""避免缓存文件是一个空文件"""
|
||||||
|
if os.stat(f"config/assets/{file}").st_size > (5 * 1024):
|
||||||
return f"config/assets/{file}"
|
return f"config/assets/{file}"
|
||||||
|
|
||||||
"""查找config/assets/目录下名称为wakeup_words的文件"""
|
"""查找config/assets/目录下名称为wakeup_words的文件"""
|
||||||
for file in os.listdir(WAKEUP_CONFIG["dir"]):
|
for file in os.listdir(WAKEUP_CONFIG["dir"]):
|
||||||
if file_name in file:
|
if file.startswith(file_name):
|
||||||
return f"config/assets/{file}"
|
return f"config/assets/{file}"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user