AAhad commited on
Commit
11c3ed2
·
1 Parent(s): 4f1ea37
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -10,6 +10,7 @@ from streamlit_webrtc import webrtc_streamer, WebRtcMode, RTCConfiguration
10
  import av
11
  import queue
12
 
 
13
  # Define the models
14
  MODELS = {
15
  "Whisper (English)": "openai/whisper-small.en",
@@ -112,10 +113,11 @@ elif audio_option == 'Upload Audio':
112
  audio_file = st.file_uploader("Upload audio file (WAV format)", type=['wav'])
113
 
114
  if audio_file:
115
- # Load the audio file
116
- with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
117
- tmp_file.write(audio_file.read())
118
- tmp_file_path = tmp_file.name
 
119
 
120
  audio_data, sr = librosa.load(tmp_file_path, sr=None)
121
 
 
10
  import av
11
  import queue
12
 
13
+
14
  # Define the models
15
  MODELS = {
16
  "Whisper (English)": "openai/whisper-small.en",
 
113
  audio_file = st.file_uploader("Upload audio file (WAV format)", type=['wav'])
114
 
115
  if audio_file:
116
+
117
+ # When writing the audio data, specify the format explicitly
118
+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as tmp_file:
119
+ sf.write(tmp_file.name, audio_data, sr, format='WAV')
120
+ tmp_file_path = tmp_file.name
121
 
122
  audio_data, sr = librosa.load(tmp_file_path, sr=None)
123