auditok.io.BufferAudioSource¶
-
class
auditok.io.
BufferAudioSource
(data, sampling_rate=16000, sample_width=2, channels=1)[source]¶ An AudioSource that encapsulates and reads data from a memory buffer.
This class implements the Rewindable interface. :param data: audio data :type data: bytes :param sampling_rate: number of samples per second of audio data. :type sampling_rate: int, default: 16000 :param sample_width: size in bytes of one audio sample. Possible values: 1, 2 or 4. :type sample_width: int, default: 2 :param channels: number of channels of audio data. :type channels: int, default: 1
-
__init__
(data, sampling_rate=16000, sample_width=2, channels=1)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(data[, sampling_rate, …])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. rewind
()Go back to the beginning of audio stream. Attributes
ch
Number of channels in audio stream (alias for channels). channels
Number of channels in audio stream. data
Get raw audio data as a bytes object. position
Get stream position in number of samples position_ms
Get stream position in milliseconds. position_s
Return stream position in seconds. 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). -