voicebox.sinks package

Submodules

voicebox.sinks.distributor module

class voicebox.sinks.distributor.Distributor(sinks: Sequence[Sink])[source]

Bases: Sink

Distributes audio to multiple sinks.

play(audio)[source]
sinks: Sequence[Sink]

voicebox.sinks.sink module

class voicebox.sinks.sink.Sink[source]

Bases: ABC

Base class for audio sinks.

abstractmethod play(audio: Audio) None[source]

voicebox.sinks.sounddevice module

class voicebox.sinks.sounddevice.SoundDevice(device: int | str = None, blocking: bool = True, latency: float | Literal['low', 'high'] = 0.1)[source]

Bases: Sink

An audio sink that uses the sounddevice library to play audio through the default audio device.

Parameters:
  • device (Device) – Device index or query string specifying the device to be used. If None (default), a device will be selected automatically. See sounddevice.query_devices() for valid choices.

  • blocking (bool) – Whether to wait for playback to finish before returning.

  • latency (float | 'low' | 'high') – The desired latency in seconds. The special values ‘low’ and ‘high’ select the device’s default low and high latency, respectively. Lower latency reduces time to playback; higher latency improves stability.

blocking: bool = True
device: int | str = None
latency: float | Literal['low', 'high'] = 0.1
play(audio: Audio) None[source]

voicebox.sinks.wavefile module

class voicebox.sinks.wavefile.WaveFile(file: IO[bytes] | str | Path, append: bool = False, sample_width: int = 2)[source]

Bases: Sink

Writes audio to a WAV file.

Parameters:
  • file (FileOrPath) – The file to write to. If a path is given, the file will be opened in write mode. If a file-like object is given, it will be written to directly.

  • append (bool) – Whether to append to an existing file. If True, the file must already exist and the sample rate must match the existing file.

  • sample_width (int) – The number of bytes to use per sample. Must be 1, 2, or 4.

append: bool = False
file: IO[bytes] | str | Path
play(audio: Audio) None[source]
sample_width: int = 2
voicebox.sinks.wavefile.write_audio_to_wav(audio: Audio, file_or_path: IO[bytes] | str | Path, append: bool = False, sample_width: int = 2) None[source]

Module contents

voicebox.sinks.default_sink() Sink[source]

Returns a new instance of the default sink, SoundDevice.