AudioRecorder

Allows recording audio in Flet apps.

Platform Support

| Platform | Windows | macOS | Linux | iOS | Android | Web | |---|---|---|---|---|---|---| | Supported | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |

Installation

Add flet-audio-recorder to project dependencies:

uv add flet-audio-recorder

or

pip install flet-audio-recorder

**Note:** For Linux, fmedia must be installed separately.

Description

Inherits from flet.Service. Provides functionality to record audio with configurable parameters.

Properties

  • **configuration**: AudioRecorderConfiguration
  • * The default configuration for the audio recorder.

    Events

  • **on_state_change**: EventHandler[AudioRecorderStateChangeEvent] | None
  • * Called when the audio recorder's state changes.

    Methods

  • **cancel_recording()** (async)
  • * Cancels the current audio recording.

  • **get_input_devices()** (async) -> list[InputDevice]
  • * Retrieves a list of available audio input devices.

  • **has_permission()** (async) -> bool
  • * Checks if the application has permission to record audio.

  • **is_paused()** (async) -> bool
  • * Returns True if the recorder is currently paused, False otherwise.

  • **is_recording()** (async) -> bool
  • * Returns True if the recorder is currently recording, False otherwise.

  • **is_supported_encoder(encoder: AudioEncoder)** (async) -> bool
  • * Checks if a specific audio encoder is supported.

  • **pause_recording()** (async)
  • * Pauses the ongoing audio recording.

  • **resume_recording()** (async)
  • * Resumes a paused audio recording.

  • **start_recording(output_path: str | None = None, configuration: AudioRecorderConfiguration | None = None)** (async) -> bool
  • * Starts recording audio. * output_path: Required on non-web platforms. Path to save the audio file. * configuration: Optional. Overrides the default configuration. * Returns True if started successfully, False otherwise. * Raises ValueError if output_path is missing on non-web.

  • **stop_recording()** (async) -> str | None
  • * Stops the audio recording. * Returns the path to the saved audio file or None.