Rebuilding my local voice assistant pipeline

本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。

Rebuilding my local voice assistant pipeline

Rebuilding my voice assistant pipeline https://blog.platypush.tech/article/Rewriting-my-voice-assistant-pipeline 📝 Swapping openwakeword for microwakeword and making voice detection smarter Fabio Manganiello Nov 19, 2026 #platypush #voice #voiceassistant #microwakeword #openai

重建我的本地语音助手管道 https://blog.platypush.tech/article/Rewriting-my-voice-assistant-pipeline 📝 将 openwakeword 替换为 microwakeword 并使语音检测更智能 Fabio Manganiello 2026年11月19日 #platypush #voice #voiceassistant #microwakeword #openai

Wake word detection: a new assistant.microwakeword plugin Speech-to-text: assistant.openai, with a much better ear Responses and context: the openai plugin Text-to-speech: tts.openai The full configuration What changed on the code side Caveats I wrote an article a couple of months ago describing how I rebuilt my old voice assistant pipeline in Platypush. And I wrote earlier articles describing my journey through self-hosted voice assistants - in 2024 (with Picovoice), in 2020 (diving into the legacy assistant.google integration, the now defunct assistant.alexa integration, the now defunct Snowboy integration, the now defunct DeepSpeech integration and Picovoice) and the original article in 2019 describing the Google Assistant integration.

唤醒词检测:一个新的 assistant.microwakeword 插件;语音转文字:assistant.openai,拥有更好的“听力”;响应与上下文:openai 插件;文字转语音:tts.openai;完整配置;代码侧的变更;注意事项。几个月前,我写了一篇文章,描述了我是如何在 Platypush 中重建旧的语音助手管道的。我还写过更早的文章,描述了我使用自托管语音助手的历程——2024 年(使用 Picovoice),2020 年(深入研究了已弃用的 assistant.google 集成、现已失效的 assistant.alexa 集成、现已失效的 Snowboy 集成、现已失效的 DeepSpeech 集成以及 Picovoice),以及 2019 年描述 Google Assistant 集成的最初文章。

For a couple of months I used the voice pipeline described in my latest article as my main driver, but after getting used to the robustness of commercial voice assistants I was unhappy with the high rates of false positives/negatives of my self-hosted pipeline, as well as its lack of robustness in detecting start/end of speech, especially in noisy environments and using cheap microphones. After a bit of experimentation, I decided to swap and fine tune a few parts, and after a couple of days of trying the results are satisfying enough for me to write a short article about it. The resulting pipeline is:

在过去几个月里,我一直将上一篇文章中描述的语音管道作为我的主要驱动程序,但在习惯了商业语音助手的稳健性之后,我对自托管管道的高误报/漏报率感到不满,而且它在检测语音开始/结束方面缺乏稳健性,尤其是在嘈杂环境和使用廉价麦克风时。经过一番实验,我决定更换并微调了一些部分,经过几天的尝试,结果令我满意,足以让我写一篇短文来介绍它。最终的管道如下:

Wake word detection: a new assistant.microwakeword plugin Until recently I used assistant.openwakeword, which wraps openWakeWord. It works, but the project has been quiet for a while and all of its pre-trained models are v0.1 files from 2023, mostly trained on synthetic speech. In practice I was getting both false positives (the hotword triggering on background noise) and false negatives (the hotword not detected unless I was close to the microphone). I added a new plugin, assistant.microwakeword, on top of microWakeWord through the pymicro-wakeword Python bindings. microWakeWord is the engine used by ESPHome and Home Assistant Voice, its models are actively maintained, and the built-in models (okay_nabu, hey_jarvis, hey_mycroft, alexa) ship with the package — no download required.

唤醒词检测:一个新的 assistant.microwakeword 插件。直到最近,我还在使用封装了 openWakeWord 的 assistant.openwakeword。它确实有效,但该项目已经沉寂了一段时间,其所有预训练模型都是 2023 年的 v0.1 文件,且大多是在合成语音上训练的。在实践中,我既遇到了误报(背景噪音触发了热词),也遇到了漏报(除非我靠近麦克风,否则检测不到热词)。我通过 pymicro-wakeword Python 绑定在 microWakeWord 之上添加了一个新插件 assistant.microwakeword。microWakeWord 是 ESPHome 和 Home Assistant Voice 使用的引擎,其模型得到了积极维护,并且内置模型(okay_nabu, hey_jarvis, hey_mycroft, alexa)随包提供——无需下载。

The current official models are provided under the ESPHome micro-wake-word-models repository. Custom models are supported too: drop a microWakeWord JSON manifest (with its .tflite model) in the plugin’s models directory and reference it by name. The plugin exposes the same API as assistant.openwakeword (same models, detection_threshold, frame_duration, patience_frames, input_device, input_volume parameters, same list_models action, same HotwordDetectedEvent), so switching is a matter of just changing the configuration to point to the new plugin: assistant.microwakeword: models: - alexa

目前的官方模型在 ESPHome 的 micro-wake-word-models 仓库下提供。也支持自定义模型:只需将 microWakeWord JSON 清单(及其 .tflite 模型)放入插件的 models 目录中,并按名称引用即可。该插件公开了与 assistant.openwakeword 相同的 API(相同的 models、detection_threshold、frame_duration、patience_frames、input_device、input_volume 参数,相同的 list_models 操作,相同的 HotwordDetectedEvent),因此切换只需更改配置以指向新插件即可:assistant.microwakeword: models: - alexa

A few design notes: Without an explicit detection_threshold, each model uses the probability_cutoff from its own manifest (0.9 for alexa), which is the value the model was validated against. Models already smooth their output over a sliding window, so unlike openwakeword, patience_frames defaults to 0 here. The audio thread never touches the TFLite models directly: it queues frames (and a reset marker) to the main thread, because MicroWakeWord.reset() reloads the interpreter and isn’t safe to call concurrently. Like assistant.openwakeword, the plugin releases the audio device when another assistant plugin starts a conversation, and re-acquires it when the conversation ends.

一些设计说明:如果没有明确的 detection_threshold,每个模型都会使用其清单中的 probability_cutoff(alexa 为 0.9),这是模型验证时所使用的值。模型已经在滑动窗口上平滑了输出,因此与 openwakeword 不同,这里的 patience_frames 默认为 0。音频线程从不直接接触 TFLite 模型:它将帧(以及重置标记)排队到主线程,因为 MicroWakeWord.reset() 会重新加载解释器,并发调用是不安全的。与 assistant.openwakeword 一样,当另一个助手插件开始对话时,该插件会释放音频设备,并在对话结束时重新获取它。

Speech-to-text: assistant.openai, with a much better ear assistant.openai records audio when a conversation starts and transcribes it through Whisper. The tricky part has always been end-of-speech detection: knowing when the user has finished talking. The previous implementation used a per-frame boolean from WebRTC VAD, and any single frame classified as speech would reset the silence timer. With even a bit of background noise, phrases would only end when the maximum conversation duration was hit. The audio preprocessing layer (AudioPreprocessor, shared by the STT integrations) has been reworked: Silero VAD as the primary backend (through onnxruntime, no PyTorch required), with WebRTC VAD and a plain RMS-based detector as fallbacks.

语音转文字:assistant.openai,拥有更好的“听力”。assistant.openai 在对话开始时录制音频,并通过 Whisper 进行转录。最棘手的部分一直是语音结束检测:即知道用户何时停止说话。之前的实现使用了来自 WebRTC VAD 的逐帧布尔值,任何被归类为语音的单帧都会重置静音计时器。即使有一点背景噪音,短语也只有在达到最大对话持续时间时才会结束。音频预处理层(AudioPreprocessor,由 STT 集成共享)已重新设计:以 Silero VAD 作为主要后端(通过 onnxruntime,无需 PyTorch),并以 WebRTC VAD 和简单的基于 RMS 的检测器作为后备。

To get an idea of Silero VAD’s performance compared against other solutions for speech activity detection, take a look at the insightful article One voice detector to rule them all. The Silero model is downloaded on first use into the Platypush workdir and checksum-verified: assistant.openai: # auto = silero -> webrtc -> energy, depending on what’s installed vad_backend: auto Hysteresis + sliding window: a frame becomes speech above the VAD threshold and stays speech until its score drops by a margin, and the per-frame decisions are smoothed by majority vote over a 0.5s window. A single noise burst can no longer keep a conversation alive.

要了解 Silero VAD 与其他语音活动检测解决方案相比的性能,请查看那篇富有洞察力的文章《One voice detector to rule them all》。Silero 模型在首次使用时会下载到 Platypush 工作目录中并进行校验和验证:assistant.openai: # auto = silero -> webrtc -> energy,取决于安装了什么 vad_backend: auto。滞后 + 滑动窗口:当帧高于 VAD 阈值时变为语音,并保持语音状态,直到其分数下降一定幅度;逐帧决策通过 0.5 秒窗口内的多数投票进行平滑处理。单一的噪音爆发不再能维持对话。

Adaptive noise floor: the background noise level is tracked over time, and frames that aren’t louder than noise_floor_factor (default 2.0, ~6 dB) times the floor are never considered as speech. On a synthetic benchmark (Piper-generated phrases mixed with babble and burst noise), the old settings kept conversations open for 6–10 seconds after the speech had ended; the new pipeline ends them 1.0–1.6 seconds after the last word, which is the configured conversation_end_timeout plus the smoothing lag. Since the changes on Platypush have been performed directly in the AudioPreprocessor also used by other native speech-to-text engines, other speech-to-text plugins also benefit from them - e.g. if you use assistant.vosk for full on-device detection. Responses and context: the openai plugin The transcribed phrase is processed by the openai plugin, which handles both the API key and the conversation

自适应噪声基准:背景噪声水平会随时间进行跟踪,且不高于噪声基准因子(默认 2.0,约 6 dB)倍数的帧永远不会被视为语音。在合成基准测试(Piper 生成的短语混合了嘈杂声和突发噪音)中,旧设置在语音结束后仍会将对话保持 6-10 秒;新管道在最后一个单词后 1.0-1.6 秒结束对话,即配置的 conversation_end_timeout 加上平滑延迟。由于 Platypush 上的更改是直接在其他原生语音转文字引擎也使用的 AudioPreprocessor 中执行的,因此其他语音转文字插件也从中受益——例如,如果您使用 assistant.vosk 进行完全设备端检测。响应与上下文:openai 插件。转录的短语由 openai 插件处理,该插件同时处理 API 密钥和对话。