fix: added tom's fixes

pull/38/head
Shiven Mian 11 months ago
parent cb628fa314
commit 86975c4026

1
.gitignore vendored

@ -167,3 +167,4 @@ cython_debug/
# ignore the aifs index files
_.aifs
01OS/output_audio.wav

@ -50,7 +50,7 @@ send_queue = queue.Queue()
class Device:
def __init__(self):
pass
self.pressed_keys = set()
def record_audio(self):
@ -125,12 +125,21 @@ class Device:
RECORDING = False
def on_press(self, key):
"""Detect spacebar press."""
if key == keyboard.Key.space:
"""Detect spacebar press, ESC key press, and Ctrl+C combination."""
self.pressed_keys.add(key) # Add the pressed key to the set
if keyboard.Key.esc in self.pressed_keys:
logger.info("Exiting...")
os._exit(0)
elif keyboard.Key.space in self.pressed_keys:
self.toggle_recording(True)
elif {keyboard.Key.ctrl, keyboard.KeyCode.from_char('c')} <= self.pressed_keys:
logger.info("Ctrl+C pressed. Exiting...")
os._exit(0)
def on_release(self, key):
"""Detect spacebar release and ESC key press."""
self.pressed_keys.discard(key) # Remove the released key from the key press tracking set
if key == keyboard.Key.space:
self.toggle_recording(False)
elif key == keyboard.Key.esc or (key == keyboard.Key.ctrl and keyboard.Key.c):

@ -1,8 +1,8 @@
DEVICE=$(uname -n)
if [[ "$DEVICE" == "rpi" ]]; then
cd 01OS
python -m 01OS.clients.rpi.device &
python -m 01OS.clients.rpi.device
else
cd 01OS
python -m 01OS.clients.macos.device &
python -m 01OS.clients.macos.device
fi

@ -1,5 +1,12 @@
#!/usr/bin/env bash
# Set python to prioritize the module files from the current directory
# If we don't do this, then the python interpreter will not be able to find the modules,
# and will throw an error like "ModuleNotFoundError: No module named '01OS'".
# If we solve the problem by pip installing the official 01OS package, then those
# modules will run instead of the local ones that we are trying to develop with.
export PYTHONPATH="$(pwd):$PYTHONPATH"
### Import Environment Variables from .env
SCRIPT_DIR="$(dirname "$0")"
if [ ! -f "$SCRIPT_DIR/.env" ]; then

Loading…
Cancel
Save