dev427tools commited on
Commit
52a4fb9
Β·
verified Β·
1 Parent(s): 8f341f6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the Automatic Speech Recognition pipeline from Hugging Face
5
+ asr = pipeline("automatic-speech-recognition", model="openai/whisper-large-v3")
6
+
7
+ def transcribe(audio):
8
+ if audio is None:
9
+ return "Please record or upload an audio file."
10
+ # audio is a tuple: (sample_rate, numpy array)
11
+ result = asr(audio)["text"]
12
+ return result
13
+
14
+ description = """
15
+ # Speech-to-Text Converter
16
+ Record your voice or upload an audio file and get the transcription using Hugging Face's Whisper model.
17
+ """
18
+
19
+ demo = gr.Interface(
20
+ fn=transcribe,
21
+ inputs=gr.Audio(source="microphone", type="numpy", label="Record or Upload Audio"),
22
+ outputs=gr.Textbox(label="Transcribed Text"),
23
+ title="Speech to Text App",
24
+ description=description,
25
+ allow_flagging="never",
26
+ theme="default"
27
+ )
28
+
29
+ if __name__ == "__main__":
30
+ demo.launch()