def __init__(self): Thread.__init__(self, name="GPIO Listener") self._logger = logging.getLogger(__name__) self._logger.setLevel(logging.INFO) self.SWITCH_PIN = 14 self.config = cmInstance.getRootConfig()
def __init__(self): self._logger = logging.getLogger(__name__) self.config = cmInstance.getRootConfig() try: stt_engine_slug = self.config['stt_engine'] except KeyError: stt_engine_slug = 'sphinx-stt' logger.warning("stt_engine not specified in profile, defaulting " + "to '%s'", stt_engine_slug) stt_engine_class = stt.get_engine_by_slug(stt_engine_slug) try: tts_engine_slug = self.config['tts_engine'] except KeyError: tts_engine_slug = tts.get_default_engine_slug() logger.warning("tts_engine not specified in profile, defaulting " + "to '%s'", tts_engine_slug) tts_engine_class = tts.get_engine_by_slug(tts_engine_slug) try: mic_slug = self.config['active_mic'] except KeyError: mic_slug = ear.get_default_mic_slug() logger.warning("active_mic not specified in profile, defaulting " + "to '%s'", mic_slug) mic_class = ear.get_mic_by_slug(mic_slug) self.ear = mic_class.get_instance(stt_engine_class.get_active_instance()) mouth.setTTS(tts_engine_class.get_instance())
def get_config(cls): # FIXME: Replace this as soon as we have a config module config = {} profile = cmInstance.getRootConfig() if 'flite-tts' in profile: if 'voice' in profile['flite-tts']: config['voice'] = profile['flite-tts']['voice'] return config
def __init__(self): """ Initiates the Mouth instance. Arguments: tts_engine -- handles platform-independent audio output """ self._logger = logging.getLogger(__name__) self.config = cmInstance.getRootConfig()
def _compile_vocabulary(self, phrases): prefix = 'robot' tmpdir = tempfile.mkdtemp() lexicon_file = configuration.data('julius-stt', 'VoxForge.tgz') lexicon_archive_member = 'VoxForge/VoxForgeDict' profile = cmInstance.getRootConfig() if 'julius' in profile: if 'lexicon' in profile['julius']: lexicon_file = profile['julius']['lexicon'] if 'lexicon_archive_member' in profile['julius']: lexicon_archive_member = \ profile['julius']['lexicon_archive_member'] lexicon = JuliusVocabulary.VoxForgeLexicon(lexicon_file, lexicon_archive_member) # Create grammar file tmp_grammar_file = os.path.join(tmpdir, os.extsep.join([prefix, 'grammar'])) with open(tmp_grammar_file, 'w') as f: grammar = self._get_grammar(phrases) for definition in grammar.pop('S'): f.write("%s: %s\n" % ('S', ' '.join(definition))) for name, definitions in grammar.items(): for definition in definitions: f.write("%s: %s\n" % (name, ' '.join(definition))) # Create voca file tmp_voca_file = os.path.join(tmpdir, os.extsep.join([prefix, 'voca'])) with open(tmp_voca_file, 'w') as f: for category, words in self._get_word_defs(lexicon, phrases).items(): f.write("%% %s\n" % category) for word, phoneme in words: f.write("%s\t\t\t%s\n" % (word, phoneme)) # mkdfa.pl olddir = os.getcwd() os.chdir(tmpdir) cmd = ['mkdfa.pl', str(prefix)] with tempfile.SpooledTemporaryFile() as out_f: subprocess.call(cmd, stdout=out_f, stderr=out_f) out_f.seek(0) for line in out_f.read().splitlines(): line = line.strip() if line: self._logger.debug(line) os.chdir(olddir) tmp_dfa_file = os.path.join(tmpdir, os.extsep.join([prefix, 'dfa'])) tmp_dict_file = os.path.join(tmpdir, os.extsep.join([prefix, 'dict'])) shutil.move(tmp_dfa_file, self.dfa_file) shutil.move(tmp_dict_file, self.dict_file) shutil.rmtree(tmpdir)
def __init__(self): """ Instantiates a new Brain object, which cross-references user input with a list of modules. Note that the order of brain.modules matters, as the Brain will cease execution on the first module that accepts a given input. """ self.profile = cmInstance.getRootConfig() self.modules = self.get_modules() self._logger = logging.getLogger(__name__) self.handling = False
def executeTask(taskname=None): try: profile = cmInstance.getRootConfig() service_url = "".join( profile.homeassistant.hass_tasks[taskname].service) data = profile.homeassistant.hass_tasks[taskname].data response = restpost(service_url, data) if response == "[]": return False except Exception as e: print e.message raise return True
def get_config(cls): # FIXME: Replace this as soon as we have a config module config = {} profile = cmInstance.getRootConfig() if 'espeak-tts' in profile: if 'voice' in profile['espeak-tts']: config['voice'] = profile['espeak-tts']['voice'] if 'pitch_adjustment' in profile['espeak-tts']: config['pitch_adjustment'] = \ profile['espeak-tts']['pitch_adjustment'] if 'words_per_minute' in profile['espeak-tts']: config['words_per_minute'] = \ profile['espeak-tts']['words_per_minute'] return config
def executeTask(taskname=None, paras=None): try: profile = cmInstance.getRootConfig() print profile.meetingscreen.tasks[taskname] service_url = "".join(profile.meetingscreen.tasks[taskname].service) data = profile.meetingscreen.tasks[taskname].data if paras: data["parameters"] = paras response = restpost(service_url, data) if response == "[]": return False except Exception as e: print e.message raise return True
def __init__(self, brain): self._logger = logging.getLogger(__name__) self.q = Queue.Queue() self.profile = cmInstance.getRootConfig() self.notifiers = [] self.brain = brain if 'email' in self.profile and \ ('enable' not in self.profile['email'] or self.profile['email']['enable']): self.notifiers.append(self.NotificationClient( self.handleEmailNotifications, None)) else: self._logger.warning('email account not set ' + 'in profile, email notifier will not be used') sched = BackgroundScheduler(daemon=True) sched.start() sched.add_job(self.gather, 'interval', seconds=30) atexit.register(lambda: sched.shutdown(wait=False))
def __init__(self): self._logger = logging.getLogger(__name__) self.config = cmInstance.getRootConfig() try: stt_engine_slug = self.config['stt_engine'] except KeyError: pass stt_engine_class = stt.get_engine_by_slug(stt_engine_slug) self.stt = stt_engine_class.get_active_instance() try: tts_engine_slug = self.config['tts_engine'] except KeyError: pass tts_engine_class = tts.get_engine_by_slug(tts_engine_slug) self.tts = tts_engine_class.get_instance() self.brain = Brain() mouth.setTTS(self.tts)
def __init__(self): self._logger = logging.getLogger(__name__) self.config = cmInstance.getRootConfig()
def __init__(self, persona, ear): self._logger = logging.getLogger(__name__) self.persona = persona self.mic = ear self.profile = cmInstance.getRootConfig() self.brain = Brain()
def __init__(self, stt_engine): self.config = cmInstance.getRootConfig() return