Lenylvt commited on
Commit
30d58a1
·
verified ·
1 Parent(s): 1a8b6da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -10
app.py CHANGED
@@ -5,21 +5,15 @@ import whisper
5
  model = whisper.load_model("base")
6
 
7
  def transcribe(audio_file):
8
- # Process the audio file
9
- audio = whisper.load_audio(audio_file.name)
10
- audio = whisper.pad_or_trim(audio)
11
-
12
- # Make predictions
13
- mel = whisper.log_mel_spectrogram(audio).to(model.device)
14
- options = whisper.DecodingOptions(fp16=False)
15
- result = whisper.decode(model, mel, options)
16
 
17
  # Return the transcription
18
- return result.text
19
 
20
  # Create the Gradio interface
21
  iface = gr.Interface(fn=transcribe,
22
- inputs=gr.Audio(sources="upload", type="filepath"),
23
  outputs="text",
24
  title="Whisper Transcription",
25
  description="Upload an audio file to transcribe it using OpenAI's Whisper model.")
 
5
  model = whisper.load_model("base")
6
 
7
  def transcribe(audio_file):
8
+ # Process the audio file directly with the file path
9
+ result = model.transcribe(audio_file)
 
 
 
 
 
 
10
 
11
  # Return the transcription
12
+ return result['text']
13
 
14
  # Create the Gradio interface
15
  iface = gr.Interface(fn=transcribe,
16
+ inputs=gr.inputs.Audio(sources="upload", type="file", label="Upload Audio"),
17
  outputs="text",
18
  title="Whisper Transcription",
19
  description="Upload an audio file to transcribe it using OpenAI's Whisper model.")