Used isort to sort imports. Also added to the git pre-commit hook.
[python_utils.git] / google_assistant.py
index b92f443d6744882ddaa56418ed992b39b33c8568..ec5f6a4c85e17ed0fb2eaaf4f2f22d8ee2ebf300 100644 (file)
@@ -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
@@ -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"])