LimaRaed commited on
Commit
bc3d280
·
verified ·
1 Parent(s): bb7408d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -1,24 +1,21 @@
1
  import gradio as gr
2
- import torch
3
  from transformers import pipeline
4
 
5
- # Load Whisper model from Hugging Face
6
- asr = pipeline("automatic-speech-recognition", model="openai/whisper-small", device=0 if torch.cuda.is_available() else -1)
7
 
8
- # Function to transcribe audio
9
  def transcribe(audio):
10
- print("Received audio input.")
11
- text = asr(audio)["text"]
12
- return text
13
 
14
- # Create Gradio Interface
15
- demo = gr.Interface(
16
  fn=transcribe,
17
- inputs=gr.Audio(source="microphone", type="filepath"),
18
  outputs="text",
19
- title="🎙️ Whisper Voice Recognition",
20
- description="Speak into your mic and get real-time transcription using OpenAI's Whisper ASR."
21
  )
22
 
23
  # Launch the app
24
- demo.launch()
 
1
  import gradio as gr
 
2
  from transformers import pipeline
3
 
4
+ # Load Whisper ASR pipeline
5
+ asr = pipeline("automatic-speech-recognition", model="openai/whisper-base")
6
 
7
+ # Transcription function
8
  def transcribe(audio):
9
+ return asr(audio)["text"]
 
 
10
 
11
+ # Gradio interface
12
+ interface = gr.Interface(
13
  fn=transcribe,
14
+ inputs=gr.Audio(type="filepath", label="Upload or Record Audio"),
15
  outputs="text",
16
+ title="Whisper ASR Voice Recognition",
17
+ description="Transcribe speech using OpenAI's Whisper model."
18
  )
19
 
20
  # Launch the app
21
+ interface.launch()