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
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 millisecondsthreshold(optional, default: -60): Audio level threshold for speech detection in dBsilenceTimeout(optional, default: 1500): Time in milliseconds to wait after silence before stopping recordingplay(optional, default: False): Whether to play the audio during recording
Demo
Check out the demo video showing the component in action:
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:
- The microphone starts recording
- When you stop speaking (silence is detected), the recording automatically stops after a configurable timeout
- 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamlit_realtime_audio_recorder-0.1.1.tar.gz.
File metadata
- Download URL: streamlit_realtime_audio_recorder-0.1.1.tar.gz
- Upload date:
- Size: 5.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64676fdb39aa82673385e3c9b326e0eef83502f6e4fca7590584b1af4192db5c
|
|
| MD5 |
4c0b254dd05fc204b4d96b78421c4459
|
|
| BLAKE2b-256 |
dcf4fdbadb5abcf45bee70a4ca715188d9c9043140f14abfbf532f1540c32d8f
|
File details
Details for the file streamlit_realtime_audio_recorder-0.1.1-py3-none-any.whl.
File metadata
- Download URL: streamlit_realtime_audio_recorder-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c14e9a6edf81040ef2397d76beed2160f698e5253546f534e861d22a1a417213
|
|
| MD5 |
07c3fd0ce06701a85f9da844d91ee37d
|
|
| BLAKE2b-256 |
c38ae6856264cf3b820d6a78b12fc638d74f18636fde1a3cf9f7deabaaf18ba9
|