def __init__(self, client_secret_file="client_secret.json"):
self.credentials = None
self.credentials_pickle = "./credentials.pickle"
+ self.client_secret_file = client_secret_file
if os.path.exists(self.credentials_pickle):
logger.debug(
f"Refreshing credentials from disk pickle file {self.credentials_pickle}"
self.credentials = pickle.load(open(self.credentials_pickle, "rb"))
else:
logger.debug(f"{self.credentials_pickle} does not exist; calling Google.")
- self.refresh_credentials(client_secret_file)
+ self.refresh_credentials(self.client_secret_file)
self.save()
assert self.credentials is not None
except gkeepapi.exception.LoginException:
logger.warning("Invalid token, attempting to re-login.")
- if not self.keep.login(
+ self.keep.authenticate(
secrets.google_keep_username,
- secrets.google_keep_password,
- secrets.google_keep_mac,
- ):
- raise Exception("Error connecting with Google Keep?!")
+ secrets.google_keep_token,
+ )
+ self.keep.sync()
logger.debug("Successfully logged in with Google Keep")
def debug_prefix(self) -> str:
# Test
-# logger.setLevel(logging.DEBUG)
-# ch = logging.StreamHandler()
-# ch.setLevel(logging.DEBUG)
-# formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
-# ch.setFormatter(formatter)
-# logger.addHandler(ch)
-# x = gkeep_renderer({"Test", 1234})
-# x.periodic_render("Test")
+#logger.setLevel(logging.DEBUG)
+#ch = logging.StreamHandler()
+#ch.setLevel(logging.DEBUG)
+#formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+#ch.setFormatter(formatter)
+#logger.addHandler(ch)
+#x = gkeep_renderer({"Test", 1234})
+#x.periodic_render("Test")
recognizer = sr.Recognizer()
pa = pyaudio.PyAudio()
+# audio_stream = pa.open(
+# rate=porcupine.sample_rate,
+# channels=1,
+# format=pyaudio.paInt16,
+# input=True,
+# frames_per_buffer=porcupine.frame_length,
+# input_device_index=self._input_device_index,
+# )
audio_stream = pa.open(
- rate=porcupine.sample_rate,
- channels=1,
format=pyaudio.paInt16,
+ channels=2, # kiosk_mic (plug) will downmix for you
+ rate=16000, # kiosk_mic (plug) will resample for you
input=True,
- frames_per_buffer=porcupine.frame_length,
- input_device_index=self._input_device_index,
+ input_device_index=7, # <--- Your new kiosk_mic index
+ frames_per_buffer=1024
)
logger.info("Listening {")
if len(self.candidate_photos) == 0:
print("No photos!")
return False
- path = random.sample(self.candidate_photos, 1)[0]
+ path = random.sample(list(self.candidate_photos), 1)[0]
with file_writer.file_writer("photo_23_3600.html") as f:
f.write(
"""
key_path = None
home = os.environ.get('HOME', '/home/scott')
filename = f'{home}/gasch_certificate/dmzjail-scott-selfsigned.crt'
- if os.exists(filename):
- cert_path = filename
filename = f'{home}/gasch_certificate/dmzjail-scott-selfsigned.key'
- if os.exists(filename):
- key_path = filename
key = secrets.homeassistant_api_key
headers = {
"Authorization": f"Bearer {key}",