From 853f14c8443cf47a495bea33fca587e0fbb0fd74 Mon Sep 17 00:00:00 2001 From: Mohammad Sadeq Sirjani Date: Tue, 13 Jun 2023 10:39:48 +0330 Subject: [PATCH] fix: handle Google Speech Recognition could not understand audio --- .idea/BarkTalk.iml | 2 +- .idea/misc.xml | 2 +- app.py | 7 ++++++- requirements.txt | Bin 1956 -> 1960 bytes 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.idea/BarkTalk.iml b/.idea/BarkTalk.iml index 848da22..86a0a88 100644 --- a/.idea/BarkTalk.iml +++ b/.idea/BarkTalk.iml @@ -7,7 +7,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index 90f665f..5021713 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/app.py b/app.py index 55e84fe..06ec2aa 100644 --- a/app.py +++ b/app.py @@ -61,12 +61,17 @@ def ask(language: str): os.remove(secure_file_path) + if prompt is None: + return jsonify({"data": None, + "message": "Google Speech Recognition could not understand audio", + "status": "success"}), 400 + engine = gpt_engine.GptEngine() answer_text = engine.command(prompt=prompt) exact_answer_voice_name = text_to_speech.convert(text=answer_text, - language=language) + language=language) data = { "prompt": prompt, diff --git a/requirements.txt b/requirements.txt index c9c44767c592bee63cbca82e44e7755c5377bdd7..a24deb053d9d1551a728dbe6b9f85e6bedc87140 100644 GIT binary patch delta 25 fcmZ3&zk+{*8auBcgC2tsgBg%CWH6ho&t3`uM(hOd delta 21 bcmZ3%zl48-8at;EgC2tc5F1T4W-kQ*HxdMc