Skip to main content

Dash Audio Recorder Component

Project description

Dash Audio Recorder

A professional and customizable audio recording component for Plotly Dash. This component allows users to record audio directly from their browser's microphone, visualize the audio as a waveform in real-time, and send the data back to Python for processing.

Key Features

  • Real-time Waveform: Visualize audio input as it happens.
  • Two UI Modes: Support for both a discrete small view and an immersive fullscreen recording experience.
  • Flexible Interaction: Choose between hold (Push-To-Talk) or click to toggle recording modes.
  • Memory Efficient: Sends audio data as a Base64 string directly to Dash, allowing for lightning-fast handling via dcc.Store without mandatory disk writes.
  • Customizable Formats: Specify preferred MIME types (e.g., audio/webm, audio/mp4).

Installation

Install the package via pip:

pip install dash-audio-recorder


### Quick Start
Here is a minimal example of how to use the component in a Dash application.

import dash_audio_recorder
from dash import Dash, html, Input, Output, callback

app = Dash(__name__)

app.layout = html.Div([
    html.H2("Dash Audio Recorder Demo"),
    
    dash_audio_recorder.DashAudioRecorder(
        id='audio-recorder',
        audioType='audio/webm',
        visualMode='fullscreen',  # Options: 'fullscreen', 'small'
        recordMode='hold'         # Options: 'hold', 'click'
    ),
    
    html.Div(id='output-status', style={'marginTop': '20px'}),
    html.Audio(id='audio-player', controls=True, style={'marginTop': '10px'})
])

@callback(
    Output('audio-player', 'src'),
    Output('output-status', 'children'),
    Input('audio-recorder', 'audioData')
)
def handle_audio(audio_data):
    if not audio_data:
        return "", "Waiting for recording..."
    
    # audio_data is a base64 string that can be used directly as a source
    return audio_data, "Recording received! You can play it back below:"

if __name__ == '__main__':
    app.run_server(debug=True)


### Component Properties (Props)


Prop,Type,Default,Description
id,string,None,The ID used to identify this component in Dash callbacks.
audioData,string,None,The recorded audio data as a Base64 encoded string. Read-only from Python.
audioType,string,'audio/webm',"The MIME type for the audio recording (e.g., audio/webm, audio/mp4)."
visualMode,string,'fullscreen',UI style: 'fullscreen' (overlay) or 'small' (inline block).
recordMode,string,'hold',Interaction style: 'hold' (push-to-talk) or 'click' (toggle).

### License
This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dash_audio_recorder-0.0.4.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dash_audio_recorder-0.0.4-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file dash_audio_recorder-0.0.4.tar.gz.

File metadata

  • Download URL: dash_audio_recorder-0.0.4.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for dash_audio_recorder-0.0.4.tar.gz
Algorithm Hash digest
SHA256 99cd6c39436ed87c09817ebc4f69993e00f9f40ae70c9edb98dd6133d9ebbe0a
MD5 930cec7827ccc2f3a8d8b5915df575de
BLAKE2b-256 8596c81a4af2d03cfa3285dbb98e35fb8c41540f8db3c58021482a3336bda772

See more details on using hashes here.

File details

Details for the file dash_audio_recorder-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for dash_audio_recorder-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4fc97555f136cf0181acd469a3007a01f974a188842606bfe3cc586ad6227b69
MD5 e841992d5aba3f3e8f34ea3e84ea4f18
BLAKE2b-256 6dd3f7759962a6b4119182069f86fb4b30eb736f9b8117565ef831d4ee362129

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page