auditok.io.BufferAudioSource
- class auditok.io.BufferAudioSource(data, sampling_rate=16000, sample_width=2, channels=1)[source]
An AudioSource that reads audio data from a memory buffer.
This class implements the Rewindable interface, allowing audio data stored in a buffer to be read with support for rewinding and position control.
- Parameters:
data (bytes) – The audio data stored in a memory buffer.
sampling_rate (int, optional, default=16000) – The number of samples per second of audio data.
sample_width (int, optional, default=2) – The size in bytes of one audio sample. Accepted values are 1, 2, or 4.
channels (int, optional, default=1) – The number of audio channels.
Methods
__init__(data[, sampling_rate, ...])close()Close audio source.
is_open()Return True if audio source is open, False otherwise.
open()Open audio source.
read(size)Read and return up to size audio samples.
rewind()Go back to the beginning of audio stream.
Attributes
chNumber of channels in audio stream (alias for channels).
channelsNumber of channels in audio stream.
Get raw audio data as a bytes object.
Get stream position in number of samples
Get stream position in milliseconds.
position_sReturn stream position in seconds.
sample_widthNumber of bytes used to represent one audio sample.
sampling_rateNumber of samples per second of audio stream.
srNumber of samples per second of audio stream (alias for sampling_rate).
swNumber of bytes used to represent one audio sample (alias for sample_width).