Skip to main content

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

from streamlit_realtime_audio_recorder import audio_recorder
import streamlit as st
import base64
import io

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

if result:
    if result.get('status') == 'stopped':
        audio_data = result.get('audioData')
        if audio_data:
            audio_bytes = base64.b64decode(audio_data)
            audio_file = io.BytesIO(audio_bytes)
            st.audio(audio_file, format="audio/webm")
        else:
            pass
    elif result.get('error'):
            st.error(f"Error: {result.get('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

Demo

Check out the demo video showing the component in action:

Streamlit Realtime Audio Recorder Demo

How It Works

This component uses the Web Audio API and the hark library to detect speech and silence. When you click the microphone button:

  1. The microphone starts recording
  2. When you stop speaking (silence is detected), the recording automatically stops after a configurable timeout
  3. The audio data is returned as base64-encoded data that you can play, save, or process

Use Cases

  • Voice commands in Streamlit apps
  • Speech-to-text integration
  • Audio data collection
  • Voice recording with automatic silence detection

License

MIT

Metadata

Release files for streamlit-realtime-audio-recorder 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamlit-realtime-audio-recorder 0.1.2
File Size Uploaded Provenance
streamlit_realtime_audio_recorder-0.1.2.tar.gz 2.6 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for streamlit-realtime-audio-recorder 0.1.2
File Interpreter ABI Platform
streamlit_realtime_audio_recorder-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 2.6 MB

Release files / streamlit_realtime_audio_recorder-0.1.2.tar.gz

Download URL streamlit_realtime_audio_recorder-0.1.2.tar.gz
Size 2.6 MB
Tags Source
SHA-256 checksum
How to use checksums
c8e43c1948f3b6fb6eae719652de15eba77579a4a8d82d0cb01f3463f717733e
BLAKE2b-256 checksum
How to use checksums
5dda0bb050b292cf443a8432aee2d7a7770acd3f890e39844a0d06f2977a4c66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / streamlit_realtime_audio_recorder-0.1.2-py3-none-any.whl

Download URL streamlit_realtime_audio_recorder-0.1.2-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ade901db01ace24c7510a7fa94b70a2b62538fc439f88f3b38ab3e914a55b79b
BLAKE2b-256 checksum
How to use checksums
3848e8621528923c408510d786f6fa94114db4576e9afbace07ac008845f4be4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Security for streamlit-realtime-audio-recorder 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page