Skip to content

Commit 83f6981

Browse files
authored
Create SpeechRecogniter.py
1 parent d6e1e90 commit 83f6981

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src_A2/SpeechRecogniter.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import speech_recognition as recogniter
2+
import VoiceEngine
3+
import sys
4+
5+
listener = recogniter.Recognizer()
6+
header = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0'}
7+
output = ""
8+
9+
10+
def getinput():
11+
command = "null"
12+
try:
13+
with recogniter.Microphone() as source:
14+
print("Ready For Commands")
15+
voice = listener.listen(source)
16+
command = listener.recognize_google(voice)
17+
command = str(command).lower()
18+
print(command)
19+
VoiceEngine.say(command)
20+
21+
if command == "stop":
22+
#stop_event.set()
23+
pass
24+
elif command == "exit" or command == "kill" or command == "end process" :
25+
VoiceEngine.say("Shutding Down")
26+
sys.exit()
27+
28+
except Exception as e:
29+
pass
30+
31+
if command is not None and command != "null" :
32+
return str(command).lower()
33+
else:
34+
getinput()

0 commit comments

Comments
 (0)