pokharel commited on
Commit
58a6f46
1 Parent(s): 3df97f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -1
app.py CHANGED
@@ -1,3 +1,31 @@
 
 
 
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- gr.load("models/openai/whisper-large-v3").launch()
 
1
+ # import gradio as gr
2
+
3
+ # gr.load("models/openai/whisper-large-v3").launch()
4
  import gradio as gr
5
+ import whisper
6
+
7
+ # Load the Whisper model
8
+ model = whisper.load_model("large")
9
+
10
+ def transcribe_audio(audio):
11
+ # Load the audio file
12
+ audio = whisper.load_audio(audio)
13
+ # Transcribe the audio using Whisper
14
+ result = model.transcribe(audio)
15
+ return result["text"]
16
+
17
+ # Create a Gradio interface with both microphone and file upload inputs
18
+ interface = gr.Interface(
19
+ fn=transcribe_audio,
20
+ inputs=[
21
+ gr.Audio(source="microphone", type="filepath", label="Record using Microphone"),
22
+ gr.Audio(source="upload", type="filepath", label="Upload Audio File")
23
+ ],
24
+ outputs="text",
25
+ live=True,
26
+ description="Speak into your microphone or upload an audio file to see the transcription in real-time."
27
+ )
28
+
29
+ # Launch the Gradio app
30
+ interface.launch()
31