Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -21,8 +21,13 @@ def process_math(query):
|
|
21 |
result_text = f"The result is: {result}"
|
22 |
tts = gTTS(result_text, lang="en")
|
23 |
tts.save("response.mp3")
|
24 |
-
os.system("start response.mp3" if os.name == "nt" else "afplay response.mp3") # Play the speech output
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
return result_text
|
27 |
except Exception as e:
|
28 |
return f"Error: Unable to process the query. Please check the syntax. Error: {e}"
|
|
|
21 |
result_text = f"The result is: {result}"
|
22 |
tts = gTTS(result_text, lang="en")
|
23 |
tts.save("response.mp3")
|
|
|
24 |
|
25 |
+
# For Windows, we can use 'start' to play the file, for MacOS/Linux 'afplay' works
|
26 |
+
if os.name == "nt": # Windows
|
27 |
+
os.system("start response.mp3")
|
28 |
+
else: # macOS/Linux
|
29 |
+
os.system("afplay response.mp3") # For macOS/Linux, you may need to use 'mpg123' or other audio players
|
30 |
+
|
31 |
return result_text
|
32 |
except Exception as e:
|
33 |
return f"Error: Unable to process the query. Please check the syntax. Error: {e}"
|