Spaces:
Runtime error
Runtime error
File size: 699 Bytes
835ac33 24d98ad 489e5a6 bf5d300 489e5a6 bf5d300 835ac33 8b70fcd 835ac33 8b70fcd 835ac33 8b70fcd |
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 |
from transformers import pipeline
import streamlit as st
from st_audiorec import st_audiorec
@st.cache_resource
def load_model():
pipe=pipeline("automatic-speech-recognition","distil-whisper/distil-large-v2")
return pipe
speech_to_text_model=load_model()
def make_text(audio):
global speech_to_text_model
text= speech_to_text_model(audio)
extract_text=text['text']
return extract_text
st.title('speech recognition')
with st.form(key='record audio'):
wave_audio_data=st_audiorec()
button=st.form_submit_button(label='Convert to Text')
if button:
text=make_text(wave_audio_data)
st.write(text)
else:
st.success('No Audio data yet') |