abdullahedcults commited on
Commit
1e507fc
1 Parent(s): 21ae366

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -48,6 +48,24 @@ def main():
48
  st.write("Click the 'Start Recording' button to start recording your voice. Press 'Stop Recording' when done.")
49
  st.write("The transcribed text will be displayed below.")
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  audio_bytes = audio_recorder()
52
  if audio_bytes:
53
  st.audio(audio_bytes, format="audio/wav")
 
48
  st.write("Click the 'Start Recording' button to start recording your voice. Press 'Stop Recording' when done.")
49
  st.write("The transcribed text will be displayed below.")
50
 
51
+ uploaded_file = st.file_uploader("Upload your recording (WAV format)", type=["wav"])
52
+ if uploaded_file is not None:
53
+ with st.spinner("Transcribing and translating audio... Please wait."):
54
+ audio_path = "uploaded_audio.wav"
55
+ with open(audio_path, "wb") as f:
56
+ f.write(uploaded_file.getvalue())
57
+
58
+ result_text, translated_text = transcribe(audio_path)
59
+
60
+ st.subheader("Original Text (English):")
61
+ st.write(result_text)
62
+
63
+ st.subheader("Translated Text (Hindi):")
64
+ st.write(translated_text)
65
+
66
+ # Remove the temporary audio file
67
+ os.remove(audio_path)
68
+
69
  audio_bytes = audio_recorder()
70
  if audio_bytes:
71
  st.audio(audio_bytes, format="audio/wav")