cdactvm commited on
Commit
5baf1ba
·
verified ·
1 Parent(s): 9dbe68a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -35
app.py CHANGED
@@ -1,48 +1,57 @@
1
- #import gradio as gr
2
- #from transformers import pipeline
3
- #p1= pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-odia_v1")
 
 
 
4
 
5
- #def transcribe_odiya(speech):
6
- # #print (p1(speech))
7
- # text = p1(speech)["text"]
8
  #text=cleanhtml(text)
9
- # return text
10
- #def sel_lng(lng,mic=None, file=None):
11
- # if mic is not None:
12
- # audio = mic
13
- # elif file is not None:
14
- # audio = file
15
- # else:
16
- # return "You must either provide a mic recording or a file"
17
- # if (lng=="Odiya"):
18
- # return transcribe_odiya(audio)
 
 
 
 
 
 
 
 
 
 
19
 
20
 
21
- #demo=gr.Interface(
22
- # fn=sel_lng,
23
 
24
- # inputs=[
25
 
26
- # gr.Dropdown(["Odiya"],value="Odiya",label="Select Language"),
27
- # gr.Audio(sources="microphone", type="filepath"),
28
- # gr.Audio(sources="upload", type="filepath"),
29
  #"state"
30
- # ],
31
- # outputs=[
32
- # "textbox"
33
  # #"state"
34
- # ],
35
- # title="Automatic Speech Recognition",
36
- # 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",
37
- # ).launch()
 
 
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