Junr-syl commited on
Commit
c8638c6
β€’
1 Parent(s): 9528165

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -30
app.py CHANGED
@@ -16,36 +16,58 @@ def make_text(audio):
16
  return extract_text
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
 
 
16
  return extract_text
17
 
18
  st.title('speech recognition')
19
+ col1,col2=st.columns(2)
20
+ with col1:
21
+ with st.form(key='record audio'):
22
+
23
+ #Record an Audio
24
+ wave_audio_data=st_audiorec()
25
+
26
+ #or upload an audio file
27
+ st.write('Or you can upload an audio file')
28
+ upload=st.file_uploader(label='Upload audio file')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
+ #submit
31
+ button=st.form_submit_button(label='Convert to Text')
32
+ #if the submit button is pressed
33
+ if button:
34
+ try:
35
+ #check if audio file
36
+ if wave_audio_data is not None:
37
+ #do the conversion
38
+ text=make_text(wave_audio_data)
39
+
40
+ st.write(text)
41
+
42
+ else:
43
+ st.error('Please record an audio', icon='🚨')
44
+ except:
45
+ st.write("we can't process your request at this time")
46
+ else:
47
+ st.success('No Audio data yet')
48
+
49
+ with col2:
50
+ with st.form(key='file upload '):
51
+ #or upload an audio file
52
+ st.write('Or you can upload an audio file')
53
+
54
+ upload=st.file_uploader(label='Upload audio file')
55
+
56
+ #submit
57
+ button=st.form_submit_button(label='Convert to Text')
58
+ #if the submit button is pressed
59
+ if button:
60
+ try:
61
+ if upload is not None:
62
+ text=make_text(upload)
63
+
64
+ st.write(text)
65
+
66
+ else:
67
+ st.error('Please record an audio', icon='🚨')
68
+ except:
69
+ st.write("we can't process your request at this time")
70
  else:
71
+ st.success('No Audio data yet')
72
+
 
 
 
73