Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from streamlit_mic_recorder import mic_recorder,speech_to_text | |
| audio=mic_recorder( | |
| start_prompt="Start recording", | |
| stop_prompt="Stop recording", | |
| just_once=False, | |
| use_container_width=False, | |
| callback=None, | |
| args=(), | |
| kwargs={}, | |
| key=None | |
| ) | |
| def callback(): | |
| if st.session_state.my_recorder_output: | |
| audio_bytes=st.session_state.my_recorder_output['bytes'] | |
| st.audio(audio_bytes) | |
| mic_recorder(key='my_recorder', callback=callback) | |
| { | |
| "bytes":audio_bytes, # wav audio bytes mono signal, can be processed directly by st.audio | |
| "sample_rate":sample_rate, # depends on your browser's audio configuration | |
| "sample_width":sample_width, # 2 | |
| "id": id # A unique timestamp identifier of the audio | |
| } |