Microphone¶
Runnable example
python/examples/microphone_send.py — generates a 440 Hz / 3 s sine wave and pushes it into the virtual mic.
resoio.microphone.MicrophoneClient ¶
Bases: _BaseClient[MicrophoneStub]
Async client for the Resonite IO Microphone service over a UDS.
Use as an async context manager so the gRPC channel is closed
deterministically. The wire format is fixed at 48 kHz / Mono /
float32 LE (:data:SAMPLE_RATE, :data:CHANNELS, :data:DTYPE).
Source code in src/resoio/_client.py
stream
async
¶
Stream microphone chunks to the server and await the summary.
chunks is consumed lazily. Callers hand in plain 1-D float32
samples arrays (no dtype coercion happens here — tobytes
blindly serialises whatever buffer it gets). The client owns
frame_id (auto-incremented from 0) and stamps
:func:time.time_ns on every chunk. Raises :class:RuntimeError
if called outside async with.
Source code in src/resoio/microphone.py
resoio.microphone.MicrophoneStreamSummary
dataclass
¶
MicrophoneStreamSummary(
received_frames: int, received_samples: int, dropped_frames: int, unix_nanos: int
)
Server-side summary returned when a StreamAudio stream ends.
dropped_frames counts frames the bridge discarded on ring buffer
overflow (client outpacing engine consumption); a healthy run is 0.
resoio.microphone.paced
async
¶
paced(
chunks: AsyncIterable[NDArray[float32]], sample_rate: int = SAMPLE_RATE
) -> AsyncIterator[NDArray[np.float32]]
Yield chunks at wall-clock pace for replaying a pre-loaded buffer.
Opt-in helper for sources that hand over their whole payload at once (e.g. a WAV file): yields each ndarray, then sleeps for its natural duration before pulling the next one, so the downstream Bridge ring buffer never overflows on long inputs.
Do not wrap real-time producers (live mic, TTS streams) — they pace themselves; the extra sleep would compound into latency.