AudioSink
Sub classes¶
| Name | Children | Inherits |
|---|---|---|
| SoundDeviceSink anyvoice.sinks Audio sink that plays PCM audio through the system speakers. |
||
| FileSink anyvoice.sinks Audio sink that writes PCM audio to a WAV file. |
||
| CallbackSink anyvoice.sinks Audio sink that passes audio chunks to a user-provided callback. |
Base classes¶
| Name | Children | Inherits |
|---|---|---|
| ABC abc Helper class that provides a standard way to create an ABC using |
⋔ Inheritance diagram¶
graph TD
3407701203["base.AudioSink"]
925645236["abc.ABC"]
2751680898["builtins.object"]
925645236 --> 3407701203
2751680898 --> 925645236
🛈 DocStrings¶
Bases: ABC
Abstract base class for audio output backends.
Audio sinks receive PCM audio chunks and handle output (playback, file writing, etc.).
Usage as context manager
async with SoundDeviceSink() as sink: await sink.write(audio_chunk)
Source code in src/anyvoice/base.py
__aenter__
async
¶
__aexit__
async
¶
__aexit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) -> None
Exit the sink context, finalize and cleanup.
write
abstractmethod
async
¶
Write a PCM audio chunk to the sink.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
bytes
|
Raw PCM audio data (16-bit signed, mono). |
required |