diff options
| author | Scott Gasch <[email protected]> | 2021-10-02 09:03:31 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2021-10-02 09:03:31 -0700 |
| commit | fa4298fa508e00759565c246aef423ba28fedf31 (patch) | |
| tree | 7afd570b762035564a6d45c1fcf03697e6ee9f79 /google_assistant.py | |
| parent | b0bde5bef4a19382136112196b238088641738d5 (diff) | |
changes
Diffstat (limited to 'google_assistant.py')
| -rw-r--r-- | google_assistant.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/google_assistant.py b/google_assistant.py index b34197a..572b4cc 100644 --- a/google_assistant.py +++ b/google_assistant.py @@ -2,6 +2,7 @@ import logging from typing import NamedTuple +import sys import requests import speech_recognition as sr # type: ignore @@ -94,13 +95,19 @@ def ask_google(cmd: str, *, recognize_speech=True) -> GoogleResponse: logger.exception(e) logger.warning('Unable to parse Google assistant\'s response.') audio_transcription = None + return GoogleResponse( + success=success, + response=response, + audio_url=audio, + audio_transcription=audio_transcription, + ) else: - logger.error( - f'HTTP request to {url} with {payload} failed; code {r.status_code}' + message = f'HTTP request to {url} with {payload} failed; code {r.status_code}' + logger.error(message) + return GoogleResponse( + success=False, + response=message, + audio_url=audio, + audio_transcription=audio_transcription, ) - return GoogleResponse( - success=success, - response=response, - audio_url=audio, - audio_transcription=audio_transcription, - ) + sys.exit(-1) |
