From 4faa994d32223c8d560d9dad0ca90a3f7eb10d6a Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Wed, 28 Jul 2021 22:13:43 -0700 Subject: Money, Rate, CentCount and a bunch of bugfixes. --- google_assistant.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'google_assistant.py') diff --git a/google_assistant.py b/google_assistant.py index 71301e4..a50003c 100644 --- a/google_assistant.py +++ b/google_assistant.py @@ -79,10 +79,15 @@ def ask_google(cmd: str, *, recognize_speech=True) -> GoogleResponse: sample_rate=24000, sample_width=2, ) - audio_transcription = recognizer.recognize_google( - speech, - ) - logger.debug(f"Transcription: '{audio_transcription}'") + try: + audio_transcription = recognizer.recognize_google( + speech, + ) + logger.debug(f"Transcription: '{audio_transcription}'") + except sr.UnknownValueError as e: + logger.exception(e) + logger.warning('Unable to parse Google assistant\'s response.') + audio_transcription = None else: logger.error( f'HTTP request to {url} with {payload} failed; code {r.status_code}' -- cgit v1.3