Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,10 +12,10 @@ import re
|
|
12 |
# Initialize the speech recognition pipeline and transliterator
|
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 |
-
|
19 |
#p3 = pipeline(task="automatic-speech-recognition", model="cdactvm/kannada_w2v-bert_model")
|
20 |
#p4 = pipeline(task="automatic-speech-recognition", model="cdactvm/telugu_w2v-bert_model")
|
21 |
#p5 = pipeline(task="automatic-speech-recognition", model="Sajjo/w2v-bert-2.0-bangala-gpu-CV16.0_v2")
|
@@ -288,16 +288,16 @@ def transcribe_punjabi_eng_model_30000(speech):
|
|
288 |
return process_transcription(processed_sentence)
|
289 |
return sentence
|
290 |
|
291 |
-
def
|
292 |
-
text =
|
293 |
text = text.replace("[PAD]","")
|
294 |
if text is None:
|
295 |
return "Error: ASR returned None"
|
296 |
return text
|
297 |
|
298 |
-
def
|
299 |
trn = Transliterator(source='pan', target='eng', build_lookup=True)
|
300 |
-
text =
|
301 |
text = text.replace("[PAD]","")
|
302 |
if text is None:
|
303 |
return "Error: ASR returned None"
|
@@ -560,10 +560,10 @@ def sel_lng(lng, mic=None, file=None):
|
|
560 |
return transcribe_punjabi_30000(audio)
|
561 |
elif lng == "Punjabi_Model1_Trans":
|
562 |
return transcribe_punjabi_eng_model_30000(audio)
|
563 |
-
elif lng == "
|
564 |
-
return
|
565 |
-
elif lng == "
|
566 |
-
return
|
567 |
elif lng == "Punjabi_Model3":
|
568 |
return transcribe_punjabi_155750(audio)
|
569 |
elif lng == "Punjabi_Model3_Trans":
|
@@ -605,7 +605,7 @@ demo=gr.Interface(
|
|
605 |
# "Hindi","Hindi-trans",
|
606 |
# "Odiya","Odiya-trans","Odia_model2","Odia_trans_model2",
|
607 |
# "Assamese-LM","Assamese-Model2",
|
608 |
-
"Punjabi_Model1","Punjabi_Model1_Trans","
|
609 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
610 |
#gr.Audio(sources="upload", type="filepath"),
|
611 |
#"state"
|
|
|
12 |
# Initialize the speech recognition pipeline and transliterator
|
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_70000_aug=pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-model-70000-augmented")
|
19 |
#p3 = pipeline(task="automatic-speech-recognition", model="cdactvm/kannada_w2v-bert_model")
|
20 |
#p4 = pipeline(task="automatic-speech-recognition", model="cdactvm/telugu_w2v-bert_model")
|
21 |
#p5 = pipeline(task="automatic-speech-recognition", model="Sajjo/w2v-bert-2.0-bangala-gpu-CV16.0_v2")
|
|
|
288 |
return process_transcription(processed_sentence)
|
289 |
return sentence
|
290 |
|
291 |
+
def transcribe_punjabi_70000_aug(speech):
|
292 |
+
text = punjaib_modle_70000_aug(speech)["text"]
|
293 |
text = text.replace("[PAD]","")
|
294 |
if text is None:
|
295 |
return "Error: ASR returned None"
|
296 |
return text
|
297 |
|
298 |
+
def transcribe_punjabi_eng_model_70000_aug(speech):
|
299 |
trn = Transliterator(source='pan', target='eng', build_lookup=True)
|
300 |
+
text = punjaib_modle_70000_aug(speech)["text"]
|
301 |
text = text.replace("[PAD]","")
|
302 |
if text is None:
|
303 |
return "Error: ASR returned None"
|
|
|
560 |
return transcribe_punjabi_30000(audio)
|
561 |
elif lng == "Punjabi_Model1_Trans":
|
562 |
return transcribe_punjabi_eng_model_30000(audio)
|
563 |
+
elif lng == "Punjabi_Model_aug":
|
564 |
+
return transcribe_punjabi_70000_aug(audio)
|
565 |
+
elif lng == "Punjabi_Model_aug_Trans":
|
566 |
+
return transcribe_punjabi_eng_model_70000_aug(audio)
|
567 |
elif lng == "Punjabi_Model3":
|
568 |
return transcribe_punjabi_155750(audio)
|
569 |
elif lng == "Punjabi_Model3_Trans":
|
|
|
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_Model_aug","Punjabi_Model_aug_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"
|