Spaces:
Runtime error
Runtime error
ThirdIringan
commited on
Commit
•
12e07a7
1
Parent(s):
75aee7b
Update app.py
Browse files
app.py
CHANGED
@@ -15,20 +15,27 @@ def asr(speech):
|
|
15 |
text = ""
|
16 |
equation = ""
|
17 |
symbols = {"plus":"+","minus":"-","times":"*","divide":"/"}
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
28 |
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
return transcript, equation, ans, model2(
|
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"),
|