Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,7 @@ p1 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-o
|
|
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 |
#p3 = pipeline(task="automatic-speech-recognition", model="cdactvm/kannada_w2v-bert_model")
|
18 |
#p4 = pipeline(task="automatic-speech-recognition", model="cdactvm/telugu_w2v-bert_model")
|
19 |
#p5 = pipeline(task="automatic-speech-recognition", model="Sajjo/w2v-bert-2.0-bangala-gpu-CV16.0_v2")
|
@@ -286,6 +287,27 @@ def transcribe_punjabi_eng_model_30000(speech):
|
|
286 |
return process_transcription(processed_sentence)
|
287 |
return sentence
|
288 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
###########################################
|
290 |
def transcribe_odiya(speech):
|
291 |
text = p1(speech)["text"]
|
@@ -512,10 +534,14 @@ def sel_lng(lng, mic=None, file=None):
|
|
512 |
return transcribe_odiya_model2(audio)
|
513 |
elif lng == "Odia_trans_model2":
|
514 |
return transcribe_odiya_eng_model2(audio)
|
515 |
-
elif lng == "
|
516 |
return transcribe_punjabi_30000(audio)
|
517 |
-
elif lng == "
|
518 |
return transcribe_punjabi_eng_model_30000(audio)
|
|
|
|
|
|
|
|
|
519 |
|
520 |
|
521 |
|
@@ -549,7 +575,11 @@ demo=gr.Interface(
|
|
549 |
inputs=[
|
550 |
|
551 |
#gr.Dropdown(["Hindi","Hindi-trans","Odiya","Odiya-trans","Kannada","Kannada-trans","Telugu","Telugu-trans","Bangala","Bangala-trans"],value="Hindi",label="Select Language"),
|
552 |
-
gr.Dropdown([
|
|
|
|
|
|
|
|
|
553 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
554 |
#gr.Audio(sources="upload", type="filepath"),
|
555 |
#"state"
|
|
|
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_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")
|
19 |
#p4 = pipeline(task="automatic-speech-recognition", model="cdactvm/telugu_w2v-bert_model")
|
20 |
#p5 = pipeline(task="automatic-speech-recognition", model="Sajjo/w2v-bert-2.0-bangala-gpu-CV16.0_v2")
|
|
|
287 |
return process_transcription(processed_sentence)
|
288 |
return sentence
|
289 |
|
290 |
+
def transcribe_punjabi_75000(speech):
|
291 |
+
text = punjaib_modle_30000(speech)["text"]
|
292 |
+
text = text.replace("[PAD]","")
|
293 |
+
if text is None:
|
294 |
+
return "Error: ASR returned None"
|
295 |
+
return text
|
296 |
+
|
297 |
+
def transcribe_punjabi_eng_model_75000(speech):
|
298 |
+
trn = Transliterator(source='pan', target='eng', build_lookup=True)
|
299 |
+
text = punjaib_modle_30000(speech)["text"]
|
300 |
+
text = text.replace("[PAD]","")
|
301 |
+
if text is None:
|
302 |
+
return "Error: ASR returned None"
|
303 |
+
sentence = trn.transform(text)
|
304 |
+
if sentence is None:
|
305 |
+
return "Error: Transliteration returned None"
|
306 |
+
replaced_words = replace_words(sentence)
|
307 |
+
processed_sentence = process_doubles(replaced_words)
|
308 |
+
return process_transcription(processed_sentence)
|
309 |
+
return sentence
|
310 |
+
|
311 |
###########################################
|
312 |
def transcribe_odiya(speech):
|
313 |
text = p1(speech)["text"]
|
|
|
534 |
return transcribe_odiya_model2(audio)
|
535 |
elif lng == "Odia_trans_model2":
|
536 |
return transcribe_odiya_eng_model2(audio)
|
537 |
+
elif lng == "punjabi_30000":
|
538 |
return transcribe_punjabi_30000(audio)
|
539 |
+
elif lng == "punjabi_trans_30000":
|
540 |
return transcribe_punjabi_eng_model_30000(audio)
|
541 |
+
elif lng == "punjabi_75000":
|
542 |
+
return transcribe_punjabi_75000(audio)
|
543 |
+
elif lng == "punjabi_trans_75000":
|
544 |
+
return transcribe_punjabi_eng_model_75000(audio)
|
545 |
|
546 |
|
547 |
|
|
|
575 |
inputs=[
|
576 |
|
577 |
#gr.Dropdown(["Hindi","Hindi-trans","Odiya","Odiya-trans","Kannada","Kannada-trans","Telugu","Telugu-trans","Bangala","Bangala-trans"],value="Hindi",label="Select Language"),
|
578 |
+
gr.Dropdown([
|
579 |
+
# "Hindi","Hindi-trans",
|
580 |
+
# "Odiya","Odiya-trans","Odia_model2","Odia_trans_model2",
|
581 |
+
# "Assamese-LM","Assamese-Model2",
|
582 |
+
"punjabi_30000","punjabi_trans_30000","punjabi_75000","punjabi_trans_75000"],value="Hindi",label="Select Language"),
|
583 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
584 |
#gr.Audio(sources="upload", type="filepath"),
|
585 |
#"state"
|