def search(self): try: wk.set_lang('es') inf = wk.summary(self.arg, sentences=2) print(inf) say(inf) except Exception as e: error_log2(e) print('No hay coincidencia de busqueda') time.sleep(4)
def rss_world(): try: feed = feedparser.parse(world) lenght = len(feed.entries) for entry in range(lenght): text = feed.entries[entry] print(text.summary) say(text.summary) except KeyboardInterrupt: ex_handler.error_log("Keyboard interruption") exit()
def search(self): try: wk.set_lang('es') inf = wk.summary(self.arg + ' ' + self.arg2 + ' ' + self.arg3 + ' ' + self.arg4 + ' ' + self.arg5, sentences=2) print(inf) inf = str(inf) say('{}'.format(inf)) except Exception as e: error_log2(e) print('No hay coincidencia de busqueda') time.sleep(4)
def ambient_adjustement(): say('Ajustando ruido del ambiente') with sr.Microphone() as source: with ChargingBar('Ajustando ruido del ambiente >>', max=20) as bar: for i in range(20): time.sleep(0.1) bar.next() recognizer.dynamic_energy_threshold = False recognizer.adjust_for_ambient_noise(source, duration=6) pre_build = open(os.getcwd() + r'/libs/pre_build_sentences.txt') sentences = pre_build.readlines() sentence = sentences[random.randint(2, 5)] print('\n{}'.format(sentence)) say(sentence) # Implement pre build sentences
def control_orders(): with sr.Microphone() as source: recorded_audio = recognizer.listen(source, timeout=50) try: #main orders order_ = recognizer.recognize_google(recorded_audio, language="es-AR") order_ = re.sub( r'[^\w\s]', '', str(order_) ) #Mistake was not converting the order from a list to a string order = order_.lower() order = unidecode.unidecode(order) for i in reader('opto1.txt'): if i in order: say('Prendiendo relé uno') driver.controller('ON1') break for i in reader('opto1_off.txt'): if 'apagar' and '1' in order: say('Apagando relé uno') driver.controller('OFF1') break for i in reader('opto2.txt'): if i == order: say('Prendiendo relé dos') driver.controller('ON2') break for i in reader('opto2_off.txt'): if 'apagar' and '2' in order: say('Apagando relé dos') driver.controller('OFF2') break for i in reader('close.txt'): if i in order: os.system('clear') pre_build = open(os.getcwd() + r'/libs/pre_build_sentences.txt') sentence = pre_build.readlines() sentence = sentence[random.randint(19, 25)] say(sentence) sys.exit() except Exception as error: str(error).join(' Control mode error') error_log(error) control_orders()
def _orders_(): try: with sr.Microphone() as source: recorded_audio = recognizer.listen(source) except Exception as ex: print(ex) ex_handler.error_log(ex) pass try: cleaner() order_ = recognizer.recognize_google(recorded_audio, language="es-AR") order_ = re.sub( r'[^\w\s]', '', str(order_) ) #Mistake was not converting the order from a list to a string order = order_.lower() order = unidecode.unidecode(order) print(order) for i in reader('insult.txt'): if i in order: say("callate puto de mierda") break else: pass for i in reader('close.txt'): if i in order: cleaner() pre_build = open(os.getcwd() + r'/libs/pre_build_sentences.txt') sentence = pre_build.readlines() sentence = sentence[random.randint(19, 25)] say(sentence) os.system('shutdown') for i in reader('notes.txt'): #Terminar notes #res = any(x in i for x in order_) if i in order: say('Abriendo anotador') say('Escriba el nombre de la nota') name_ = input('>> ') say('Escriba la nota') note_ = input('>> ') new_note = notes.Notes(note_, name_) new_note.add_note() say('Nota agregada exitosamente') cleaner() for i in reader('notes_delete.txt'): if i in order: say('Escriba el nombre de la nota a borrar') id_ = input('>> ') erase_note = notes.Notes('', id_) erase_note.erase_notes() say('Anotación borrada exitosamente') cleaner() for i in reader('notes_delete_all.txt'): if i in order: say('Escriba si, si estás seguro de elimiar todo') print('Escriba si, si estás seguro de elimiar todo') bool = input('>> ') bool.lower() if bool == 'si': erase_all = notes.Notes('', '') erase_all.erase_all() say('Notas borradas con éxito') elif bool == 'no': say('Saliendo de notas') else: say('argumento incorrecto') cleaner() for i in reader('notes_show_all.txt'): if i in order: say('Mostrando todas las notas') all_notes = notes.Notes('', '') all_notes.show_notes() print('\nPresiona enter para salir. ') input('>> ') cleaner() for i in reader('climate.txt'): if i in order: path = os.getcwd() path = os.path.join(path, "modules", "config.txt") config = open(path, "rt") city = config.readlines() city = str(city[5]) weather = climate.Weather(city) weather = weather.get_weather() print(weather) say(weather) time.sleep(3) cleaner() for i in reader('search.txt'): if i in order: order = order.replace('de', '', 1) order = order.replace('es', '', 1) order = order.split() try: if len(order) == 2: say('buscando') search = Argsearch1(order[1]) search.search() elif len(order) == 3: say('buscando') search = Argsearch2(order[1], order[2]) search.search() elif len(order) == 4: say('buscando') search = Argsearch3(order[1], order[2], order[3]) search.search() elif len(order) == 5: say('buscando') search = Argsearch4(order[1], order[2], order[3], order[4]) search.search() elif len(order) == 6: say('buscando') search = Argsearch5(order[1], order[2], order[3], order[4], order[5]) search.search() elif len(order) == 7: say('buscando') search = Argsearch6(order[1], order[2], order[3], order[4], order[5], order[6]) search.search() elif len(order) == 8: say('buscando') search = Argsearch7(order[1], order[2], order[3], order[4], order[5], order[6], order[7]) search.search() except Exception as e: say('Lo siento, pero no se puede realizar la búsqueda...') ex_handler.error_log(e) break for i in reader('control_mode.txt'): if i in order: say('Iniciando modo controlador') try: path = os.getcwd() path = os.path.join(path, 'control_mode.py') os.system('python3.9 {}'.format(path)) exit() except Exception as e: ex_handler.error_log(e) for i in reader('jokes.txt'): if i in order: num = random.randint(1, 23) string = jokes.jokes(num) print(string) say(string) break time.sleep(2) for i in reader('rss.txt'): if i and 'globales' in order: rss.rss_world() break if i and 'actuales' in order: rss.rss_last() break if i and 'politica' in order: rss.rss_politics() break for i in reader('alarm.txt'): if i in order: os.system('python3.9 modules/alarm.py &') break except Exception as ex: ex_handler.error_log(ex) pass