Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,12 +5,18 @@ import re
|
|
5 |
os.system('git clone https://github.com/irshadbhat/indic-trans.git')
|
6 |
os.system('pip install ./indic-trans/.')
|
7 |
p1= pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-odia_v1")
|
|
|
8 |
|
9 |
def transcribe_odiya(speech):
|
10 |
#print (p1(speech))
|
11 |
text = p1(speech)["text"]
|
12 |
#text=cleanhtml(text)
|
13 |
return text
|
|
|
|
|
|
|
|
|
|
|
14 |
def transcribe_odiya_eng(speech):
|
15 |
from indictrans import Transliterator
|
16 |
trn = Transliterator(source='ori', target='eng', build_lookup=True)
|
@@ -18,7 +24,13 @@ def transcribe_odiya_eng(speech):
|
|
18 |
text=trn.transform(text)
|
19 |
text = master_function(text)
|
20 |
return text
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
def sel_lng(lng,mic=None, file=None):
|
23 |
if mic is not None:
|
24 |
audio = mic
|
@@ -30,6 +42,10 @@ def sel_lng(lng,mic=None, file=None):
|
|
30 |
return transcribe_odiya(audio)
|
31 |
elif (lng=="Odiya-trans"):
|
32 |
return transcribe_odiya_eng(audio)
|
|
|
|
|
|
|
|
|
33 |
|
34 |
#####################################################
|
35 |
|
@@ -270,7 +286,7 @@ demo=gr.Interface(
|
|
270 |
|
271 |
inputs=[
|
272 |
|
273 |
-
gr.Dropdown(["Odiya","Odiya-trans"],value="
|
274 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
275 |
#gr.Audio(sources="upload", type="filepath"),
|
276 |
#"state"
|
|
|
5 |
os.system('git clone https://github.com/irshadbhat/indic-trans.git')
|
6 |
os.system('pip install ./indic-trans/.')
|
7 |
p1= pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-odia_v1")
|
8 |
+
p2=pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-hindi_v1")
|
9 |
|
10 |
def transcribe_odiya(speech):
|
11 |
#print (p1(speech))
|
12 |
text = p1(speech)["text"]
|
13 |
#text=cleanhtml(text)
|
14 |
return text
|
15 |
+
def transcribe_hindi(speech):
|
16 |
+
#print (p1(speech))
|
17 |
+
text = p2(speech)["text"]
|
18 |
+
#text=cleanhtml(text)
|
19 |
+
return text
|
20 |
def transcribe_odiya_eng(speech):
|
21 |
from indictrans import Transliterator
|
22 |
trn = Transliterator(source='ori', target='eng', build_lookup=True)
|
|
|
24 |
text=trn.transform(text)
|
25 |
text = master_function(text)
|
26 |
return text
|
27 |
+
def transcribe_hin_eng(speech):
|
28 |
+
from indictrans import Transliterator
|
29 |
+
trn = Transliterator(source='hin', target='eng', build_lookup=True)
|
30 |
+
text = p2(speech)["text"]
|
31 |
+
text=trn.transform(text)
|
32 |
+
text = master_function(text)
|
33 |
+
return text
|
34 |
def sel_lng(lng,mic=None, file=None):
|
35 |
if mic is not None:
|
36 |
audio = mic
|
|
|
42 |
return transcribe_odiya(audio)
|
43 |
elif (lng=="Odiya-trans"):
|
44 |
return transcribe_odiya_eng(audio)
|
45 |
+
elif (lng=="Hindi-trans"):
|
46 |
+
return transcribe_hin_eng(audio)
|
47 |
+
elif (lng=="Hindi"):
|
48 |
+
return transcribe_hindi(audio)
|
49 |
|
50 |
#####################################################
|
51 |
|
|
|
286 |
|
287 |
inputs=[
|
288 |
|
289 |
+
gr.Dropdown(["Hindi","Hindi-trans","Odiya","Odiya-trans"],value="Hindi",label="Select Language"),
|
290 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
291 |
#gr.Audio(sources="upload", type="filepath"),
|
292 |
#"state"
|