Expand description
Audio bridging for the hardware session: Opus <-> PCM and PCM <-> WAV.
The rest of Core speaks WAV/PCM (whisper transcribe, OuteTTS synth), while the device link speaks Opus (PROTOCOL.md §2):
- Uplink mic: Opus, mono, 16 kHz, 60 ms frames (960 samples/frame).
- Downlink TTS: Opus, mono, 24 kHz, 60 ms frames (1440 samples/frame).
This module owns the codec edges so super::session only ever deals in
decoded PCM / WAV bytes. Opus runs through audiopus (which vendors libopus
via audiopus_sys, so no system libopus is required); WAV read/write runs
through hound.
Structs§
- Decoded
Wav - Parsed PCM from a WAV blob (mono i16 at its native rate). Returned by
wav_to_pcm16so the TTS WAV produced by OuteTTS can be re-encoded as Opus. - Downlink
Encoder - Opus encoder for the 24 kHz mono TTS downlink. One per TTS stream.
- Uplink
Decoder - Opus decoder for the 16 kHz mono mic uplink. One per session (Opus decoder state is stateful across frames).
Constants§
- DOWNLINK_
RATE - TTS downlink sample rate (Hz).
- FRAME_
MS - Frame duration in milliseconds (both directions).
- UPLINK_
RATE - Mic uplink sample rate (Hz).
Functions§
- pcm16_
to_ wav - Wrap 16 kHz mono PCM (i16) as a RIFF/WAV byte blob for the whisper/meetings
transcribe path, which takes WAV
filebytes. - resample_
to - Linear-interpolation resampler to the 24 kHz Opus downlink rate. OuteTTS
already emits 24 kHz mono, so this is a near-no-op fast path when rates match;
it exists so a different TTS engine (a
?engine=sidecar at another rate) still produces a correctly-pitched downlink rather than a chipmunk artifact. - wav_
to_ pcm16 - Decode a WAV blob to mono i16 PCM. Down-mixes any multi-channel input and converts float samples to i16. The sample rate is read from the header so the caller can resample to the 24 kHz Opus downlink as needed.