Spaces:
Sleeping
Sleeping
Yurii Paniv
commited on
Commit
•
4b03cbe
1
Parent(s):
e0ad04f
Add error handling to Telegram bot API
Browse files
main.py
CHANGED
@@ -79,13 +79,17 @@ def process_voice_message(message):
|
|
79 |
|
80 |
# do the recognition
|
81 |
# get the recognized text
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
89 |
|
90 |
|
91 |
if __name__ == '__main__':
|
|
|
79 |
|
80 |
# do the recognition
|
81 |
# get the recognized text
|
82 |
+
try:
|
83 |
+
text = client(output_audio)
|
84 |
+
# no results
|
85 |
+
if not text:
|
86 |
+
bot.reply_to(message, 'Я не зміг розпізнати 😢')
|
87 |
+
else:
|
88 |
+
# send the recognized text
|
89 |
+
bot.reply_to(message, text)
|
90 |
+
except Exception as e:
|
91 |
+
logging.log(logging.ERROR, str(e))
|
92 |
+
bot.reply_to(message, 'Трапилась помилка 😢')
|
93 |
|
94 |
|
95 |
if __name__ == '__main__':
|