Shanuka01 commited on
Commit
4b68c6d
·
1 Parent(s): 51cfd89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -5,7 +5,9 @@ import whisper
5
  model = whisper.load_model("large")
6
 
7
  def transcribe(audio_file):
 
8
  audio = whisper.load_audio(audio_file.name)
 
9
  audio = whisper.pad_or_trim(audio)
10
  # Generate a mel spectrogram
11
  mel = whisper.log_mel_spectrogram(audio).to(model.device)
@@ -18,7 +20,7 @@ def transcribe(audio_file):
18
  # Create the Gradio interface
19
  iface = gr.Interface(
20
  fn=transcribe,
21
- inputs=gr.inputs.Audio(source="upload", type="file", label="Upload your audio file"),
22
  outputs="text",
23
  title="Whisper ASR",
24
  description="Upload an audio file and it will be transcribed using OpenAI's Whisper model."
@@ -26,4 +28,4 @@ iface = gr.Interface(
26
 
27
  # Launch the app
28
  if __name__ == "__main__":
29
- iface.launch()
 
5
  model = whisper.load_model("large")
6
 
7
  def transcribe(audio_file):
8
+ # Load audio file
9
  audio = whisper.load_audio(audio_file.name)
10
+ # Pad or trim audio to the expected length
11
  audio = whisper.pad_or_trim(audio)
12
  # Generate a mel spectrogram
13
  mel = whisper.log_mel_spectrogram(audio).to(model.device)
 
20
  # Create the Gradio interface
21
  iface = gr.Interface(
22
  fn=transcribe,
23
+ inputs=gr.Audio(source="upload", type="file", label="Upload your audio file"),
24
  outputs="text",
25
  title="Whisper ASR",
26
  description="Upload an audio file and it will be transcribed using OpenAI's Whisper model."
 
28
 
29
  # Launch the app
30
  if __name__ == "__main__":
31
+ iface.launch()