auditok.io.PyAudioSource
- class auditok.io.PyAudioSource(sampling_rate=16000, sample_width=2, channels=1, frames_per_buffer=1024, input_device_index=None)[source]
An AudioSource class for reading data from a built-in microphone using PyAudio.
This class leverages PyAudio (https://people.csail.mit.edu/hubert/pyaudio/) to capture audio data directly from a microphone.
- Parameters:
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 each audio sample. Accepted values are 1, 2, or 4.
channels (int, optional, default=1) – The number of audio channels.
frames_per_buffer (int, optional, default=1024) – The number of frames per buffer, as specified by PyAudio.
input_device_index (int or None, optional, default=None) – The PyAudio index of the audio device to read from. If None, the default audio device is used.
- __init__(sampling_rate=16000, sample_width=2, channels=1, frames_per_buffer=1024, input_device_index=None)[source]
Methods
__init__([sampling_rate, sample_width, ...])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.
Attributes
chNumber of channels in audio stream (alias for channels).
channelsNumber of channels in audio stream.
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).