Spaces:
Runtime error
Runtime error
added english transcription tabs
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import time
|
|
8 |
|
9 |
p_ta = pipeline("automatic-speech-recognition", model="kmknair/wav2vec2-xlsr-tamil")
|
10 |
p_ar = pipeline("automatic-speech-recognition", model="kmknair/wav2vec2-xlsr-arabic")
|
|
|
11 |
|
12 |
|
13 |
def transcribe_ta(audio_u, audio_m):
|
@@ -39,6 +40,21 @@ def transcribe_ar_stream(audio, state=""):
|
|
39 |
state += text + " "
|
40 |
return state, state
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
# transcribe Tamil stream
|
43 |
ta_tr_stream_tab = gr.Interface(
|
44 |
fn=transcribe_ta_stream,
|
@@ -64,6 +80,20 @@ ar_tr_stream_tab = gr.Interface(
|
|
64 |
],
|
65 |
live=True)
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
# transcribe Tamil file
|
68 |
ta_tr_file_tab = gr.Interface(
|
69 |
fn=transcribe_ta,
|
@@ -82,14 +112,32 @@ ar_tr_file_tab = gr.Interface(
|
|
82 |
],
|
83 |
outputs="text")
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
tabs = gr.TabbedInterface(
|
87 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
[
|
89 |
-
"Tamil Live Transcription",
|
90 |
"Arabic Live Transcription",
|
91 |
-
"
|
|
|
92 |
"Arabic File Transcription",
|
|
|
|
|
93 |
]
|
94 |
)
|
95 |
|
|
|
8 |
|
9 |
p_ta = pipeline("automatic-speech-recognition", model="kmknair/wav2vec2-xlsr-tamil")
|
10 |
p_ar = pipeline("automatic-speech-recognition", model="kmknair/wav2vec2-xlsr-arabic")
|
11 |
+
p_en = pipeline("automatic-speech-recognition", mdoel="patrickvonplaten/hubert-xlarge-ls960-ft-4-gram")
|
12 |
|
13 |
|
14 |
def transcribe_ta(audio_u, audio_m):
|
|
|
40 |
state += text + " "
|
41 |
return state, state
|
42 |
|
43 |
+
def transcribe_en(audio_u, audio_m):
|
44 |
+
text = ""
|
45 |
+
if audio_u is not None:
|
46 |
+
text += p_en(audio_u)["text"]
|
47 |
+
if audio_m is not None:
|
48 |
+
text += p_en(audio_m)["text"]
|
49 |
+
return text
|
50 |
+
|
51 |
+
def transcribe_en_stream(audio, state=""):
|
52 |
+
time.sleep(2)
|
53 |
+
text = p_en(audio)["text"]
|
54 |
+
state += text + " "
|
55 |
+
return state, state
|
56 |
+
|
57 |
+
|
58 |
# transcribe Tamil stream
|
59 |
ta_tr_stream_tab = gr.Interface(
|
60 |
fn=transcribe_ta_stream,
|
|
|
80 |
],
|
81 |
live=True)
|
82 |
|
83 |
+
# transcribe English stream
|
84 |
+
en_tr_stream_tab = gr.Interface(
|
85 |
+
fn=transcribe_en_stream,
|
86 |
+
inputs=[
|
87 |
+
gr.Audio(source="microphone", type="filepath", streaming=True),
|
88 |
+
"state"
|
89 |
+
],
|
90 |
+
outputs=[
|
91 |
+
"textbox",
|
92 |
+
"state"
|
93 |
+
],
|
94 |
+
live=True)
|
95 |
+
|
96 |
+
|
97 |
# transcribe Tamil file
|
98 |
ta_tr_file_tab = gr.Interface(
|
99 |
fn=transcribe_ta,
|
|
|
112 |
],
|
113 |
outputs="text")
|
114 |
|
115 |
+
# transcribe English file
|
116 |
+
en_tr_file_tab = gr.Interface(
|
117 |
+
fn=transcribe_en,
|
118 |
+
inputs=[
|
119 |
+
gr.Audio(type="filepath"),
|
120 |
+
gr.Audio(source="microphone", type="filepath")
|
121 |
+
],
|
122 |
+
outputs="text")
|
123 |
+
|
124 |
|
125 |
tabs = gr.TabbedInterface(
|
126 |
+
[
|
127 |
+
ar_tr_stream_tab,
|
128 |
+
en_tr_stream_tab,
|
129 |
+
ta_tr_stream_tab,
|
130 |
+
ar_tr_file_tab,
|
131 |
+
en_tr_file_tab,
|
132 |
+
ta_tr_file_tab
|
133 |
+
],
|
134 |
[
|
|
|
135 |
"Arabic Live Transcription",
|
136 |
+
"English Live Transcription",
|
137 |
+
"Tamil Live Transcription",
|
138 |
"Arabic File Transcription",
|
139 |
+
"English File Transcription",
|
140 |
+
"Tamil File Transcription"
|
141 |
]
|
142 |
)
|
143 |
|