X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;ds=inline;f=google_assistant.py;h=ec5f6a4c85e17ed0fb2eaaf4f2f22d8ee2ebf300;hb=31c81f6539969a5eba864d3305f9fb7bf716a367;hp=49c08d3c5efded9bc61e8f647d4c1deff98f5768;hpb=55a3172e37855f388b9ba0dfc91641a6c9ad1376;p=python_utils.git diff --git a/google_assistant.py b/google_assistant.py index 49c08d3..ec5f6a4 100644 --- a/google_assistant.py +++ b/google_assistant.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 import logging -from typing import NamedTuple import sys import warnings +from typing import NamedTuple, Optional import requests import speech_recognition as sr # type: ignore @@ -21,14 +21,14 @@ parser.add_argument( type=str, default="http://kiosk.house:3000", metavar="URL", - help="How to contact the Google Assistant bridge" + help="How to contact the Google Assistant bridge", ) parser.add_argument( "--google_assistant_username", type=str, metavar="GOOGLE_ACCOUNT", default="scott.gasch", - help="The user account for talking to Google Assistant" + help="The user account for talking to Google Assistant", ) @@ -36,7 +36,7 @@ class GoogleResponse(NamedTuple): success: bool response: str audio_url: str - audio_transcription: str + audio_transcription: Optional[str] # None if not available. def __repr__(self): return f""" @@ -67,7 +67,7 @@ def ask_google(cmd: str, *, recognize_speech=True) -> GoogleResponse: success = False response = "" audio = "" - audio_transcription = "" + audio_transcription: Optional[str] = "" if r.status_code == 200: j = r.json() success = bool(j["success"])