-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.py
46 lines (38 loc) · 1.15 KB
/
start.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
# NOTE: this example requires PyAudio because it uses the Microphone class
import speech_recognition as sr
import lucy as lucy
from config import *
from lucy import parseQuestion
activated = True
while activated:
if speech_mode == 'true':
userIn = input("Click enter to enable: ")
# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
try:
text = r.recognize_google(audio)
except:
lucy.speakError()
print("Error")
try:
print('4')
if text.lower() == 'turn off':
activated = False
print('1')
else:
lucy.parseQuestion(text)
print('2')
except:
print('3')
# lucy.speakError()
elif speech_mode=='false':
print("Say something!")
userIn = input()
if userIn.lower() == 'turn off' or 'exit':
activated = False
else:
lucy.parseQuestion(userIn)