Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,48 +1,57 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
#
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
#text=cleanhtml(text)
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
|
21 |
-
|
22 |
-
|
23 |
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
#"state"
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
# #"state"
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
38 |
|
39 |
|
40 |
|
41 |
-
#demo.launch()
|
42 |
-
#from huggingface_hub import Repository
|
43 |
-
#repo = Repository(local_dir="indic-trans", clone_from="https://github.com/libindic/indic-trans.gi")
|
44 |
-
import os
|
45 |
-
os.system('git clone https://github.com/irshadbhat/indic-trans.git')
|
46 |
-
os.system('pip install ./indic-trans/.')
|
47 |
|
48 |
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
#import os
|
4 |
+
#os.system('git clone https://github.com/irshadbhat/indic-trans.git')
|
5 |
+
#os.system('pip install ./indic-trans/.')
|
6 |
+
p1= pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-odia_v1")
|
7 |
|
8 |
+
def transcribe_odiya(speech):
|
9 |
+
#print (p1(speech))
|
10 |
+
text = p1(speech)["text"]
|
11 |
#text=cleanhtml(text)
|
12 |
+
return text
|
13 |
+
def transcribe_odiya_eng(speech):
|
14 |
+
from indictrans import Transliterator
|
15 |
+
trn = Transliterator(source='ori', target='eng', build_lookup=True)
|
16 |
+
text = p1(speech)["text"]
|
17 |
+
text=trn.transform(text)
|
18 |
+
return text
|
19 |
+
|
20 |
+
def sel_lng(lng,mic=None, file=None):
|
21 |
+
if mic is not None:
|
22 |
+
audio = mic
|
23 |
+
elif file is not None:
|
24 |
+
audio = file
|
25 |
+
else:
|
26 |
+
return "You must either provide a mic recording or a file"
|
27 |
+
if (lng=="Odiya"):
|
28 |
+
return transcribe_odiya(audio)
|
29 |
+
elif (lng="Odiya-trans"):
|
30 |
+
return transcribe_odiya_eng(audio)
|
31 |
+
|
32 |
|
33 |
|
34 |
+
demo=gr.Interface(
|
35 |
+
fn=sel_lng,
|
36 |
|
37 |
+
inputs=[
|
38 |
|
39 |
+
gr.Dropdown(["Odiya","Odiya-trans"],value="Odiya",label="Select Language"),
|
40 |
+
gr.Audio(sources="microphone", type="filepath"),
|
41 |
+
gr.Audio(sources="upload", type="filepath"),
|
42 |
#"state"
|
43 |
+
],
|
44 |
+
outputs=[
|
45 |
+
"textbox"
|
46 |
# #"state"
|
47 |
+
],
|
48 |
+
title="Automatic Speech Recognition",
|
49 |
+
description = "Demo for Automatic Speech Recognition. Use microphone to record speech. Please press Record button. Initially it will take some time to load the model. The recognized text will appear in the output textbox",
|
50 |
+
).launch()
|
51 |
+
|
52 |
+
|
53 |
|
54 |
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
|