silvesterjk commited on
Commit
a2fdb17
1 Parent(s): 024fc83

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ pipeline = pipeline(model="openai/whisper-medium.en")
5
+
6
+ def transcribe(file):
7
+ options = dict(task="transcribe", best_of=5)
8
+ text = model.transcribe(file, **options)["text"]
9
+ return text.strip()
10
+
11
+ block = gr.Blocks()
12
+
13
+ with block:
14
+ with gr.Group():
15
+ audio = gr.Audio(
16
+ show_label=False,
17
+ source="microphone",
18
+ type="filepath"
19
+ )
20
+ with gr.Box():
21
+ with gr.Row().style(equal_height=True):
22
+ transcribe_button = gr.Button("Transcribe")
23
+
24
+ textbox = gr.Textbox(show_label=False)
25
+
26
+ transcribe_button.click(transcribe, inputs=[audio], outputs=[textbox])
27
+
28
+ block.launch(share=True)