Meckyhugging commited on
Commit
2b271d9
·
verified ·
1 Parent(s): 355ef22

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+
3
+ import gradio as gr
4
+ import torch
5
+ from transformers import pipeline
6
+
7
+ # Load a fast automatic speech recognition pipeline
8
+ asr_pipeline = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h")
9
+
10
+ def transcribe_audio(audio):
11
+ if audio is None:
12
+ return "No audio input"
13
+
14
+ text = asr_pipeline(audio)["text"]
15
+ return text
16
+
17
+ # Gradio Interface
18
+ iface = gr.Interface(
19
+ fn=transcribe_audio,
20
+ inputs=gr.Audio(sources=["microphone"], type="filepath"),
21
+ outputs=gr.Textbox(label="Recognized Text"),
22
+ live=True,
23
+ title="Real-time Voice to Text (Fast Version)",
24
+ description="Speak into your microphone and get instant transcription!",
25
+ )
26
+
27
+ if __name__ == "__main__":
28
+ iface.launch()