Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,6 +18,7 @@ p1 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-o
|
|
18 |
p2 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-hindi_v1")
|
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 |
os.system('git clone https://github.com/irshadbhat/indic-trans.git')
|
22 |
os.system('pip install ./indic-trans/.')
|
23 |
|
@@ -47,6 +48,13 @@ def transcribe_telugu(speech):
|
|
47 |
if text is None:
|
48 |
return "Error: ASR returned None"
|
49 |
return text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
def transcribe_odiya_eng(speech):
|
51 |
trn = Transliterator(source='ori', target='eng', build_lookup=True)
|
52 |
text = p1(speech)["text"]
|
@@ -58,6 +66,18 @@ def transcribe_odiya_eng(speech):
|
|
58 |
replaced_words = replace_words(sentence)
|
59 |
processed_sentence = process_doubles(replaced_words)
|
60 |
return process_transcription(processed_sentence)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
def transcribe_hin_eng(speech):
|
63 |
trn = Transliterator(source='hin', target='eng', build_lookup=True)
|
@@ -136,6 +156,10 @@ def sel_lng(lng, mic=None, file=None):
|
|
136 |
return transcribe_tel_eng(audio)
|
137 |
elif lng == "Telugu":
|
138 |
return transcribe_telugu(audio)
|
|
|
|
|
|
|
|
|
139 |
|
140 |
# Function to replace incorrectly spelled words
|
141 |
def replace_words(sentence):
|
|
|
18 |
p2 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-hindi_v1")
|
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")
|
22 |
os.system('git clone https://github.com/irshadbhat/indic-trans.git')
|
23 |
os.system('pip install ./indic-trans/.')
|
24 |
|
|
|
48 |
if text is None:
|
49 |
return "Error: ASR returned None"
|
50 |
return text
|
51 |
+
|
52 |
+
def transcribe_bangala(speech):
|
53 |
+
text = p5(speech)["text"]
|
54 |
+
if text is None:
|
55 |
+
return "Error: ASR returned None"
|
56 |
+
return text
|
57 |
+
|
58 |
def transcribe_odiya_eng(speech):
|
59 |
trn = Transliterator(source='ori', target='eng', build_lookup=True)
|
60 |
text = p1(speech)["text"]
|
|
|
66 |
replaced_words = replace_words(sentence)
|
67 |
processed_sentence = process_doubles(replaced_words)
|
68 |
return process_transcription(processed_sentence)
|
69 |
+
|
70 |
+
def transcribe_ban_eng(speech):
|
71 |
+
trn = Transliterator(source='ori', target='eng', build_lookup=True)
|
72 |
+
text = p5(speech)["text"]
|
73 |
+
if text is None:
|
74 |
+
return "Error: ASR returned None"
|
75 |
+
sentence = trn.transform(text)
|
76 |
+
if sentence is None:
|
77 |
+
return "Error: Transliteration returned None"
|
78 |
+
replaced_words = replace_words(sentence)
|
79 |
+
processed_sentence = process_doubles(replaced_words)
|
80 |
+
return process_transcription(processed_sentence)
|
81 |
|
82 |
def transcribe_hin_eng(speech):
|
83 |
trn = Transliterator(source='hin', target='eng', build_lookup=True)
|
|
|
156 |
return transcribe_tel_eng(audio)
|
157 |
elif lng == "Telugu":
|
158 |
return transcribe_telugu(audio)
|
159 |
+
elif lng == "Bangala-trans":
|
160 |
+
return transcribe_ban_eng(audio)
|
161 |
+
elif lng == "Bangala":
|
162 |
+
return transcribe_bangala(audio)
|
163 |
|
164 |
# Function to replace incorrectly spelled words
|
165 |
def replace_words(sentence):
|