PvRecorder
Python API
API Reference for the PvRecorder Python SDK (PyPI).
pvrecorder.PvRecorder
Class for the PvRecorder audio recorder.
PvRecorder is initialized via __init__() method.
pvrecorder.PvRecorder.is_recording
Whether the recorder is currently recording audio or not.
pvrecorder.PvRecorder.selected_device
The audio device that the given PvRecorder instance is using.
pvrecorder.PvRecorder.version
The version string of the PvRecorder library.
pvrecorder.PvRecorder.frame_length
Gets the frame length matching the value given to __init__().
pvrecorder.PvRecorder.sample_rate
The audio sample rate used by PvRecorder.
pvrecorder.PvRecorder.__init__()
__init__ method for PvRecorder.
Parameters
frame_lengthint : The length of audio frame to get for each read call.device_indexint : The index of the audio device to use. A value of (-1) will resort to default device.buffered_frames_countint : The number of audio frames buffered internally for reading - i.e. internal circular buffer will be of sizeframe_length*buffered_frames_count. If this value is too low, buffer overflows could occur audio frames could be dropped. A higher value will increase memory usage.
Returns
PvRecorder: An instance of PvRecorder.
Throws
Error: If an error occurs while creating an instance of PvRecorder.
pvrecorder.PvRecorder.delete()
Releases resources acquired by PvRecorder.
pvrecorder.PvRecorder.start()
Starts recording and buffering audio frames.
Throws
Error: If an error occurs while starting audio device.
pvrecorder.PvRecorder.stop()
Stops recording audio.
Throws
Error: If an error occurs while stopping audio device.
pvrecorder.PvRecorder.read()
Synchronous call to read a frame of audio.
Returns
int: A frame with sizeframe_lengthmatching the value given to__init__().
Throws
Error: If an error occurs while reading audio frame.
pvrecorder.PvRecorder.set_debug_logging()
Enable or disable debug logging for PvRecorder. Debug logs will indicate when there are overflows
in the internal frame buffer and when an audio source is generating frames of silence.
Parameters
is_debug_logging_enabledbool : Boolean indicating whether the debug logging is enabled or disabled.
pvrecorder.PvRecorder.get_available_devices()
Gets the list of available audio devices that can be used for recording.
Returns
List[str]: A list of strings, indicating the names of audio devices.
Throws
Error: If an error occurs while getting available devices.