Created
November 20, 2019 22:20
-
-
Save nickcjohnston/47503443a71332f213dd797719d18073 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Requires | |
# pip3 SpeechRecognition | |
# apt python-pyaudio python3-pyaudio | |
import speech_recognition as sr | |
recog = sr.Recognizer() | |
mic = sr.Microphone(device_index=6) | |
while True: | |
with mic as source: | |
recog.adjust_for_ambient_noise(source) | |
audio = recog.listen(source) | |
resp = recog.recognize_google(audio) | |
resp = resp.split() | |
# command: new group GROUPNAME | |
if ("new" and "group") in resp: | |
group_name = resp[2] | |
print(f"Creating new group {group_name}") | |
# command: add 5 to GROUPNAME | |
elif ("add" and "to") in resp: | |
num_hosts = resp[1] | |
group_name = resp[3] | |
print(f"Adding {num_hosts} available nodes to {group_name}") | |
# command: groupname execute ping target_name | |
elif ("execute" and "ping") in resp: | |
group_name = resp[0] | |
target_name = resp[3:] | |
print(f"All nodes in {group_name} pinging {target_name}") | |
else: | |
print(f"Unrecognized command: {resp}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment