diff --git a/examples/xiaozhi/README.md b/examples/xiaozhi/README.md index a8e352b..beda4ba 100644 --- a/examples/xiaozhi/README.md +++ b/examples/xiaozhi/README.md @@ -136,15 +136,13 @@ APP_CONFIG = { ### Q:唤醒词一直没有反应? -由于小爱音箱远场拾音音量较小,有时可能会识别不清,你可以调大 `config.py` 配置文件里的 `boost` 参数,然后重启应用 / Docker 试试看。 +如果唤醒词还是不敏感,可以先调低 `vad.threshold`,然后重启应用 / Docker 试试看。 ```py APP_CONFIG = { "vad": { - # 小爱音箱录音音量较小,需要后期放大一下 - "boost": 100, - # boost 调大后,语音检测阈值可能也需要一起调大些 - "threshold": 0.50, + # 语音检测阈值(0-1,越小越灵敏) + "threshold": 0.05, }, # ... 其他配置 } diff --git a/examples/xiaozhi/config.py b/examples/xiaozhi/config.py index aa843f8..fd316e5 100644 --- a/examples/xiaozhi/config.py +++ b/examples/xiaozhi/config.py @@ -53,8 +53,6 @@ APP_CONFIG = { "after_wakeup": after_wakeup, }, "vad": { - # 录音音量增强倍数(小爱音箱录音音量较小,需要后期放大一下) - "boost": 10, # 语音检测阈值(0-1,越小越灵敏) "threshold": 0.10, # 最小语音时长(ms) diff --git a/examples/xiaozhi/xiaozhi/services/audio/kws/sherpa.py b/examples/xiaozhi/xiaozhi/services/audio/kws/sherpa.py index 667c22a..b9d231b 100644 --- a/examples/xiaozhi/xiaozhi/services/audio/kws/sherpa.py +++ b/examples/xiaozhi/xiaozhi/services/audio/kws/sherpa.py @@ -9,10 +9,10 @@ class _SherpaOnnx: self.keyword_spotter = sherpa_onnx.KeywordSpotter( provider="cpu", num_threads=1, - max_active_paths=4, + max_active_paths=8, keywords_score=2.0, keywords_threshold=0.2, - num_trailing_blanks=1, + num_trailing_blanks=0, keywords_file=get_model_file_path("keywords.txt"), tokens=get_model_file_path("tokens.txt"), encoder=get_model_file_path("encoder.onnx"), diff --git a/examples/xiaozhi/xiaozhi/services/audio/stream.py b/examples/xiaozhi/xiaozhi/services/audio/stream.py index ca11d4e..a5a7489 100644 --- a/examples/xiaozhi/xiaozhi/services/audio/stream.py +++ b/examples/xiaozhi/xiaozhi/services/audio/stream.py @@ -1,9 +1,6 @@ import uuid from typing import Any, Callable, ClassVar, Optional -import numpy as np - -from config import APP_CONFIG from xiaozhi.ref import get_xiaoai @@ -88,10 +85,7 @@ class MyStream: return if len(data) > 0: - samples = np.frombuffer(data, dtype=np.int16) - # 小爱音箱录音音量较小,需要后期放大一下 - samples = samples * APP_CONFIG["vad"]["boost"] - self.input_bytes.extend(samples.tobytes()) + self.input_bytes.extend(data) def read(self, num_frames=None, exception_on_overflow=False) -> bytes: if num_frames is None: