def run_tests(decoder, voice, classes): t_range = ["1", "2", "3", "4", "5", "6"] t_menu = ("TEST 1: \"set a timer for 3 seconds\"\n" "TEST 2: \"play the song country roads\"\n" "TEST 3: \"stop playing music\"\n" "TEST 4: \"what's the weather in denver\"\n" "TEST 5: \"start a stopwatch\"\n" "TEST 6: \"stop the stopwatch\"\n" "enter \"7\" to exit this menu\n" "Enter a test number for the test you would like to run: ") num = None os.system("clear") while True: num = input(t_menu).strip() if num in t_range: f_name = os.getcwd() + "/tests/voice_files/file_" + num + ".wav" if num == "3": mixer.init() mixer.music.pause() os.system("aplay " + f_name) if num == "3": mixer.music.unpause() os.system("clear") sentence = decoder.decode_file(f_name) if sentence == "": print("nothing detected within vosk") continue msg, func, bMod = sklearn_sims.compare_command(sentence, classes) check_test(num, msg) elif num != "7": print(str(num) + " isn't a valid option!") else: break
def main(): classes = ml.class_builder() info = {"path": str(pathlib.Path(__file__).parent.absolute())} voice = None commands = ["using youtube play the song slow dancing in the darkness"] for i in commands: print(i) msg, func, mod = sk.compare_command(i, classes, info) run_results(msg, func, mod, classes, voice)
def main(): info = fi.get_fe_info() info["path"] = pathlib.Path().absolute() voice = vs.VoiceSynth(info) decoder = vosk_rec.Decoder(info) classes = ml.class_builder() filename = "{}/temp/downSamp.wav".format(info["path"]) os.system("clear") #clearing out text from vosk intialization menu = ("enter \"reuse\" to use previous recording\n" "enter \"r\" to record for 10 seconds\n" "enter \"wifi\" to test the wifi functionality\n" "enter \"test\" to enter the testing menu\n" "enter \"exit\" to exit the program: ") while True: print() #record = input(menu) record = "wifi" print() record = record.strip().lower() msg = "" func = None if (record == "exit"): exit() elif (record == "r" or record == "wifi" or record == "reuse"): if record == "r": #do a local recording local() sentence = decoder.decode_file(filename) elif record == "wifi": #test using wifi capability while True: sentence = decoder.listen_stream() if sentence == "": send_error(info) continue elif sentence == "stop": send_stop(info) continue msg, func, mod = sklearn_sims.compare_command( sentence, classes, info) if "no match for" in msg: send_error(info) continue run_results(msg, func, mod, classes, voice) elif record == "reuse": #reuse previous recording sentence = decoder.decode_file(filename) else: print("that shouldn't have happened: " + record) exit() print("vosk sentence: " + sentence) run_results(msg, func, mod, classes, voice) elif (record == "test"): run_tests(decoder, voice, classes) else: print(record, "is not an option \n")
def main(): voice = vs.VoiceSynth() decoder = om.Decoder() classes = ml.class_builder() info = {"path": str(pathlib.Path(__file__).parent.absolute())} os.system("clear") #clearing out text from vosk intialization while True: sent = decoder.run() msg, func, mod = sk.compare_command(sent, classes, info) run_results(msg, func, mod, classes, voice)
def run_stuff(sentences, classes, delay): info = fi.get_fe_info() info["path"] = pathlib.Path(__file__).parent.absolute() for i in sentences: msg, func, mod = sk.compare_command(i, classes, info) print(msg) if func: #we got a function back if mod in classes.keys( ): #classes functions should manipulate themselves func(classes[mod]) else: func() time.sleep(delay)
def main(): classes = ml.class_builder() info = {"path": str(pathlib.Path(__file__).parent.absolute())} voice = None commands = [ "turn off the smart plug", "turn on the smart plug", "get the status of the smart plug", ] for i in commands: print(i) msg, func, mod = sk.compare_command(i, classes, info) run_results(msg, func, mod, classes, voice)
def main(): classes = ml.class_builder() info = {"path": str(pathlib.Path(__file__).parent.absolute())} voice = None commands = [ "turn the flux lightbulb color to red", "turn the flux lightbulb color to blue", "turn the flux lightbulb off", "turn the flux lightbulb on", "set the flux lightbulb brightness to fifty percent", ] for i in commands: print(i) msg, func, mod = sk.compare_command(i, classes, info) run_results(msg, func, mod, classes, voice)