def __init__(self, caller): self.caller = caller self.triggers = { _(u'Turn off the lights'): [12, GPIO.OUT, 1], _(u'Turn on the lights'): [12, GPIO.OUT, 0], _(u'Is there any light on?'): [14, GPIO.IN, lambda x: self.caller.tts.say( VERBS[x])] }
def configure_new_remote(self, remote_name): pe = pexpect.check_call("irrecord --ignore-namespace {}".format(LIRC_FILE)) pe.expect("Don't stop pressing buttons") self.caller.tts.say( _( """We're going to configure your remote now. Reserved words for buttons are cancel and done. Please, keep pressing buttons (a second each) for half a minute, until I tell you to stop.""" ) ) pe.sendline() pe.expect("Found") self.caller.tts.say( _( """Please, continue pressing buttons as before, we are almost there""" ) ) pe.sendline() self.caller.tts.say( _( """You can stop pressing buttons now. Now we're going to record the buttons. When you're finished with them, say done. Tell me the trigger phrase of the first button to configure After each button, I'll tell you what I've recognized. I will interpret everything as close as possible to reality. If I have not correctly recognized your button, you can say cancel to retry. """ ) ) while True: action = next(self.caller.stt.text) if action == _("cancel"): continue if action == _("done"): pe.sendline() pe.sendline() break tags = TAGGER.get_main_words(action, lemmatize=True, type_w=["W", "N"]) button = "_".join(tags) pe.sendline(button) pe.expect("Now hold down") self.caller.tts.say(_("""Now press the button""")) return subprocess.Popen()
def __init__(self, caller): self.caller = caller self.remotes = read_lirc_file(LIRC_FILE) self.configure_command = _("Nuevo mando")
def main(): """ Main CLI. This receives as parameters the vinisto modules to load. """ vinisto_ = Vinisto() nltk.downloader.download('all') plugins = extract_modules(vinisto.plugins, 'plugins') tts_plugins = extract_modules(vinisto.tts, 'tts') stt_plugins = extract_modules(vinisto.stt, 'stt') parser = argparse.ArgumentParser( description='Vinisto - Your personal butler') parser.add_argument('--plugins', type=str, nargs='?', choices=plugins, help='List of plugin modules', default=plugins) parser.add_argument('--stt', type=str, choices=stt_plugins, help='List of stt modules', default='vinisto.stt.google_stt') parser.add_argument('--tts', type=str, choices=tts_plugins, help='List of tts modules', default='vinisto.tts.google_tts') parser.add_argument('--keyword', type=str, help='Keyword to wait for') parser.add_argument('--rate', type=int, help="Mic rate, defaults to raspberry pi USB (24000)", default=24000) parser.add_argument('--language', type=str, help="Language to use in both TTS and STT", default=locale.getdefaultlocale()[0].replace('_', '-')) parser.add_argument('--key', type=str, help="Key to be passed to STT engines.", default="AIzaSyCuOvb2qd0mhQRkIbGAcgMUmFQaLIXtlmg") parser.add_argument('--response_phrase', type=str, help="What to say when the keyword has been detected") args = parser.parse_args() TTS = next(extract_classes([args.tts])) STT = next(extract_classes([args.stt])) vinisto_.stt = STT(language=args.language, rate=args.rate, key=args.key) vinisto_.tts = TTS(language=args.language) for class_ in extract_classes(plugins): vinisto_.register_plugin(class_) keyword = _(u'vinisto') phrase = _(u'Yes, master?') if args.keyword: keyword = args.keyword if args.response_phrase: phrase = args.response_phrase phrases = vinisto_.wait_for_keyword(keyword.lower()) for text in phrases: LOG.info("Received: %s", text) if not text: LOG.info("Asking tts to say our phrase") Thread(target=vinisto_.tts.say, args=(phrase,)).start() vinisto_.execute_callbacks(text)
""" Control GPIO relays on raspberry pi """ RUN = True try: import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) except ImportError: RUN = False from vinisto.i18n import _ VERBS = [_(u'Yes'), _(u'No')] class Gpio(object): """ Turn on/off GPIOs """ def __init__(self, caller): self.caller = caller self.triggers = { _(u'Turn off the lights'): [12, GPIO.OUT, 1], _(u'Turn on the lights'): [12, GPIO.OUT, 0], _(u'Is there any light on?'): [14, GPIO.IN, lambda x: self.caller.tts.say(
def __init__(self, caller): self.caller = caller self.triggers = [_("Tell me something")]
def __init__(self, caller): self.caller = caller self.triggers = { _(u"put the lights red"): ["light_control", "red"], _(u"turn the ac off"): ["ac_control", "key_0"], }
def __init__(self, caller): self.caller = caller self.trigger = [_(u'what time is it?'), _(u'It\'s {}')]