cdactvm commited on
Commit
6dd1216
·
verified ·
1 Parent(s): bb2ae30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -3
app.py CHANGED
@@ -1,7 +1,41 @@
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  demo.launch()
 
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 = p(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.inputs.Audio(source="microphone", type="filepath"),
28
+ gr.inputs.Audio(source="upload", type="filepath", optional=True),
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()