Junr-syl commited on
Commit
bf5d300
1 Parent(s): 835ac33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -3,16 +3,20 @@ from torch import *
3
  from transformers import pipeline
4
  import streamlit as st
5
  from st_audiorec import st_audiorec
6
-
7
- pipe=pipeline("automatic-speech-recognition","distil-whisper/distil-large-v2")
 
 
 
 
8
 
9
  st.title('speech recognition')
10
  wave_audio_data=st_audiorec()
11
- if wave_audio_data is None:
12
 
13
  audio_input=st.audio(wave_audio_data,format="audio/wave")
 
14
 
15
- text=pipe(audio_input)
16
  st.write(text)
17
  else:
18
  st.error('No Audio data')
 
3
  from transformers import pipeline
4
  import streamlit as st
5
  from st_audiorec import st_audiorec
6
+ @st.cache
7
+ def make_text(audio):
8
+ pipe=pipeline("automatic-speech-recognition","distil-whisper/distil-large-v2")
9
+ text= pipe(audio)
10
+ extract_text=text['text']
11
+ return extract_text
12
 
13
  st.title('speech recognition')
14
  wave_audio_data=st_audiorec()
15
+ if wave_audio_data is not None:
16
 
17
  audio_input=st.audio(wave_audio_data,format="audio/wave")
18
+ text=make_text(audio_input)
19
 
 
20
  st.write(text)
21
  else:
22
  st.error('No Audio data')