Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,26 @@
|
|
1 |
import gradio as gr
|
2 |
import whisper
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
# Transcribe the audio
|
10 |
result = model.transcribe(audio)
|
|
|
11 |
return result['text']
|
12 |
|
13 |
-
#
|
14 |
iface = gr.Interface(
|
15 |
-
fn=transcribe_audio,
|
16 |
-
inputs=
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
20 |
)
|
21 |
|
22 |
# Launch the interface
|
|
|
1 |
import gradio as gr
|
2 |
import whisper
|
3 |
|
4 |
+
# Function to process the audio file
|
5 |
+
def transcribe_audio(model_size, audio):
|
6 |
+
# Load the Whisper model based on the user's choice
|
7 |
+
model = whisper.load_model(model_size)
|
8 |
+
|
9 |
+
# Transcribe the audio file
|
10 |
result = model.transcribe(audio)
|
11 |
+
|
12 |
return result['text']
|
13 |
|
14 |
+
# Gradio interface with model selection
|
15 |
iface = gr.Interface(
|
16 |
+
fn=transcribe_audio, # The function that will process the audio and model choice
|
17 |
+
inputs=[
|
18 |
+
gr.Dropdown(label="Choose Whisper Model", choices=["tiny", "base", "small", "medium", "large"], value="base"), # Model selection
|
19 |
+
gr.Audio(source="upload", type="filepath") # Audio upload input
|
20 |
+
],
|
21 |
+
outputs="text", # Output transcription as text
|
22 |
+
title="Whisper Audio Transcription",
|
23 |
+
description="Upload an audio file and select a Whisper model to get the transcription."
|
24 |
)
|
25 |
|
26 |
# Launch the interface
|