diff options
| author | Scott Gasch <[email protected]> | 2021-07-28 22:13:43 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2021-07-28 22:13:43 -0700 |
| commit | 4faa994d32223c8d560d9dad0ca90a3f7eb10d6a (patch) | |
| tree | 1200e5615d94247a120b98a4ddceb2cd6674e0af /google_assistant.py | |
| parent | c79ecbf708a63a54a9c3e8d189b65d4794930082 (diff) | |
Money, Rate, CentCount and a bunch of bugfixes.
Diffstat (limited to 'google_assistant.py')
| -rw-r--r-- | google_assistant.py | 13 |
1 files changed, 9 insertions, 4 deletions
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}' |
