Luigi commited on
Commit
fbf03ad
·
1 Parent(s): af2d743

Fix Whisper transcription: save bytes to file before processing

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -113,8 +113,17 @@ def transcribe_audio_whisper(audio_file):
113
  # Load Whisper model (will be done on GPU)
114
  model = whisper.load_model("small")
115
 
 
 
 
 
 
 
116
  # Transcribe the audio
117
- result = model.transcribe(audio_file)
 
 
 
118
 
119
  return result["text"].strip()
120
 
 
113
  # Load Whisper model (will be done on GPU)
114
  model = whisper.load_model("small")
115
 
116
+ # Save uploaded audio to temporary file for processing
117
+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_audio:
118
+ temp_audio_path = temp_audio.name
119
+ with open(temp_audio_path, "wb") as f:
120
+ f.write(audio_file)
121
+
122
  # Transcribe the audio
123
+ result = model.transcribe(temp_audio_path)
124
+
125
+ # Clean up temporary file
126
+ os.unlink(temp_audio_path)
127
 
128
  return result["text"].strip()
129