-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeechcommands.py
More file actions
33 lines (27 loc) · 1.35 KB
/
speechcommands.py
File metadata and controls
33 lines (27 loc) · 1.35 KB
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
"""
o 8
8 8
.oPYo. o o o8P 8oPYo. .oPYo. odYo.
8 8 8 8 8 8 8 8 8 8' `8
8 8 8 8 8 8 8 8 8 8 8
8YooP' `YooP8 8 8 8 `YooP' 8 8
8 ....::....8 ::..:..:::..:.....:..::..
8 :::::::ooP'.:::::::::::::::::::::::::
..:::::::...:::::::::::::::A7MD0V:::::::
::::Python Learning::::::::::::15:03:17:::
::::::;; Speech Commands ;;:::::::::::::::
"""
# Download SR: pip install SpeechRecognition PyAudio
# Implement PyAutoGUI for speech to commands
import speech_recognition as sr
# get real time audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
print("Speak:")
audio = r.listen(source)
try:
print("You said " + r.recognize_google(audio))
except sr.UnknownValueError:
print("Could not understand audio")
except sr.RequestError as e:
print("Could not request results; {0}".format(e))