Trupthi commited on
Commit
b398bd6
·
verified ·
1 Parent(s): e449d16

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load Whisper pipeline
5
+ pipe = pipeline(task="automatic-speech-recognition", model="openai/whisper-small")
6
+
7
+ # Function to transcribe audio file
8
+ def transcribe(audio_file):
9
+ if audio_file is None:
10
+ return "Please upload an audio file."
11
+ return pipe(audio_file)["text"]
12
+
13
+ # Gradio Interface
14
+ with gr.Blocks() as app:
15
+ gr.Markdown("## 🎙️ Whisper Speech-to-Text (ASR)\nUpload or record audio and get transcription.")
16
+
17
+ with gr.Row():
18
+ audio_input = gr.Audio(type="filepath", label="Upload or Record Audio")
19
+ output_text = gr.Textbox(label="Transcription")
20
+
21
+ transcribe_btn = gr.Button("Transcribe")
22
+ transcribe_btn.click(fn=transcribe, inputs=audio_input, outputs=output_text)
23
+
24
+
25
+ app.launch()