Better errors, bug fix

pull/39/head
killian 11 months ago
parent 3571382a9f
commit 1b68f14a7a

@ -128,8 +128,11 @@ class Device:
play(audio) play(audio)
self.audiosegments.remove(audio) self.audiosegments.remove(audio)
await asyncio.sleep(0.1) await asyncio.sleep(0.1)
except asyncio.exceptions.CancelledError:
# This happens once at the start?
pass
except: except:
logger.debug(f"Non fatal error, retrying: ", traceback.format_exc()) logger.info(traceback.format_exc())
def record_audio(self): def record_audio(self):
@ -282,7 +285,7 @@ class Device:
except: except:
logger.debug(f"Non fatal error, retrying: ", traceback.format_exc()) logger.debug(traceback.format_exc())
logger.info(f"Connecting to `{WS_URL}`...") logger.info(f"Connecting to `{WS_URL}`...")
await asyncio.sleep(2) await asyncio.sleep(2)

@ -102,7 +102,7 @@ async def websocket_endpoint(websocket: WebSocket):
try: try:
await asyncio.gather(receive_task, send_task) await asyncio.gather(receive_task, send_task)
except Exception as e: except Exception as e:
logger.debug(f"Non fatal error, retrying: ", traceback.format_exc()) logger.debug(traceback.format_exc())
logger.info(f"Connection lost. Error: {e}") logger.info(f"Connection lost. Error: {e}")
async def receive_messages(websocket: WebSocket): async def receive_messages(websocket: WebSocket):

@ -17,6 +17,10 @@ class Accumulator:
return None return None
if "content" in chunk: if "content" in chunk:
# Display
print(chunk['content'], end="", flush=True)
if any(self.message[key] != chunk[key] for key in self.message if key != "content"): if any(self.message[key] != chunk[key] for key in self.message if key != "content"):
self.message = chunk self.message = chunk
if "content" not in self.message: if "content" not in self.message:

Loading…
Cancel
Save