Spaces:
Running
Running
Update app.py
Browse files
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.
|
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()
|