Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,7 @@ import re
|
|
11 |
|
12 |
# Initialize the speech recognition pipeline and transliterator
|
13 |
p1 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-odia_v1")
|
|
|
14 |
p2 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-hindi_v1")
|
15 |
#p3 = pipeline(task="automatic-speech-recognition", model="cdactvm/kannada_w2v-bert_model")
|
16 |
#p4 = pipeline(task="automatic-speech-recognition", model="cdactvm/telugu_w2v-bert_model")
|
@@ -47,7 +48,26 @@ def transcribe_odiya(speech):
|
|
47 |
return "Error: ASR returned None"
|
48 |
return text
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
|
|
51 |
def cleanhtml(raw_html):
|
52 |
cleantext = re.sub(r'<.*?>', '', raw_html)
|
53 |
return cleantext
|
@@ -196,7 +216,11 @@ def sel_lng(lng, mic=None, file=None):
|
|
196 |
elif lng == "Assamese-LM":
|
197 |
return transcribe_assamese_LM(audio)
|
198 |
elif lng == "Assamese-Model2":
|
|
|
|
|
199 |
return transcribe_assamese_model2(audio)
|
|
|
|
|
200 |
|
201 |
|
202 |
# Function to replace incorrectly spelled words
|
@@ -423,7 +447,7 @@ demo=gr.Interface(
|
|
423 |
inputs=[
|
424 |
|
425 |
#gr.Dropdown(["Hindi","Hindi-trans","Odiya","Odiya-trans","Kannada","Kannada-trans","Telugu","Telugu-trans","Bangala","Bangala-trans"],value="Hindi",label="Select Language"),
|
426 |
-
gr.Dropdown(["Hindi","Hindi-trans","Odiya","Odiya-trans","Assamese-LM","Assamese-Model2"],value="Hindi",label="Select Language"),
|
427 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
428 |
#gr.Audio(sources="upload", type="filepath"),
|
429 |
#"state"
|
|
|
11 |
|
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 |
#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")
|
|
|
48 |
return "Error: ASR returned None"
|
49 |
return text
|
50 |
|
51 |
+
###################################
|
52 |
+
def transcribe_odiya_model2(speech):
|
53 |
+
text = odia-model2(speech)["text"]
|
54 |
+
if text is None:
|
55 |
+
return "Error: ASR returned None"
|
56 |
+
return text
|
57 |
+
|
58 |
+
def transcribe_odiya_eng_model2(speech):
|
59 |
+
trn = Transliterator(source='ori', target='eng', build_lookup=True)
|
60 |
+
text = odia-model2(speech)["text"]
|
61 |
+
if text is None:
|
62 |
+
return "Error: ASR returned None"
|
63 |
+
sentence = trn.transform(text)
|
64 |
+
if sentence is None:
|
65 |
+
return "Error: Transliteration returned None"
|
66 |
+
replaced_words = replace_words(sentence)
|
67 |
+
processed_sentence = process_doubles(replaced_words)
|
68 |
+
return process_transcription(processed_sentence)
|
69 |
|
70 |
+
########################################
|
71 |
def cleanhtml(raw_html):
|
72 |
cleantext = re.sub(r'<.*?>', '', raw_html)
|
73 |
return cleantext
|
|
|
216 |
elif lng == "Assamese-LM":
|
217 |
return transcribe_assamese_LM(audio)
|
218 |
elif lng == "Assamese-Model2":
|
219 |
+
return transcribe_odiya_model2(audio)
|
220 |
+
elif lng == "Odia_model2":
|
221 |
return transcribe_assamese_model2(audio)
|
222 |
+
elif lng == "Odia_trans_model2":
|
223 |
+
return transcribe_odiya_eng_model2(audio)
|
224 |
|
225 |
|
226 |
# Function to replace incorrectly spelled words
|
|
|
447 |
inputs=[
|
448 |
|
449 |
#gr.Dropdown(["Hindi","Hindi-trans","Odiya","Odiya-trans","Kannada","Kannada-trans","Telugu","Telugu-trans","Bangala","Bangala-trans"],value="Hindi",label="Select Language"),
|
450 |
+
gr.Dropdown(["Hindi","Hindi-trans","Odiya","Odiya-trans","Odia_model2","Odia_trans_model2","Assamese-LM","Assamese-Model2"],value="Hindi",label="Select Language"),
|
451 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
452 |
#gr.Audio(sources="upload", type="filepath"),
|
453 |
#"state"
|