Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,25 @@
|
|
1 |
import streamlit as st
|
2 |
-
from
|
3 |
-
from bokeh.models import CustomJS
|
4 |
-
from streamlit_bokeh_events import streamlit_bokeh_events
|
5 |
|
6 |
-
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
recognition.continuous = true;
|
11 |
-
recognition.interimResults = true;
|
12 |
-
|
13 |
-
recognition.onresult = function (e) {
|
14 |
-
var value = "";
|
15 |
-
for (var i = e.resultIndex; i < e.results.length; ++i) {
|
16 |
-
if (e.results[i].isFinal) {
|
17 |
-
value += e.results[i][0].transcript;
|
18 |
-
}
|
19 |
-
}
|
20 |
-
if ( value != "") {
|
21 |
-
document.dispatchEvent(new CustomEvent("GET_TEXT", {detail: value}));
|
22 |
-
}
|
23 |
-
}
|
24 |
-
recognition.start();
|
25 |
-
"""))
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
override_height=75,
|
33 |
-
debounce_time=0)
|
34 |
|
35 |
-
if
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from streamlit_mic_recorder import mic_recorder,speech_to_text
|
|
|
|
|
3 |
|
4 |
+
state=st.session_state
|
5 |
|
6 |
+
if 'text_received' not in state:
|
7 |
+
state.text_received=[]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
c1,c2=st.columns(2)
|
10 |
+
with c1:
|
11 |
+
st.write("Convert speech to text:")
|
12 |
+
with c2:
|
13 |
+
text=speech_to_text(language='en',use_container_width=True,just_once=True,key='STT')
|
|
|
|
|
14 |
|
15 |
+
if text:
|
16 |
+
state.text_received.append(text)
|
17 |
+
|
18 |
+
for text in state.text_received:
|
19 |
+
st.text(text)
|
20 |
+
|
21 |
+
st.write("Record your voice, and play the recorded audio:")
|
22 |
+
audio=mic_recorder(start_prompt="⏺️",stop_prompt="⏹️",key='recorder')
|
23 |
+
|
24 |
+
if audio:
|
25 |
+
st.audio(audio['bytes'])
|