Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,7 @@ import re
|
|
13 |
#p1 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-odia_v1")
|
14 |
#odia_model2 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-odia_v1")
|
15 |
p2 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-hindi_v1")
|
|
|
16 |
punjaib_modle_155750=pipeline(task="automatic-speech-recognition", model="cdactvm/wav2vec-bert-punjabi-155750-model")
|
17 |
punjaib_modle_75000=pipeline(task="automatic-speech-recognition", model="cdactvm/wav2vec-bert-punjabi-75000-model")
|
18 |
#p3 = pipeline(task="automatic-speech-recognition", model="cdactvm/kannada_w2v-bert_model")
|
@@ -267,7 +268,7 @@ def process_transcription(input_sentence):
|
|
267 |
###########################################
|
268 |
|
269 |
def transcribe_punjabi_30000(speech):
|
270 |
-
text =
|
271 |
text = text.replace("[PAD]","")
|
272 |
if text is None:
|
273 |
return "Error: ASR returned None"
|
@@ -275,7 +276,7 @@ def transcribe_punjabi_30000(speech):
|
|
275 |
|
276 |
def transcribe_punjabi_eng_model_30000(speech):
|
277 |
trn = Transliterator(source='pan', target='eng', build_lookup=True)
|
278 |
-
text =
|
279 |
text = text.replace("[PAD]","")
|
280 |
if text is None:
|
281 |
return "Error: ASR returned None"
|
@@ -288,7 +289,7 @@ def transcribe_punjabi_eng_model_30000(speech):
|
|
288 |
return sentence
|
289 |
|
290 |
def transcribe_punjabi_75000(speech):
|
291 |
-
text =
|
292 |
text = text.replace("[PAD]","")
|
293 |
if text is None:
|
294 |
return "Error: ASR returned None"
|
@@ -296,7 +297,7 @@ def transcribe_punjabi_75000(speech):
|
|
296 |
|
297 |
def transcribe_punjabi_eng_model_75000(speech):
|
298 |
trn = Transliterator(source='pan', target='eng', build_lookup=True)
|
299 |
-
text =
|
300 |
text = text.replace("[PAD]","")
|
301 |
if text is None:
|
302 |
return "Error: ASR returned None"
|
@@ -308,6 +309,27 @@ def transcribe_punjabi_eng_model_75000(speech):
|
|
308 |
return process_transcription(processed_sentence)
|
309 |
return sentence
|
310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
###########################################
|
312 |
def transcribe_odiya(speech):
|
313 |
text = p1(speech)["text"]
|
@@ -542,6 +564,10 @@ def sel_lng(lng, mic=None, file=None):
|
|
542 |
return transcribe_punjabi_75000(audio)
|
543 |
elif lng == "Punjabi_Model2_Trans":
|
544 |
return transcribe_punjabi_eng_model_75000(audio)
|
|
|
|
|
|
|
|
|
545 |
|
546 |
|
547 |
|
@@ -579,7 +605,7 @@ demo=gr.Interface(
|
|
579 |
# "Hindi","Hindi-trans",
|
580 |
# "Odiya","Odiya-trans","Odia_model2","Odia_trans_model2",
|
581 |
# "Assamese-LM","Assamese-Model2",
|
582 |
-
"Punjabi_Model1","Punjabi_Model1_Trans","Punjabi_Model2","Punjabi_Model2_Trans"],value="Hindi",label="Select Language"),
|
583 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
584 |
#gr.Audio(sources="upload", type="filepath"),
|
585 |
#"state"
|
|
|
13 |
#p1 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-odia_v1")
|
14 |
#odia_model2 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-odia_v1")
|
15 |
p2 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-hindi_v1")
|
16 |
+
punjaib_modle_30000=pipeline(task="automatic-speech-recognition", model="cdactvm/wav2vec-bert-punjabi-30000-model")
|
17 |
punjaib_modle_155750=pipeline(task="automatic-speech-recognition", model="cdactvm/wav2vec-bert-punjabi-155750-model")
|
18 |
punjaib_modle_75000=pipeline(task="automatic-speech-recognition", model="cdactvm/wav2vec-bert-punjabi-75000-model")
|
19 |
#p3 = pipeline(task="automatic-speech-recognition", model="cdactvm/kannada_w2v-bert_model")
|
|
|
268 |
###########################################
|
269 |
|
270 |
def transcribe_punjabi_30000(speech):
|
271 |
+
text = punjaib_modle_30000(speech)["text"]
|
272 |
text = text.replace("[PAD]","")
|
273 |
if text is None:
|
274 |
return "Error: ASR returned None"
|
|
|
276 |
|
277 |
def transcribe_punjabi_eng_model_30000(speech):
|
278 |
trn = Transliterator(source='pan', target='eng', build_lookup=True)
|
279 |
+
text = punjaib_modle_30000(speech)["text"]
|
280 |
text = text.replace("[PAD]","")
|
281 |
if text is None:
|
282 |
return "Error: ASR returned None"
|
|
|
289 |
return sentence
|
290 |
|
291 |
def transcribe_punjabi_75000(speech):
|
292 |
+
text = punjaib_modle_75000(speech)["text"]
|
293 |
text = text.replace("[PAD]","")
|
294 |
if text is None:
|
295 |
return "Error: ASR returned None"
|
|
|
297 |
|
298 |
def transcribe_punjabi_eng_model_75000(speech):
|
299 |
trn = Transliterator(source='pan', target='eng', build_lookup=True)
|
300 |
+
text = punjaib_modle_75000(speech)["text"]
|
301 |
text = text.replace("[PAD]","")
|
302 |
if text is None:
|
303 |
return "Error: ASR returned None"
|
|
|
309 |
return process_transcription(processed_sentence)
|
310 |
return sentence
|
311 |
|
312 |
+
def transcribe_punjabi_155750(speech):
|
313 |
+
text = punjaib_modle_155750(speech)["text"]
|
314 |
+
text = text.replace("[PAD]","")
|
315 |
+
if text is None:
|
316 |
+
return "Error: ASR returned None"
|
317 |
+
return text
|
318 |
+
|
319 |
+
def transcribe_punjabi_eng_model_155750(speech):
|
320 |
+
trn = Transliterator(source='pan', target='eng', build_lookup=True)
|
321 |
+
text = punjaib_modle_155750(speech)["text"]
|
322 |
+
text = text.replace("[PAD]","")
|
323 |
+
if text is None:
|
324 |
+
return "Error: ASR returned None"
|
325 |
+
sentence = trn.transform(text)
|
326 |
+
if sentence is None:
|
327 |
+
return "Error: Transliteration returned None"
|
328 |
+
replaced_words = replace_words(sentence)
|
329 |
+
processed_sentence = process_doubles(replaced_words)
|
330 |
+
return process_transcription(processed_sentence)
|
331 |
+
return sentence
|
332 |
+
|
333 |
###########################################
|
334 |
def transcribe_odiya(speech):
|
335 |
text = p1(speech)["text"]
|
|
|
564 |
return transcribe_punjabi_75000(audio)
|
565 |
elif lng == "Punjabi_Model2_Trans":
|
566 |
return transcribe_punjabi_eng_model_75000(audio)
|
567 |
+
elif lng == "Punjabi_Model3":
|
568 |
+
return transcribe_punjabi_155750(audio)
|
569 |
+
elif lng == "Punjabi_Model3_Trans":
|
570 |
+
return transcribe_punjabi_eng_model_155750(audio)
|
571 |
|
572 |
|
573 |
|
|
|
605 |
# "Hindi","Hindi-trans",
|
606 |
# "Odiya","Odiya-trans","Odia_model2","Odia_trans_model2",
|
607 |
# "Assamese-LM","Assamese-Model2",
|
608 |
+
"Punjabi_Model1","Punjabi_Model1_Trans","Punjabi_Model2","Punjabi_Model2_Trans","Punjabi_Model3","Punjabi_Model3_Trans"],value="Hindi",label="Select Language"),
|
609 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
610 |
#gr.Audio(sources="upload", type="filepath"),
|
611 |
#"state"
|