fix: added tom's fixes
This commit is contained in:
parent
cb628fa314
commit
86975c4026
|
@ -167,3 +167,4 @@ cython_debug/
|
||||||
|
|
||||||
# ignore the aifs index files
|
# ignore the aifs index files
|
||||||
_.aifs
|
_.aifs
|
||||||
|
01OS/output_audio.wav
|
|
@ -50,7 +50,7 @@ send_queue = queue.Queue()
|
||||||
|
|
||||||
class Device:
|
class Device:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
self.pressed_keys = set()
|
||||||
|
|
||||||
def record_audio(self):
|
def record_audio(self):
|
||||||
|
|
||||||
|
@ -125,12 +125,21 @@ class Device:
|
||||||
RECORDING = False
|
RECORDING = False
|
||||||
|
|
||||||
def on_press(self, key):
|
def on_press(self, key):
|
||||||
"""Detect spacebar press."""
|
"""Detect spacebar press, ESC key press, and Ctrl+C combination."""
|
||||||
if key == keyboard.Key.space:
|
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)
|
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):
|
def on_release(self, key):
|
||||||
"""Detect spacebar release and ESC key press."""
|
"""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:
|
if key == keyboard.Key.space:
|
||||||
self.toggle_recording(False)
|
self.toggle_recording(False)
|
||||||
elif key == keyboard.Key.esc or (key == keyboard.Key.ctrl and keyboard.Key.c):
|
elif key == keyboard.Key.esc or (key == keyboard.Key.ctrl and keyboard.Key.c):
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
DEVICE=$(uname -n)
|
DEVICE=$(uname -n)
|
||||||
if [[ "$DEVICE" == "rpi" ]]; then
|
if [[ "$DEVICE" == "rpi" ]]; then
|
||||||
cd 01OS
|
cd 01OS
|
||||||
python -m 01OS.clients.rpi.device &
|
python -m 01OS.clients.rpi.device
|
||||||
else
|
else
|
||||||
cd 01OS
|
cd 01OS
|
||||||
python -m 01OS.clients.macos.device &
|
python -m 01OS.clients.macos.device
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/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
|
### Import Environment Variables from .env
|
||||||
SCRIPT_DIR="$(dirname "$0")"
|
SCRIPT_DIR="$(dirname "$0")"
|
||||||
if [ ! -f "$SCRIPT_DIR/.env" ]; then
|
if [ ! -f "$SCRIPT_DIR/.env" ]; then
|
||||||
|
|
Loading…
Reference in New Issue