Voice/AI · voice
Portal Voice — Speech Interaction Pipeline
Complete voice interaction layer: wake word detection, VAD (Silero on QNN DSP), STT (Sherpa-onnx Zipformer on CPU), NLU (MiniLM sentence similarity), TTS (Elara VITS on QNN DSP), and voice state machine. Hosts portal-voiced daemon.
Architecture
Overview
portal-voice implements the full voice interaction pipeline for Portal. Audio arrives from the glasses' microphone via UDP (:5601), gets denoised by RNNoise, then processed by a VAD (Voice Activity Detection) running on the QNN DSP (Silero model). When speech is detected, Sherpa-onnx Zipformer performs STT (Speech-to-Text) on CPU. The transcript is classified by a MiniLM NLU (Natural Language Understanding) classifier using sentence similarity against 28 intent categories. Based on the classified intent, the system either executes a system command, launches an app via gtk-launch, queries the LLM via IPC, or produces a canned response. Responses are synthesized via Elara VITS TTS (encoder on QNN DSP, decoder via onnxruntime-qnn plugin), resampled to 48kHz, and streamed back to the glasses via RTP/UDP.
Key Types
Modules
vad
Voice Activity Detection — Silero VAD model on QNN DSP (Hexagon). Detects speech segments in audio stream.
stt
Speech-to-Text — Sherpa-onnx Zipformer model on CPU (A76/Oryon cores). Streaming transcription of detected speech.
nlu
Natural Language Understanding — MiniLM sentence similarity classifier. 28 intents, cosine similarity matching, slot extraction.
tts
Text-to-Speech — Elara VITS engine. Encoder on QNN DSP, decoder via onnxruntime-qnn. 22050Hz output, resampled to 48kHz for glasses.
wake_word
Wake word detection — listens for activation phrase before starting full pipeline.
preprocessing
Audio preprocessing — RNNoise denoising, format conversion, sample rate adjustment.
audio_io
Audio I/O — UDP audio reception from glasses (:5601), RTP audio transmission to glasses (:5002).
mic_controller
Microphone controller — manages audio capture, noise gate, automatic gain control.
npu_backend
NPU backend abstraction — QNN model loading, context management, tensor I/O.
npu_scheduler
NPU scheduler — arbitrates DSP access between VAD, TTS encoder, and LLM to prevent context conflicts.
voice_state
Voice state machine — Idle/Listening/Processing/Speaking transitions, mic control coordination.
tts_arbitration
TTS arbitration — prevents overlapping speech, queues responses, handles interruption.
clarification
Clarification handler — asks follow-up questions when NLU confidence is low or slots are missing.
address_detection
Address detection — determines if user is addressing Portal ('Hey Elara') vs. talking to someone else.
error_recovery
Error recovery — handles NPU failures, model reload, graceful degradation.
subprocess_integrity
Subprocess integrity — validates GenieX Python subprocess health, restarts on crash.
telemetry
Telemetry — latency tracking, classification accuracy, RTF (Real-Time Factor) measurement.
Data Flow
Glasses → UDP audio (:5601) → RNNoise → VAD (QNN DSP) → Sherpa STT (CPU) → MiniLM NLU → [SystemCommand|LaunchApp|LLM IPC|canned] → TTS encoder (QNN DSP) → TTS decoder (onnxruntime-qnn) → RTP → glasses (:5002)
Dependencies
External (21)
External: sherpa-onnx (STT), ort/onnxruntime (NLU/TTS decoder), tokenizers (MiniLM). NPU: QNN SDK (.so models), rnnoise-sys, qnn-sys. Build: cargo build --features 'qnn-tts,qnn-vad,npu-stt,network-audio,nlu-minilm' --bin portal-voiced