LVKinyanjui commited on
Commit
d5eba79
β€’
1 Parent(s): d7d7ec2

Wrote a fix for audio file upload parse errors

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import streamlit as st
 
2
 
3
  st.write("## Whisper Speech to Text 🎧")
4
 
@@ -36,10 +37,15 @@ def transcribe(_pipe, sample):
36
  return result["text"]
37
 
38
 
39
- file = st.file_uploader("Upload your Audio Here")
40
 
41
  model = load_model()
42
  if st.button("Transcribe"):
43
- st.write("Transcribing ... ")
44
- transcript = transcribe(model, file)
45
- transcript # MAGIC!
 
 
 
 
 
 
1
  import streamlit as st
2
+ from tempfile import NamedTemporaryFile
3
 
4
  st.write("## Whisper Speech to Text 🎧")
5
 
 
37
  return result["text"]
38
 
39
 
40
+ audio = st.file_uploader("Upload your Audio Here")
41
 
42
  model = load_model()
43
  if st.button("Transcribe"):
44
+ if audio is not None:
45
+ st.write("Transcribing ... ")
46
+
47
+ with NamedTemporaryFile(suffix="mp3") as temp:
48
+ temp.write(audio.getvalue())
49
+ temp.seek(0)
50
+ transcript = transcribe(model, temp.name)
51
+ transcript # MAGIC!