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 |
#p3 = pipeline(task="automatic-speech-recognition", model="cdactvm/kannada_w2v-bert_model")
|
17 |
#p4 = pipeline(task="automatic-speech-recognition", model="cdactvm/telugu_w2v-bert_model")
|
18 |
#p5 = pipeline(task="automatic-speech-recognition", model="Sajjo/w2v-bert-2.0-bangala-gpu-CV16.0_v2")
|
@@ -264,6 +265,25 @@ def process_transcription(input_sentence):
|
|
264 |
|
265 |
###########################################
|
266 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
def transcribe_odiya(speech):
|
268 |
text = p1(speech)["text"]
|
269 |
if text is None:
|
@@ -427,6 +447,10 @@ def sel_lng(lng, mic=None, file=None):
|
|
427 |
return transcribe_odiya_model2(audio)
|
428 |
elif lng == "Odia_trans_model2":
|
429 |
return transcribe_odiya_eng_model2(audio)
|
|
|
|
|
|
|
|
|
430 |
|
431 |
|
432 |
|
@@ -460,7 +484,7 @@ demo=gr.Interface(
|
|
460 |
inputs=[
|
461 |
|
462 |
#gr.Dropdown(["Hindi","Hindi-trans","Odiya","Odiya-trans","Kannada","Kannada-trans","Telugu","Telugu-trans","Bangala","Bangala-trans"],value="Hindi",label="Select Language"),
|
463 |
-
gr.Dropdown(["Hindi","Hindi-trans","Odiya","Odiya-trans","Odia_model2","Odia_trans_model2","Assamese-LM","Assamese-Model2"],value="Hindi",label="Select Language"),
|
464 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
465 |
#gr.Audio(sources="upload", type="filepath"),
|
466 |
#"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")
|
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")
|
|
|
265 |
|
266 |
###########################################
|
267 |
|
268 |
+
def transcribe_punjabi_30000(speech):
|
269 |
+
text = punjaib_modle_30000(speech)["text"]
|
270 |
+
if text is None:
|
271 |
+
return "Error: ASR returned None"
|
272 |
+
return text
|
273 |
+
|
274 |
+
def transcribe_punjabi_eng_model_30000(speech):
|
275 |
+
trn = Transliterator(source='pun', target='eng', build_lookup=True)
|
276 |
+
text = punjaib_modle_30000(speech)["text"]
|
277 |
+
if text is None:
|
278 |
+
return "Error: ASR returned None"
|
279 |
+
sentence = trn.transform(text)
|
280 |
+
if sentence is None:
|
281 |
+
return "Error: Transliteration returned None"
|
282 |
+
replaced_words = replace_words(sentence)
|
283 |
+
processed_sentence = process_doubles(replaced_words)
|
284 |
+
return process_transcription(processed_sentence)
|
285 |
+
|
286 |
+
###########################################
|
287 |
def transcribe_odiya(speech):
|
288 |
text = p1(speech)["text"]
|
289 |
if text is None:
|
|
|
447 |
return transcribe_odiya_model2(audio)
|
448 |
elif lng == "Odia_trans_model2":
|
449 |
return transcribe_odiya_eng_model2(audio)
|
450 |
+
elif lng == "punjabi":
|
451 |
+
return transcribe_punjabi_30000(audio)
|
452 |
+
elif lng == "punjabi_trans":
|
453 |
+
return transcribe_punjabi_eng_model_30000(audio)
|
454 |
|
455 |
|
456 |
|
|
|
484 |
inputs=[
|
485 |
|
486 |
#gr.Dropdown(["Hindi","Hindi-trans","Odiya","Odiya-trans","Kannada","Kannada-trans","Telugu","Telugu-trans","Bangala","Bangala-trans"],value="Hindi",label="Select Language"),
|
487 |
+
gr.Dropdown(["Hindi","Hindi-trans","Odiya","Odiya-trans","Odia_model2","Odia_trans_model2","Assamese-LM","Assamese-Model2","punjabi","punjabi-trans"],value="Hindi",label="Select Language"),
|
488 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
489 |
#gr.Audio(sources="upload", type="filepath"),
|
490 |
#"state"
|