summaryrefslogtreecommitdiff
path: root/sec.py
diff options
context:
space:
mode:
Diffstat (limited to 'sec.py')
-rw-r--r--sec.py83
1 files changed, 0 insertions, 83 deletions
diff --git a/sec.py b/sec.py
deleted file mode 100644
index 0afd67f..0000000
--- a/sec.py
+++ /dev/null
@@ -1,83 +0,0 @@
1# A speach transcriber using the google speech recognizer and then dsplaying it on the lcd of a raspberry pi
2
3from rpi_lcd import LCD
4import RPi.GPIO as GPIO
5import speech_recognition as sr
6from time import sleep
7import sounddevice
8import os
9
10r = sr.Recognizer()
11lcd = LCD()
12mic = sr.Microphone()
13
14beepPin = 17
15allow = False
16
17def stream():
18 print("starting live steam")
19 # starting the motion live stream
20 os.system('motion')
21
22# Listening to the user's voice and putting it into a variable
23def listen_voice():
24 global audio
25 with mic as source:
26 r.adjust_for_ambient_noise(source)
27 audio = r.listen(source)
28 return audio
29
30# Transcribing the audio to text and printing it out
31# Using the google speech recognizer
32# Google speech recognizer does require a internet connection
33def recognize_speech(audio):
34 error = "400"
35 r_error = "401"
36
37 try:
38 words = r.recognize_google(audio)
39 lcd.text(words, 1)
40 print(f"Printing on screen: {words}")
41 password = "linux"
42 while allow == False:
43 if words == password:
44 allow = True
45 print("That's the password!!!")
46 stream()
47
48 except sr.UnknownValueError:
49 lcd.text(error, 1)
50 print(error)
51 except sr.RequestError:
52 lcd.text(r_error, 1)
53 print(r_error)
54
55def setup():
56 print("clearing the lcd screen")
57 lcd.clear()
58 print("setting up the system")
59 GPIO.setmode(GPIO.BCM)
60 GPIO.setup(beepPin, GPIO.OUT, initial=GPIO.HIGH)
61
62def main():
63 while True:
64 audio = listen_voice()
65 recognize_speech(audio)
66 GPIO.output(beepPin,GPIO.HIGH)
67 sleep(0.5)
68 GPIO.output(beepPin,GPIO.LOW)
69
70
71
72def destroy():
73 lcd.clear()
74
75if __name__ == '__main__':
76 # Clearing the lcd before starting the program
77
78 print("setting up the alarm")
79 setup()
80 try:
81 main()
82 except KeyboardInterrupt:
83 destroy()