Skip to main content

A Streamlit component that records audio with real-time silence detection

Project description

Streamlit Realtime Audio Recorder

A Streamlit component that records audio in real-time and automatically stops recording after a configurable silence period.

Installation

pip install streamlit-realtime-audio-recorder

Usage

import streamlit as st
from streamlit_realtime_audio_recorder import audio_recorder

# Basic usage
result = audio_recorder()

# With custom parameters
result = audio_recorder(
    interval=50,      # How often to check audio level in ms
    threshold=-60,    # Audio level threshold for speech detection
    silenceTimeout=20000  # Time in ms to wait after silence before stopping recording
)

# Process the recorded audio
if result:
    if "audioData" in result:
        # Process audio data
        audio_data = result["audioData"]
        # You can save this as a file, process it, etc.
        
    if "status" in result:
        st.write(f"Recording status: {result['status']}")
        
    if "error" in result:
        st.error(f"Error: {result['error']}")

Parameters

  • interval (optional, default: 50): How often to check audio level in milliseconds
  • threshold (optional, default: -60): Audio level threshold for speech detection in dB
  • silenceTimeout (optional, default: 1500): Time in milliseconds to wait after silence before stopping recording
  • play (optional, default: False): Whether to play the audio during recording

Example App

import streamlit as st
import base64
from streamlit_realtime_audio_recorder import audio_recorder

st.title("Audio Recorder Example")

result = audio_recorder(
    interval=50,
    threshold=-60,
    silenceTimeout=2000
)

if result:
    if "audioData" in result:
        st.audio(data=base64.b64decode(result["audioData"]), format="audio/webm")
    
    if "error" in result:
        st.error(f"Error: {result['error']}")

License

MIT

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

streamlit_realtime_audio_recorder-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file streamlit_realtime_audio_recorder-0.1.0.tar.gz.

File metadata

File hashes

Hashes for streamlit_realtime_audio_recorder-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a436585b4a8b829aec36c5b04efd856510066890307f8b2cba8269ec67f33b6b
MD5 30fa23284daeb584c09439ce2e139454
BLAKE2b-256 43c5164e9cb3d1d727b17d4e165f68309c00e0ef2e1b8e3a96240052c0c58483

See more details on using hashes here.

File details

Details for the file streamlit_realtime_audio_recorder-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_realtime_audio_recorder-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45081a5bf6f24afceca29ba02876d95c7e8842311fec1d683608f58ed29b1727
MD5 9bdf88a651ae3a67a674f2fb69fcc505
BLAKE2b-256 3a529a465a58e827de7981eaaf7711f76630bdd37937069ada0a024dab8929c0

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