create app
Browse filesinitial commit
app.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
demo = gr.Blocks()
|
3 |
+
|
4 |
+
def transcribe_long_form(filepath):
|
5 |
+
if filepath is None:
|
6 |
+
gr.Warning("No audio found, please retry.")
|
7 |
+
return ""
|
8 |
+
output = asr(
|
9 |
+
filepath,
|
10 |
+
max_new_tokens=256,
|
11 |
+
chunk_length_s=30,
|
12 |
+
batch_size=8,
|
13 |
+
)
|
14 |
+
return output["text"]
|
15 |
+
|
16 |
+
mic_transcribe = gr.Interface(
|
17 |
+
fn=transcribe_long_form,
|
18 |
+
inputs=gr.Audio(sources="microphone",
|
19 |
+
type="filepath"),
|
20 |
+
outputs=gr.Textbox(label="Transcription",
|
21 |
+
lines=3),
|
22 |
+
allow_flagging="never")
|
23 |
+
|
24 |
+
file_transcribe = gr.Interface(
|
25 |
+
fn=transcribe_long_form,
|
26 |
+
inputs=gr.Audio(sources="upload",
|
27 |
+
type="filepath"),
|
28 |
+
outputs=gr.Textbox(label="Transcription",
|
29 |
+
lines=3),
|
30 |
+
allow_flagging="never",
|
31 |
+
)
|
32 |
+
|
33 |
+
with demo:
|
34 |
+
gr.TabbedInterface(
|
35 |
+
[mic_transcribe,
|
36 |
+
file_transcribe],
|
37 |
+
["Transcribe Microphone",
|
38 |
+
"Transcribe Audio File"],
|
39 |
+
)
|
40 |
+
demo.launch(share=True,
|
41 |
+
server_port=int(os.environ['PORT1']))
|