auditok.io.AudioSource

class auditok.io.AudioSource(sampling_rate, sample_width, channels)[source]

Base class for audio source objects.

Subclasses should implement methods to open/close and audio stream and read the desired amount of audio samples.

Parameters:
  • sampling_rate (int) – number of samples per second of audio data.
  • sample_width (int) – size in bytes of one audio sample. Possible values: 1, 2 or 4.
  • channels (int) – number of channels of audio data.
__init__(sampling_rate, sample_width, channels)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(sampling_rate, sample_width, channels) Initialize self.
close() Close audio source.
is_open() Return True if audio source is open, False otherwise.
open() Open audio source.
read(size) Read and return size audio samples at most.

Attributes

ch Number of channels in audio stream (alias for channels).
channels Number of channels in audio stream.
sample_width Number of bytes used to represent one audio sample.
sampling_rate Number of samples per second of audio stream.
sr Number of samples per second of audio stream (alias for sampling_rate).
sw Number of bytes used to represent one audio sample (alias for sample_width).