#229·moonshine

Concurrent streams share one Silero VAD instance and corrupt each other's speech detection

Author: pixistCreated Sep 25, 2026Updated Sep 25, 2026

Summary

All transcription streams in a process share one Silero VAD instance, and that instance keeps recurrent state (_state, _context) between predict() calls. When two streams are fed at the same time, each stream's VAD runs on state left behind by the other, so speech detection on one stream gets corrupted by the other stream's audio. It happens whether the streams belong to one transcriber or to two separate transcribers.

Where

The vad_mutex makes the calls thread-safe, but it doesn't separate the state, so the problem shows up even on a single thread that alternates between streams.

How we hit it

We transcribe a two-person dialog live as two streams, one per speaker: the local mic and the far side (system audio), both English Medium Streaming, fed in real time in ~10–20 ms chunks from one thread. The mic is quiet (speech around −55 dBFS RMS) and the far side is loud (around −20 dBFS).

  • Mic stream alone, same audio, same chunking: 11 of 11 lines, each final about 1 s after the speech ends.
  • Mic stream next to the far-side stream: 1 of 11 lines over a one-minute recording. Most of the mic speech is never segmented.
  • Same result with one transcriber and two streams, and with two transcribers and one stream each.
  • Feeding each stream 0.5–1 s blocks instead of small chunks, to cut down the interleaving, didn't fix it; the output came out garbled.
  • With two streams of equally loud speech the effect showed up as latency instead: a 10 s line finished 3–17 s after the speech ended, against about 1 s for either stream alone.
  • Running each stream in its own process (so each has its own static silero_vad) fixes everything: 11 of 11 lines, about 1 s latency on both sides.

Environment: prebuilt moonshine-voice-macos-arm64.tar.gz from v0.1.5 (static libmoonshine.a), C API, macOS 27 on an Apple M4, English Medium Streaming model (quantized_26_08_21).

Repro outline

  1. Load a streaming transcriber and create two streams (or load two transcribers with one stream each).
  2. Start both. In a loop, add ~20 ms of loud speech to stream A and ~20 ms of quiet speech to stream B, then call moonshine_transcribe_stream on each.
  3. Compare stream B's lines with the same audio fed to a stream on its own: most of B's speech never becomes a line.

Suggested fix

Keep one SileroVad per stream, or keep the ONNX session shared but move _state and _context into the per-stream VoiceActivityDetector and pass them into predict(). The session itself is stateless, so sharing it is fine; only the recurrent state has to be per stream.

Our workaround for now is one worker process per stream.