jiaofengxu commited on
Commit
cf27605
Β·
1 Parent(s): 17333b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -1,7 +1,25 @@
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
  import gradio as gr
3
 
4
+ model = pipeline("automatic-speech-recognition")
 
5
 
6
+
7
+ def transcribe_audio(mic=None, file=None):
8
+ if mic is not None:
9
+ audio = mic
10
+ elif file is not None:
11
+ audio = file
12
+ else:
13
+ return "You must either provide a mic recording or a file"
14
+ transcription = model(audio)["text"]
15
+ return transcription
16
+
17
+
18
+ gr.Interface(
19
+ fn=transcribe_audio,
20
+ inputs=[
21
+ gr.Audio(source="microphone", type="filepath", optional=True),
22
+ gr.Audio(source="upload", type="filepath", optional=True),
23
+ ],
24
+ outputs="text",
25
+ ).launch()