streamlit-audiorecorder
streamlit-audiorecorder copied to clipboard
[Feature Request] Add callback for recording start/stop events
Current Behavior
The audiorecorder() function only returns the recorded audio after stopping, without providing any way to detect when recording starts or stops.
Use Case
When starting a new recording, I need to perform some actions (like stopping currently playing audio) right at the moment when user clicks the start button. However, since audiorecorder() is blocking until recording finishes, there's no way to hook into these events.
Desired Solution It would be helpful if the component could accept callbacks for recording events:
def on_record_start():
# Handle record start
stop_current_audio()
audio = audiorecorder(
"Start recording",
"Stop recording",
on_start=on_record_start, # Callback when recording starts
on_stop=None, # Optional callback when recording stops
key="recorder"
)
Additional Context
- This would enable better integration with other audio-related operations
- Could help prevent audio conflicts when recording starts
- Would make the component more flexible for complex use cases
Would it be possible to expose these event callbacks in a future release?
Let me know if you need any clarification. Thanks!