summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsrddyn@gmail.com <nsrddyn@gmail.com>2024-10-23 09:35:29 +0200
committernsrddyn@gmail.com <nsrddyn@gmail.com>2024-10-23 09:35:29 +0200
commit6198d0333d432b4e0dad7e8da2c2395473a12995 (patch)
treef049031b60bbec1c132892da70466bfa6c4adbf4
parent9ee6cc3e55aa855b0f2daa1db9a162d8bac0e864 (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
-rw-r--r--sec.py55
1 files changed, 45 insertions, 10 deletions
diff --git a/sec.py b/sec.py
index 1db8683..a8685b7 100644
--- a/sec.py
+++ b/sec.py
@@ -1,18 +1,24 @@
1# A speach transcriber using the google speech recognizer and then dsplaying it on the lcd of a raspberry pi 1# A speach transcriber using the google speech recognizer and then dsplaying it on the lcd of a raspberry pi
2 2
3from rpi_lcd import LCD 3from rpi_lcd import LCD
4fro 4import RPi.GPIO as GPIO
5import speech_recognition as sr 5import speech_recognition as sr
6from time import sleep 6from time import sleep
7import sounddevice 7import sounddevice
8from motion import comp 8import os
9 9
10r = sr.Recognizer() 10r = sr.Recognizer()
11lcd = LCD() 11lcd = LCD()
12mic = sr.Microphone() 12mic = sr.Microphone()
13 13
14# Clearing the lcd before starting the program 14beepPin = 17
15lcd.clear() 15allow = False
16
17def stream():
18 print("starting live steam")
19 # starting the motion live stream
20 os.system('motion')
21
16 22
17# Listening to the user's voice and putting it into a variable 23# Listening to the user's voice and putting it into a variable
18def listen_voice(): 24def listen_voice():
@@ -33,18 +39,47 @@ def recognize_speech(audio):
33 words = r.recognize_google(audio) 39 words = r.recognize_google(audio)
34 lcd.text(words, 1) 40 lcd.text(words, 1)
35 print(f"Printing on screen: {words}") 41 print(f"Printing on screen: {words}")
42 password = "linux"
43 while allow == False:
44 if words == password:
45 allow = True
46 print("That's the password!!!")
47 stream()
48
36 except sr.UnknownValueError: 49 except sr.UnknownValueError:
37 lcd.text(error, 1) 50 lcd.text(error, 1)
38 print(error) 51 print(error)
39 except sr.RequestError: 52 except sr.RequestError:
40 lcd.text(r_error, 1) 53 lcd.text(r_error, 1)
41 print(r_error) 54 print(r_error)
42 55
43 56def setup():
44while True: 57 print("clearing the lcd screen")
45 audio = listen_voice() 58 lcd.clear()
46 recognize_speech(audio) 59 print("setting up the system")
60 GPIO.setmode(GPIO.BCM)
61 GPIO.setup(beepPin, GPIO.OUT, initial=GPIO.HIGH)
47 62
63def main():
64 while True:
65 audio = listen_voice()
66 recognize_speech(audio)
67 GPIO.output(beepPin,GPIO.HIGH)
68 sleep(0.5)
69 GPIO.output(beepPin,GPIO.LOW)
48 70
49 71
50 72
73def destroy():
74 lcd.clear()
75
76if __name__ == '__main__':
77 # Clearing the lcd before starting the program
78
79 print("setting up the alarm")
80 setup()
81 try:
82 main()
83 except KeyboardInterrupt:
84 destroy()
85