AudioRecorder
AudioRecorder
#
Bases: Service
A control that allows you to record audio from your device.
This control can record audio using different audio encoders and also allows configuration of various audio recording parameters such as noise suppression, echo cancellation, and more.
Note
This control is non-visual and should be added to Page.services
list before it can be used.
configuration: AudioRecorderConfiguration = field(default_factory=lambda: AudioRecorderConfiguration())
#
The default configuration of the audio recorder.
data: Any = skip_field()
#
Arbitrary data of any type that can be attached to a control.
key: str | int | float | bool | ValueKey | ScrollKey | None = None
#
on_state_change: ft.OptionalEventHandler[AudioRecorderStateChangeEvent[AudioRecorder]] = None
#
Event handler that is called when the state of the audio recorder changes.
Event handler argument is of type AudioRecorderStateChangeEvent
.
page: Page | PageView | None
#
The page (of type Page
or PageView
) to which this control belongs to.
parent: BaseControl | None
#
The direct ancestor(parent) of this control.
It defaults to None
and will only have a value when this control is mounted (added to the page tree).
The Page
control (which is the root of the tree) is an exception - it always has parent=None
.
cancel_recording()
#
Cancels the current audio recording.
cancel_recording_async()
#
Cancels the current audio recording.
get_input_devices_async() -> list[InputDevice]
#
Asynchronously retrieves the available input devices for recording.
RETURNS | DESCRIPTION |
---|---|
dict
|
A dictionary of available input devices.
TYPE:
|
has_permission_async() -> bool
#
Asynchronously checks if the app has permission to record audio.
RETURNS | DESCRIPTION |
---|---|
bool
|
TYPE:
|
is_paused_async() -> bool
#
Asynchronously checks whether the audio recorder is currently paused.
RETURNS | DESCRIPTION |
---|---|
bool
|
TYPE:
|
is_recording_async() -> bool
#
Asynchronously checks whether the audio recorder is currently recording.
RETURNS | DESCRIPTION |
---|---|
bool
|
TYPE:
|
is_supported_encoder_async(encoder: AudioEncoder) -> bool
#
Asynchronously checks if the given audio encoder is supported by the recorder.
PARAMETER | DESCRIPTION |
---|---|
encoder
|
The audio encoder to check.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
TYPE:
|
pause_recording()
#
Pauses the ongoing audio recording.
pause_recording_async()
#
Pauses the ongoing audio recording.
resume_recording()
#
Resumes a paused audio recording.
resume_recording_async()
#
Resumes a paused audio recording.
start_recording_async(output_path: str | None = None, configuration: AudioRecorderConfiguration | None = None) -> bool
#
Starts recording audio and saves it to the specified output path.
If not on the web, the output_path
parameter must be provided.
PARAMETER | DESCRIPTION |
---|---|
output_path
|
The file path where the audio will be saved. It must be specified if not on web.
TYPE:
|
configuration
|
The configuration for the audio recorder.
If
TYPE:
|
Returns:
bool: True
if recording was successfully started, False
otherwise.