diff options
| author | nsrddyn@gmail.com <nsrddyn@gmail.com> | 2024-10-23 09:35:29 +0200 |
|---|---|---|
| committer | nsrddyn@gmail.com <nsrddyn@gmail.com> | 2024-10-23 09:35:29 +0200 |
| commit | 6198d0333d432b4e0dad7e8da2c2395473a12995 (patch) | |
| tree | f049031b60bbec1c132892da70466bfa6c4adbf4 /sec.py | |
| parent | 9ee6cc3e55aa855b0f2daa1db9a162d8bac0e864 (diff) | |
added most of the function only thing i need to do now i seem to link them in some way and then also define the real io pin im going to use and also think about a good use case for the security system
Diffstat (limited to 'sec.py')
| -rw-r--r-- | sec.py | 55 |
1 files changed, 45 insertions, 10 deletions
@@ -1,18 +1,24 @@ # A speach transcriber using the google speech recognizer and then dsplaying it on the lcd of a raspberry pi from rpi_lcd import LCD -fro +import RPi.GPIO as GPIO import speech_recognition as sr from time import sleep import sounddevice -from motion import comp +import os r = sr.Recognizer() lcd = LCD() mic = sr.Microphone() -# Clearing the lcd before starting the program -lcd.clear() +beepPin = 17 +allow = False + +def stream(): + print("starting live steam") + # starting the motion live stream + os.system('motion') + # Listening to the user's voice and putting it into a variable def listen_voice(): @@ -33,18 +39,47 @@ def recognize_speech(audio): words = r.recognize_google(audio) lcd.text(words, 1) print(f"Printing on screen: {words}") + password = "linux" + while allow == False: + if words == password: + allow = True + print("That's the password!!!") + stream() + except sr.UnknownValueError: lcd.text(error, 1) print(error) except sr.RequestError: lcd.text(r_error, 1) print(r_error) - - -while True: - audio = listen_voice() - recognize_speech(audio) + +def setup(): + print("clearing the lcd screen") + lcd.clear() + print("setting up the system") + GPIO.setmode(GPIO.BCM) + GPIO.setup(beepPin, GPIO.OUT, initial=GPIO.HIGH) +def main(): + while True: + audio = listen_voice() + recognize_speech(audio) + GPIO.output(beepPin,GPIO.HIGH) + sleep(0.5) + GPIO.output(beepPin,GPIO.LOW) - + +def destroy(): + lcd.clear() + +if __name__ == '__main__': + # Clearing the lcd before starting the program + + print("setting up the alarm") + setup() + try: + main() + except KeyboardInterrupt: + destroy() + |
