ZoyaRabail commited on
Commit
0eb7e32
·
verified ·
1 Parent(s): ebad87a

Create stt_app.py

Browse files
Files changed (1) hide show
  1. stt_app.py +24 -0
stt_app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load Whisper model
5
+ stt_pipeline = pipeline("automatic-speech-recognition", model="openai/whisper-small")
6
+
7
+ def transcribe(audio):
8
+ if audio is None:
9
+ return "Please record some audio."
10
+ result = stt_pipeline(audio)
11
+ return result["text"]
12
+
13
+ with gr.Blocks() as demo:
14
+ gr.Markdown("# 🎙️ Speech to Text Converter")
15
+ gr.Markdown("Supports **English, Spanish, French, German, Portuguese, Italian, Russian, Chinese**")
16
+
17
+ with gr.Row():
18
+ with gr.Column():
19
+ audio_input = gr.Audio(sources=["microphone"], type="filepath", label="🎤 Record Speech")
20
+ transcribe_btn = gr.Button("Transcribe")
21
+ with gr.Column():
22
+ output_text = gr.Textbox(label="📝 Transcribed Text", lines=8)
23
+
24
+ transcribe_btn.click(fn=transcribe, inputs=audio_input, outputs=output_text)