Shanuka01 commited on
Commit
70cc84d
·
1 Parent(s): 2bd0dd9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -5,10 +5,9 @@ import whisper
5
  model = whisper.load_model("large")
6
 
7
  def transcribe(audio_file):
8
- # The audio_file parameter is a tuple with the filename and the file object
9
- # We only need the file object which is the second element of the tuple
10
- audio_data = audio_file[1]
11
- audio = whisper.load_audio(audio_data)
12
  audio = whisper.pad_or_trim(audio)
13
  mel = whisper.log_mel_spectrogram(audio).to(model.device)
14
  options = whisper.DecodingOptions()
@@ -18,7 +17,7 @@ def transcribe(audio_file):
18
  # Create the Gradio interface
19
  iface = gr.Interface(
20
  fn=transcribe,
21
- inputs=gr.Audio(label="Upload your audio file", type="file"),
22
  outputs="text",
23
  title="Whisper ASR",
24
  description="Upload an audio file and it will be transcribed using OpenAI's Whisper model."
 
5
  model = whisper.load_model("large")
6
 
7
  def transcribe(audio_file):
8
+ # Whisper expects a filepath, so we use the 'filepath' type in gr.Audio
9
+ # audio_file now directly contains the path to the uploaded file
10
+ audio = whisper.load_audio(audio_file)
 
11
  audio = whisper.pad_or_trim(audio)
12
  mel = whisper.log_mel_spectrogram(audio).to(model.device)
13
  options = whisper.DecodingOptions()
 
17
  # Create the Gradio interface
18
  iface = gr.Interface(
19
  fn=transcribe,
20
+ inputs=gr.Audio(label="Upload your audio file", type="filepath"),
21
  outputs="text",
22
  title="Whisper ASR",
23
  description="Upload an audio file and it will be transcribed using OpenAI's Whisper model."