pritamdeka commited on
Commit
8c8114a
·
verified ·
1 Parent(s): 2459bb2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -1,22 +1,26 @@
1
  import gradio as gr
2
  import whisper
3
 
4
- # Load the Whisper model (you can change to "base", "small", "medium", etc.)
5
- model = whisper.load_model("base")
6
-
7
- # Function to process the audio file and transcribe
8
- def transcribe_audio(audio):
9
- # Transcribe the audio using Whisper
10
  result = model.transcribe(audio)
 
11
  return result['text']
12
 
13
- # Create a Gradio interface for audio transcription
14
  iface = gr.Interface(
15
- fn=transcribe_audio, # The function that will process the audio
16
- inputs=gr.Audio(source="upload", type="filepath"), # Upload audio input
17
- outputs="text", # Output transcription as text
18
- title="Whisper Audio Transcription", # Title of the interface
19
- description="Upload an audio file and get the transcription using OpenAI's Whisper model." # Description
 
 
 
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