|
|
|
@ -155,6 +155,7 @@ class Device:
|
|
|
|
|
|
|
|
|
|
async def play_audiosegments(self):
|
|
|
|
|
"""Plays them sequentially."""
|
|
|
|
|
print("play audiosegments called!!!")
|
|
|
|
|
|
|
|
|
|
mpv_command = ["mpv", "--no-cache", "--no-terminal", "--", "fd://0"]
|
|
|
|
|
mpv_process = subprocess.Popen(
|
|
|
|
@ -332,6 +333,7 @@ class Device:
|
|
|
|
|
self.fetch_image_from_camera()
|
|
|
|
|
|
|
|
|
|
async def message_sender(self, websocket):
|
|
|
|
|
print("message sender running!!!")
|
|
|
|
|
while True:
|
|
|
|
|
message = await asyncio.get_event_loop().run_in_executor(
|
|
|
|
|
None, send_queue.get
|
|
|
|
@ -354,6 +356,7 @@ class Device:
|
|
|
|
|
else:
|
|
|
|
|
print("\nHold the spacebar to start recording. Press CTRL-C to exit.")
|
|
|
|
|
|
|
|
|
|
print("calling message sender")
|
|
|
|
|
asyncio.create_task(self.message_sender(websocket))
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
@ -430,10 +433,12 @@ class Device:
|
|
|
|
|
await asyncio.sleep(2)
|
|
|
|
|
|
|
|
|
|
async def start_async(self):
|
|
|
|
|
print("start async called!!!!")
|
|
|
|
|
# Configuration for WebSocket
|
|
|
|
|
WS_URL = f"ws://{self.server_url}"
|
|
|
|
|
# Start the WebSocket communication
|
|
|
|
|
await self.websocket_communication(WS_URL)
|
|
|
|
|
print("ws communication called!")
|
|
|
|
|
|
|
|
|
|
# Start watching the kernel if it's your job to do that
|
|
|
|
|
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(self.play_audiosegments())
|
|
|
|
|
print("play audiosegments called!!")
|
|
|
|
|
|
|
|
|
|
# If Raspberry Pi, add the button listener, otherwise use the spacebar
|
|
|
|
|
if current_platform.startswith("raspberry-pi"):
|
|
|
|
@ -469,8 +475,10 @@ class Device:
|
|
|
|
|
on_press=self.on_press, on_release=self.on_release
|
|
|
|
|
)
|
|
|
|
|
listener.start()
|
|
|
|
|
print("listener started!!!!!!!!")
|
|
|
|
|
|
|
|
|
|
def start(self):
|
|
|
|
|
print("start client called!")
|
|
|
|
|
if os.getenv("TEACH_MODE") != "True":
|
|
|
|
|
asyncio.run(self.start_async())
|
|
|
|
|
p.terminate()
|
|
|
|
|