ThirdIringan commited on
Commit
12e07a7
1 Parent(s): 75aee7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -12
app.py CHANGED
@@ -15,20 +15,27 @@ def asr(speech):
15
  text = ""
16
  equation = ""
17
  symbols = {"plus":"+","minus":"-","times":"*","divide":"/"}
18
- for i in range(len(strings)):
19
- if strings[i].lower() in symbols:
20
- text = wordtodigits.convert(text)
21
- equation += text + symbols[strings[i].lower()]
22
- text=""
23
- continue
24
- text += strings[i].lower() + " "
25
- if i == len(strings)-1:
26
- text = wordtodigits.convert(text)
27
- equation += text
 
28
 
29
- ans = round(eval(equation),2)
 
 
 
 
 
 
30
 
31
- return transcript, equation, ans, model2("The answer is "+str(ans))
32
 
33
  gr.Interface(fn=asr,
34
  #inputs = gr.inputs.Audio(source="microphone", type="filepath", optional=False, label="Please record your voice"),
 
15
  text = ""
16
  equation = ""
17
  symbols = {"plus":"+","minus":"-","times":"*","divide":"/"}
18
+ try:
19
+ for i in range(len(strings)):
20
+ if strings[i].lower() in symbols:
21
+ text = wordtodigits.convert(text)
22
+ equation += text + symbols[strings[i].lower()]
23
+ text=""
24
+ continue
25
+ text += strings[i].lower() + " "
26
+ if i == len(strings)-1:
27
+ text = wordtodigits.convert(text)
28
+ equation += text
29
 
30
+ ans = round(eval(equation),2)
31
+ speech = "The answer is "+str(ans)
32
+ except:
33
+ transcript = "Error in Translation/Format of Audio"
34
+ equation = "Error in Translation/Format of Audio"
35
+ ans = "Error in Translation/Format of Audio"
36
+ speech = "Error in Translation/Format of Audio"
37
 
38
+ return transcript, equation, ans, model2(speech)
39
 
40
  gr.Interface(fn=asr,
41
  #inputs = gr.inputs.Audio(source="microphone", type="filepath", optional=False, label="Please record your voice"),