Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
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
|
19 |
|
20 |
# Create the Gradio interface
|
21 |
iface = gr.Interface(fn=transcribe,
|
22 |
-
inputs=gr.Audio(sources="upload", type="
|
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.")
|