File size: 772 Bytes
9b86a45
ac0462b
b2f496e
3b5f1fa
 
 
 
 
 
 
 
 
 
b2f496e
7b09059
00c3087
 
 
 
 
 
3b5f1fa
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
}