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 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
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
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.0.tar.gz.
File metadata
- Download URL: streamlit_realtime_audio_recorder-0.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a436585b4a8b829aec36c5b04efd856510066890307f8b2cba8269ec67f33b6b
|
|
| MD5 |
30fa23284daeb584c09439ce2e139454
|
|
| BLAKE2b-256 |
43c5164e9cb3d1d727b17d4e165f68309c00e0ef2e1b8e3a96240052c0c58483
|
File details
Details for the file streamlit_realtime_audio_recorder-0.1.0-py3-none-any.whl.
File metadata
- Download URL: streamlit_realtime_audio_recorder-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 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 |
45081a5bf6f24afceca29ba02876d95c7e8842311fec1d683608f58ed29b1727
|
|
| MD5 |
9bdf88a651ae3a67a674f2fb69fcc505
|
|
| BLAKE2b-256 |
3a529a465a58e827de7981eaaf7711f76630bdd37937069ada0a024dab8929c0
|