Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,11 +7,13 @@ import re
|
|
7 |
#import torchaudio
|
8 |
|
9 |
# Initialize the speech recognition pipeline and transliterator
|
10 |
-
p1 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-odia_v1")
|
11 |
p2 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-hindi_v1")
|
12 |
-
p3 = pipeline(task="automatic-speech-recognition", model="cdactvm/kannada_w2v-bert_model")
|
13 |
-
p4 = pipeline(task="automatic-speech-recognition", model="cdactvm/telugu_w2v-bert_model")
|
14 |
-
p5 = pipeline(task="automatic-speech-recognition", model="Sajjo/w2v-bert-2.0-bangala-gpu-CV16.0_v2")
|
|
|
|
|
15 |
os.system('git clone https://github.com/irshadbhat/indic-trans.git')
|
16 |
os.system('pip install ./indic-trans/.')
|
17 |
|
@@ -47,6 +49,18 @@ def transcribe_bangala(speech):
|
|
47 |
if text is None:
|
48 |
return "Error: ASR returned None"
|
49 |
return text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
def transcribe_odiya_eng(speech):
|
52 |
trn = Transliterator(source='ori', target='eng', build_lookup=True)
|
@@ -153,6 +167,11 @@ def sel_lng(lng, mic=None, file=None):
|
|
153 |
return transcribe_ban_eng(audio)
|
154 |
elif lng == "Bangala":
|
155 |
return transcribe_bangala(audio)
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
# Function to replace incorrectly spelled words
|
158 |
def replace_words(sentence):
|
@@ -377,7 +396,8 @@ demo=gr.Interface(
|
|
377 |
|
378 |
inputs=[
|
379 |
|
380 |
-
gr.Dropdown(["Hindi","Hindi-trans","Odiya","Odiya-trans","Kannada","Kannada-trans","Telugu","Telugu-trans","Bangala","Bangala-trans"],value="Hindi",label="Select Language"),
|
|
|
381 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
382 |
#gr.Audio(sources="upload", type="filepath"),
|
383 |
#"state"
|
|
|
7 |
#import torchaudio
|
8 |
|
9 |
# Initialize the speech recognition pipeline and transliterator
|
10 |
+
#p1 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-odia_v1")
|
11 |
p2 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-hindi_v1")
|
12 |
+
#p3 = pipeline(task="automatic-speech-recognition", model="cdactvm/kannada_w2v-bert_model")
|
13 |
+
#p4 = pipeline(task="automatic-speech-recognition", model="cdactvm/telugu_w2v-bert_model")
|
14 |
+
#p5 = pipeline(task="automatic-speech-recognition", model="Sajjo/w2v-bert-2.0-bangala-gpu-CV16.0_v2")
|
15 |
+
p6 = pipeline(task="automatic-speech-recognition", model="cdactvm/hf-open-assames")
|
16 |
+
p7 = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-assames")
|
17 |
os.system('git clone https://github.com/irshadbhat/indic-trans.git')
|
18 |
os.system('pip install ./indic-trans/.')
|
19 |
|
|
|
49 |
if text is None:
|
50 |
return "Error: ASR returned None"
|
51 |
return text
|
52 |
+
|
53 |
+
def transcribe_assamese_model1(speech):
|
54 |
+
text = p6(speech)["text"]
|
55 |
+
if text is None:
|
56 |
+
return "Error: ASR returned None"
|
57 |
+
return text
|
58 |
+
|
59 |
+
def transcribe_assamese_model2(speech):
|
60 |
+
text = p7(speech)["text"]
|
61 |
+
if text is None:
|
62 |
+
return "Error: ASR returned None"
|
63 |
+
return text
|
64 |
|
65 |
def transcribe_odiya_eng(speech):
|
66 |
trn = Transliterator(source='ori', target='eng', build_lookup=True)
|
|
|
167 |
return transcribe_ban_eng(audio)
|
168 |
elif lng == "Bangala":
|
169 |
return transcribe_bangala(audio)
|
170 |
+
elif lng == "Assamese-Model1":
|
171 |
+
return transcribe_assamese_model1(audio)
|
172 |
+
elif lng == "Assamese-Model2":
|
173 |
+
return transcribe_assamese_model2(audio)
|
174 |
+
|
175 |
|
176 |
# Function to replace incorrectly spelled words
|
177 |
def replace_words(sentence):
|
|
|
396 |
|
397 |
inputs=[
|
398 |
|
399 |
+
#gr.Dropdown(["Hindi","Hindi-trans","Odiya","Odiya-trans","Kannada","Kannada-trans","Telugu","Telugu-trans","Bangala","Bangala-trans"],value="Hindi",label="Select Language"),
|
400 |
+
gr.Dropdown(["Hindi","Hindi-trans","Assamese-Model1","Assamese-Model2"],value="Hindi",label="Select Language"),
|
401 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
402 |
#gr.Audio(sources="upload", type="filepath"),
|
403 |
#"state"
|