SoundDeviceSink
Base classes¶
| Name | Children | Inherits |
|---|---|---|
| AudioSink anyvoice.base Abstract base class for audio output backends. |
⋔ Inheritance diagram¶
graph TD
3330750070["sinks.SoundDeviceSink"]
3407701203["base.AudioSink"]
925645236["abc.ABC"]
2751680898["builtins.object"]
3407701203 --> 3330750070
925645236 --> 3407701203
2751680898 --> 925645236
🛈 DocStrings¶
Bases: AudioSink
Audio sink that plays PCM audio through the system speakers.
Uses sounddevice for real-time audio playback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_rate
|
int
|
Audio sample rate in Hz. Defaults to 24000. |
24000
|
channels
|
int
|
Number of audio channels. Defaults to 1 (mono). |
1
|
Source code in src/anyvoice/sinks.py
__aenter__
async
¶
Start the audio output stream.
Source code in src/anyvoice/sinks.py
__aexit__
async
¶
__aexit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) -> None
Stop and close the audio output stream.
Source code in src/anyvoice/sinks.py
write
async
¶
Write audio chunk to the output stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
bytes
|
PCM audio data to play. |
required |