def answer(text): """ Save the return function parameter and switch to previous mind. """ text = text.lower() func = oa.mind.user_choices.get(text, None) if func: call_function(func) oa.mind.switch_back()
def _in(): default_mind = 'boot' load_minds() set_mind(default_mind) logging.debug('"{}" is now listening. Say "Boot Mind!" to see if it can hear you.'.format(default_mind)) while not oa.core.finished.is_set(): text = get() logging.debug('Input: {}'.format(text)) mind = oa.core.mind if (text is None) or (text.strip() == ''): # Nothing to do. continue t = text.upper() # Check for a matching command. fn = mind.kws.get(t, None) if fn is not None: # There are two types of commands, stubs and command line text. # For stubs, call `perform()`. if isCallable(fn): call_function(fn) oa.last_command = t # For strings, call `sys_exec()`. elif isinstance(fn, str): sys_exec(fn) oa.last_command = t else: # Any unknown command raises an exception. raise Exception("Unable to process: {}".format(text)) yield text
def say(text): """ Text to speech using the `oa.audio.say` defined function. """ text = call_function(text) oa.sys.last_say = text # Put message into voice. put('voice', text)