Streaming Speech to Text on SL2610-Series
Complete the Getting Started with SL2610 guide first. It covers setting up your board, cloning the examples, and creating the Python environment. Activate the environment with source .venv/bin/activate in each new terminal.
The basic Speech to Text example waits for you to finish a phrase before it shows the text. In this guide the transcript updates while you talk, word by word, and the app can revise recent words as more audio arrives. This is how live captions work.
It uses the Moonshine V2 Streaming model (tiny, English), split into an encoder and a decoder that both run on the Torq NPU. A voice activity detector decides where each utterance starts and ends.
For details about the Moonshine Streaming model and how to convert it to run on Torq, check out the blog Real-time Speech Recognition on SL2610-Series.
Run Streaming Speech to Text on Astra
Hardware
Attach a USB microphone to the board. Connect from a PC using ADB or SSH, or connect a display and USB keyboard and open a terminal directly.
Install the example-specific dependencies, the PortAudio libraries for microphone input, and download the model:
cd speech_to_text_streaming
pip install -r requirements.txt
../setup/install_portaudio.sh
python setup_demo.py
The model is saved in models/Synaptics/moonshine-streaming-tiny-torq/ and is pinned to the v2.1.0 release. To use another release, run python setup_demo.py --moonshine-models streaming-tiny-en:<version>.
Streaming transcription on the edge
python run_cli.py
The app lists the audio input devices and asks you to pick one. Press Enter for the system default, or skip the prompt with --device <N>. Then start speaking. Words appear as they are recognized and settle once the model is confident. Press Ctrl+C to exit.
python run_cli.py --list-devices
python run_cli.py -m ../models/Synaptics/moonshine-streaming-tiny-torq --device 1
Transcribe a WAV file
You can test without a microphone. The file goes through the same pipeline and the app exits when it is done:
python run_cli.py -m ../models/Synaptics/moonshine-streaming-tiny-torq --wav ../samples/sample.wav
Add --realtime to play the file at its real speed and watch the live preview update as it would from a microphone.
Tune the voice activity detector
Transcription quality depends heavily on where utterances are split, and the defaults are only a starting point.
--vad-silence(default 2.5 s) is how long a pause must last before an utterance ends. Raise it if the output is fragmented, lower it if sentences merge or the transcript lags.--vad-thresholdis the speech level. Raise it in a noisy room, lower it for a quiet microphone.--vad-lookbackhelps if the beginnings of words are clipped.--vad-backend sileroswitches from the default energy detector to the Silero neural detector, which handles uneven background noise better.
python run_cli.py -m ../models/Synaptics/moonshine-streaming-tiny-torq --vad-backend silero
How it works
Audio is captured in 80 ms chunks at 16 kHz. While you speak, each chunk goes through the encoder, which grows a cross-attention memory of the audio so far (up to about 8 seconds). Every few chunks, and again when you stop speaking, the decoder produces tokens from that memory.
Two ideas keep this fast on the board:
- Resume instead of restart. The decoder continues from the words already committed instead of decoding the whole utterance again, so each preview costs only the new tail.
- Commit rules. A word is frozen on screen only when the last few decodes agree on it and it is at least three seconds behind the live audio. Committed text never rewrites itself.
The decoder keeps its attention tensors on the NPU between steps, so only the small logits are copied back each step.
Profiling
--profile records per-chunk timing and prints whether the app keeps up with real time:
python run_cli.py -m ../models/Synaptics/moonshine-streaming-tiny-torq --wav ../samples/sample.wav --profile
pip install matplotlib
python plot_profile.py
Plots are written to profile_results/plots/.
Models
This tutorial uses the following pre-compiled model for the SL2610-Series. See the model page for details, performance and download links:
Browse all models on the Models page.
Python walkthrough
run_cli.py, the app: microphone capture, VAD, worker thread, decoding triggers and terminal displayvad.py, the energy and Silero voice activity detectorssetup_demo.py, downloads and verifies the model filesprofiling.pyandplot_profile.py, timing capture and plots
Review these files to learn more.
Citations
- Useful Sensors, "Moonshine: On-Device Speech Recognition", 2024. https://github.com/usefulsensors/moonshine
- Silero Team, "Silero VAD: Voice Activity Detection", 2021. https://github.com/snakers4/silero-vad
