Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
from transformers import pipeline
|
2 |
import streamlit as st
|
3 |
from st_audiorec import st_audiorec
|
@@ -16,12 +17,35 @@ def make_text(audio):
|
|
16 |
|
17 |
st.title('speech recognition')
|
18 |
with st.form(key='record audio'):
|
|
|
|
|
19 |
wave_audio_data=st_audiorec()
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
button=st.form_submit_button(label='Convert to Text')
|
|
|
21 |
if button:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
|
|
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
26 |
else:
|
27 |
-
st.success('No Audio data yet')
|
|
|
|
1 |
+
|
2 |
from transformers import pipeline
|
3 |
import streamlit as st
|
4 |
from st_audiorec import st_audiorec
|
|
|
17 |
|
18 |
st.title('speech recognition')
|
19 |
with st.form(key='record audio'):
|
20 |
+
|
21 |
+
#Record an Audio
|
22 |
wave_audio_data=st_audiorec()
|
23 |
+
|
24 |
+
#or upload an audio file
|
25 |
+
st.write('Or you can upload an audio file')
|
26 |
+
upload=st.file_uploader(label='Upload audio file')
|
27 |
+
|
28 |
+
#submit
|
29 |
button=st.form_submit_button(label='Convert to Text')
|
30 |
+
#if the submit button is pressed
|
31 |
if button:
|
32 |
+
try:
|
33 |
+
#check if audio file
|
34 |
+
if wave_audio_data is not None:
|
35 |
+
#do the conversion
|
36 |
+
text=make_text(wave_audio_data)
|
37 |
+
|
38 |
+
st.write(text)
|
39 |
|
40 |
+
elif upload is not None:
|
41 |
+
text=make_text(upload)
|
42 |
|
43 |
+
st.write(text)
|
44 |
+
|
45 |
+
else:
|
46 |
+
st.error('Please record an audio', icon='🚨')
|
47 |
+
except:
|
48 |
+
st.write("we can't process your request at this time")
|
49 |
else:
|
50 |
+
st.success('No Audio data yet')
|
51 |
+
|