auditok.io¶
Module for low-level audio input-output operations.
Class summary¶
AudioSource([sampling_rate, sample_width, ...]) | Base class for audio source objects. |
Rewindable | Base class for rewindable audio streams. |
BufferAudioSource(data_buffer[, ...]) | An AudioSource that encapsulates and reads data from a memory buffer. |
WaveAudioSource(filename) | A class for an AudioSource that reads data from a wave file. |
PyAudioSource([sampling_rate, sample_width, ...]) | A class for an AudioSource that reads data the built-in microphone using PyAudio. |
StdinAudioSource([sampling_rate, ...]) | A class for an AudioSource that reads data from standard input. |
PyAudioPlayer([sampling_rate, sample_width, ...]) | A class for audio playback using Pyaudio |
Function summary¶
from_file(filename) | Create an AudioSource object using the audio file specified by filename. |
player_for(audio_source) | Return a PyAudioPlayer that can play data from audio_source. |
- class auditok.io.AudioSource(sampling_rate=16000, sample_width=2, channels=1)[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 stream. Default = 16000.
- sample_width : int
Size in bytes of one audio sample. Possible values : 1, 2, 4. Default = 2.
- channels : int
Number of channels of audio stream. The current version supports only mono audio streams (i.e. one channel).
- class auditok.io.Rewindable[source]¶
Base class for rewindable audio streams. Subclasses should implement methods to return to the beginning of an audio stream as well as method to move to an absolute audio position expressed in time or in number of samples.
- class auditok.io.BufferAudioSource(data_buffer, sampling_rate=16000, sample_width=2, channels=1)[source]¶
An AudioSource that encapsulates and reads data from a memory buffer. It implements methods from Rewindable and is therefore a navigable AudioSource.
- class auditok.io.WaveAudioSource(filename)[source]¶
A class for an AudioSource that reads data from a wave file.
Parameters: - filename :
path to a valid wave file
- class auditok.io.PyAudioSource(sampling_rate=16000, sample_width=2, channels=1, frames_per_buffer=1024)[source]¶
A class for an AudioSource that reads data the built-in microphone using PyAudio.
- class auditok.io.StdinAudioSource(sampling_rate=16000, sample_width=2, channels=1)[source]¶
A class for an AudioSource that reads data from standard input.
- class auditok.io.PyAudioPlayer(sampling_rate=16000, sample_width=2, channels=1)[source]¶
A class for audio playback using Pyaudio
- auditok.io.from_file(filename)[source]¶
Create an AudioSource object using the audio file specified by filename. The appropriate AudioSource class is guessed from file’s extension.
Parameters: - filename :
path to an audio file.
Returns: an AudioSource object that reads data from the given file.
- auditok.io.player_for(audio_source)[source]¶
Return a PyAudioPlayer that can play data from audio_source.
Parameters: - audio_source :
an AudioSource object.
Returns: PyAudioPlayer that has the same sampling rate, sample width and number of channels as audio_source.