diff --git a/latex/pilight.zip b/latex/pilight.zip index e001f72..ff6bc68 100644 Binary files a/latex/pilight.zip and b/latex/pilight.zip differ diff --git a/pilight.pdf b/pilight.pdf new file mode 100644 index 0000000..bffdf5a Binary files /dev/null and b/pilight.pdf differ diff --git a/py/led.py b/py/led.py index 16fc1e8..09e617f 100644 --- a/py/led.py +++ b/py/led.py @@ -1,11 +1,12 @@ import RPi.GPIO as GPIO import time -LED_PIN = 17 +LED_PIN = 17 # GPIO phisical pin GPIO.setmode(GPIO.BCM) GPIO.setup(LED_PIN, GPIO.OUT) +# Alternate every second, turning an LED on and off. Stopped by CTRL+C try: while True: GPIO.output(LED_PIN, GPIO.HIGH) diff --git a/py/speech.py b/py/speech.py index 2f85b05..2d8fbf9 100644 --- a/py/speech.py +++ b/py/speech.py @@ -2,9 +2,11 @@ import speech_recognition as sr recognizer = sr.Recognizer() with sr.Microphone() as source: + # audio input print("Say something...") audio = recognizer.listen(source) try: + # runs the live recored audio through PocketSphinx and print it as text text = recognizer.recognize_sphinx(audio) print("Sphinx recognized: {}".format(text)) except sr.UnknownValueError: diff --git a/py/speech_coltrol_led.py b/py/speech_coltrol_led.py index ef67042..d369bcf 100644 --- a/py/speech_coltrol_led.py +++ b/py/speech_coltrol_led.py @@ -2,25 +2,30 @@ import speech_recognition as sr import RPi.GPIO as GPIO import time -LED_PIN = 17 +LED_PIN = 17 # Number of GPIO physical pin # GPIO setup GPIO.setmode(GPIO.BCM) GPIO.setup(LED_PIN, GPIO.OUT) +# turn LED on or off with correct command def trigger_action(command): + # turn LED on with command fire if "fire" in command.lower(): GPIO.output(LED_PIN, GPIO.HIGH) print("Light ON") + # turn LED off with command night elif "night" in command.lower(): GPIO.output(LED_PIN, GPIO.LOW) print("Light OFF") recognizer = sr.Recognizer() with sr.Microphone() as source: + # audio input print("Say a command...") audio = recognizer.listen(source) try: + # runs the live recored audio through PocketSphinx. Send the iterpreted audio as text to function trigger_action cmd = recognizer.recognize_sphinx(audio) print("Command: {}".format(cmd)) trigger_action(cmd)