stash local debug statements
This commit is contained in:
parent
3011e5535e
commit
d59bce5107
|
@ -155,6 +155,7 @@ class Device:
|
||||||
|
|
||||||
async def play_audiosegments(self):
|
async def play_audiosegments(self):
|
||||||
"""Plays them sequentially."""
|
"""Plays them sequentially."""
|
||||||
|
print("play audiosegments called!!!")
|
||||||
|
|
||||||
mpv_command = ["mpv", "--no-cache", "--no-terminal", "--", "fd://0"]
|
mpv_command = ["mpv", "--no-cache", "--no-terminal", "--", "fd://0"]
|
||||||
mpv_process = subprocess.Popen(
|
mpv_process = subprocess.Popen(
|
||||||
|
@ -332,6 +333,7 @@ class Device:
|
||||||
self.fetch_image_from_camera()
|
self.fetch_image_from_camera()
|
||||||
|
|
||||||
async def message_sender(self, websocket):
|
async def message_sender(self, websocket):
|
||||||
|
print("message sender running!!!")
|
||||||
while True:
|
while True:
|
||||||
message = await asyncio.get_event_loop().run_in_executor(
|
message = await asyncio.get_event_loop().run_in_executor(
|
||||||
None, send_queue.get
|
None, send_queue.get
|
||||||
|
@ -354,6 +356,7 @@ class Device:
|
||||||
else:
|
else:
|
||||||
print("\nHold the spacebar to start recording. Press CTRL-C to exit.")
|
print("\nHold the spacebar to start recording. Press CTRL-C to exit.")
|
||||||
|
|
||||||
|
print("calling message sender")
|
||||||
asyncio.create_task(self.message_sender(websocket))
|
asyncio.create_task(self.message_sender(websocket))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
@ -430,10 +433,12 @@ class Device:
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
|
|
||||||
async def start_async(self):
|
async def start_async(self):
|
||||||
|
print("start async called!!!!")
|
||||||
# Configuration for WebSocket
|
# Configuration for WebSocket
|
||||||
WS_URL = f"ws://{self.server_url}"
|
WS_URL = f"ws://{self.server_url}"
|
||||||
# Start the WebSocket communication
|
# Start the WebSocket communication
|
||||||
await self.websocket_communication(WS_URL)
|
await self.websocket_communication(WS_URL)
|
||||||
|
print("ws communication called!")
|
||||||
|
|
||||||
# Start watching the kernel if it's your job to do that
|
# Start watching the kernel if it's your job to do that
|
||||||
if os.getenv("CODE_RUNNER") == "client":
|
if os.getenv("CODE_RUNNER") == "client":
|
||||||
|
@ -441,6 +446,7 @@ class Device:
|
||||||
asyncio.create_task(put_kernel_messages_into_queue(send_queue))
|
asyncio.create_task(put_kernel_messages_into_queue(send_queue))
|
||||||
|
|
||||||
asyncio.create_task(self.play_audiosegments())
|
asyncio.create_task(self.play_audiosegments())
|
||||||
|
print("play audiosegments called!!")
|
||||||
|
|
||||||
# If Raspberry Pi, add the button listener, otherwise use the spacebar
|
# If Raspberry Pi, add the button listener, otherwise use the spacebar
|
||||||
if current_platform.startswith("raspberry-pi"):
|
if current_platform.startswith("raspberry-pi"):
|
||||||
|
@ -469,8 +475,10 @@ class Device:
|
||||||
on_press=self.on_press, on_release=self.on_release
|
on_press=self.on_press, on_release=self.on_release
|
||||||
)
|
)
|
||||||
listener.start()
|
listener.start()
|
||||||
|
print("listener started!!!!!!!!")
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
print("start client called!")
|
||||||
if os.getenv("TEACH_MODE") != "True":
|
if os.getenv("TEACH_MODE") != "True":
|
||||||
asyncio.run(self.start_async())
|
asyncio.run(self.start_async())
|
||||||
p.terminate()
|
p.terminate()
|
||||||
|
|
|
@ -102,7 +102,7 @@ class AsyncInterpreter:
|
||||||
# print("ADDING TO QUEUE:", chunk)
|
# print("ADDING TO QUEUE:", chunk)
|
||||||
asyncio.create_task(self._add_to_queue(self._output_queue, chunk))
|
asyncio.create_task(self._add_to_queue(self._output_queue, chunk))
|
||||||
|
|
||||||
def generate(self, message, start_interpreter):
|
def generate(self, message):
|
||||||
last_lmc_start_flag = self._last_lmc_start_flag
|
last_lmc_start_flag = self._last_lmc_start_flag
|
||||||
self.interpreter.messages = self.active_chat_messages
|
self.interpreter.messages = self.active_chat_messages
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ class AsyncInterpreter:
|
||||||
# self.stt_latency = end_stt - start_stt
|
# self.stt_latency = end_stt - start_stt
|
||||||
# print("STT LATENCY", self.stt_latency)
|
# print("STT LATENCY", self.stt_latency)
|
||||||
|
|
||||||
# print(message)
|
print(message)
|
||||||
|
|
||||||
# Feed generate to RealtimeTTS
|
# Feed generate to RealtimeTTS
|
||||||
self.add_to_output_queue_sync(
|
self.add_to_output_queue_sync(
|
||||||
|
|
|
@ -56,13 +56,9 @@ async def main(server_host, server_port, tts_service, asynchronous):
|
||||||
print("🪼🪼🪼🪼🪼🪼 Messages loaded: ", interpreter.active_chat_messages)
|
print("🪼🪼🪼🪼🪼🪼 Messages loaded: ", interpreter.active_chat_messages)
|
||||||
return {"status": "success"}
|
return {"status": "success"}
|
||||||
|
|
||||||
print("About to set up the websocker endpoint!!!!!!!!!!!!!!!!!!!!!!!!!")
|
|
||||||
|
|
||||||
@app.websocket("/")
|
@app.websocket("/")
|
||||||
async def websocket_endpoint(websocket: WebSocket):
|
async def websocket_endpoint(websocket: WebSocket):
|
||||||
print("websocket hit")
|
|
||||||
await websocket.accept()
|
await websocket.accept()
|
||||||
print("websocket accepted")
|
|
||||||
|
|
||||||
async def send_output():
|
async def send_output():
|
||||||
try:
|
try:
|
||||||
|
@ -70,20 +66,17 @@ async def main(server_host, server_port, tts_service, asynchronous):
|
||||||
output = await interpreter.output()
|
output = await interpreter.output()
|
||||||
|
|
||||||
if isinstance(output, bytes):
|
if isinstance(output, bytes):
|
||||||
print("server sending bytes output")
|
|
||||||
try:
|
try:
|
||||||
await websocket.send_bytes(output)
|
await websocket.send_bytes(output)
|
||||||
print("server successfully sent bytes output")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error: {e}")
|
print(f"Error: {e}")
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return {"error": str(e)}
|
return {"error": str(e)}
|
||||||
|
|
||||||
elif isinstance(output, dict):
|
elif isinstance(output, dict):
|
||||||
print("server sending text output")
|
|
||||||
try:
|
try:
|
||||||
await websocket.send_text(json.dumps(output))
|
await websocket.send_text(json.dumps(output))
|
||||||
print("server successfully sent text output")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error: {e}")
|
print(f"Error: {e}")
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
@ -129,24 +122,8 @@ async def main(server_host, server_port, tts_service, asynchronous):
|
||||||
send_task = asyncio.create_task(send_output())
|
send_task = asyncio.create_task(send_output())
|
||||||
receive_task = asyncio.create_task(receive_input())
|
receive_task = asyncio.create_task(receive_input())
|
||||||
|
|
||||||
print("server starting to handle ws connection")
|
|
||||||
"""
|
|
||||||
done, pending = await asyncio.wait(
|
|
||||||
[send_task, receive_task],
|
|
||||||
return_when=asyncio.FIRST_COMPLETED,
|
|
||||||
)
|
|
||||||
|
|
||||||
for task in pending:
|
|
||||||
task.cancel()
|
|
||||||
|
|
||||||
for task in done:
|
|
||||||
if task.exception() is not None:
|
|
||||||
raise
|
|
||||||
"""
|
|
||||||
await asyncio.gather(send_task, receive_task)
|
await asyncio.gather(send_task, receive_task)
|
||||||
|
|
||||||
print("server finished handling ws connection")
|
|
||||||
|
|
||||||
except WebSocketDisconnect:
|
except WebSocketDisconnect:
|
||||||
print("WebSocket disconnected")
|
print("WebSocket disconnected")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -176,6 +176,7 @@ def _run(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
server_thread.start()
|
server_thread.start()
|
||||||
|
print("server thread started")
|
||||||
|
|
||||||
if expose:
|
if expose:
|
||||||
tunnel_thread = threading.Thread(
|
tunnel_thread = threading.Thread(
|
||||||
|
@ -208,6 +209,7 @@ def _run(
|
||||||
target=module.main, args=[server_url, tts_service]
|
target=module.main, args=[server_url, tts_service]
|
||||||
)
|
)
|
||||||
client_thread.start()
|
client_thread.start()
|
||||||
|
print("client thread started")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if server:
|
if server:
|
||||||
|
|
Loading…
Reference in New Issue