CallbackSink
Base classes¶
| Name | Children | Inherits |
|---|---|---|
| AudioSink anyvoice.base Abstract base class for audio output backends. |
⋔ Inheritance diagram¶
graph TD
427671724["sinks.CallbackSink"]
3407701203["base.AudioSink"]
925645236["abc.ABC"]
2751680898["builtins.object"]
3407701203 --> 427671724
925645236 --> 3407701203
2751680898 --> 925645236
🛈 DocStrings¶
Bases: AudioSink
Audio sink that passes audio chunks to a user-provided callback.
Useful for custom audio processing, streaming, or integration with other systems.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[bytes], Awaitable[None]] | Callable[[bytes], None]
|
Async or sync callable that receives audio chunks. |
required |
on_close
|
Callable[[], Awaitable[None]] | Callable[[], None] | None
|
Optional callback invoked when sink closes. |
None
|
Source code in src/anyvoice/sinks.py
__aexit__
async
¶
__aexit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) -> None
Invoke close callback if provided.
Source code in src/anyvoice/sinks.py
write
async
¶
Pass audio chunk to the callback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chunk
|
bytes
|
PCM audio data. |
required |