documentation finalized. Added comments to scripts. Updated README. Updated latex source files.
This commit is contained in:
parent
b62a5a06f6
commit
bc166715b7
Binary file not shown.
BIN
pilight.pdf
Normal file
BIN
pilight.pdf
Normal file
Binary file not shown.
@ -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)
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user