def get_config(cls): # FIXME: Replace this as soon as we have a config module config = {} # Try to get snowboy config from config profile_path = xiaoheipath.config('profile.yml') if os.path.exists(profile_path): with open(profile_path, 'r') as f: profile = yaml.safe_load(f) if 'snowboy' in profile: if 'model' in profile['snowboy']: config['model'] = \ profile['snowboy']['model'] else: config['model'] = os.path.join( xiaoheipath.LIB_PATH, 'snowboy/dingdang.pmdl') if 'sensitivity' in profile['snowboy']: config['sensitivity'] = \ profile['snowboy']['sensitivity'] else: config['sensitivity'] = "0.5" if 'robot_name' in profile: config['hotword'] = profile['robot_name'] else: config['hotword'] = 'DINGDANG' return config
def get_instance(cls, vocabulary_name, phrases): config = cls.get_config() if cls.VOCABULARY_TYPE: vocabulary = cls.VOCABULARY_TYPE( vocabulary_name, path=xiaoheipath.config('vocabularies')) if not vocabulary.matches_phrases(phrases): vocabulary.compile(phrases) config['vocabulary'] = vocabulary instance = cls(**config) return instance
def get_config(cls): # FIXME: Replace this as soon as we have a config module config = {} # Try to get iflytek_yuyin config from config profile_path = xiaoheipath.config('profile.yml') if os.path.exists(profile_path): with open(profile_path, 'r') as f: profile = yaml.safe_load(f) if 'iflytek_yuyin' in profile: if 'vid' in profile['iflytek_yuyin']: config['vid'] = \ profile['iflytek_yuyin']['vid'] return config
def get_config(cls): # FIXME: Replace this as soon as we have a config module config = {} # HMM dir # Try to get hmm_dir from config profile_path = xiaoheipath.config('profile.yml') if os.path.exists(profile_path): with open(profile_path, 'r') as f: profile = yaml.safe_load(f) if 'google_yuyin' in profile \ and 'api_key' in profile['google_yuyin']: config['api_key'] = profile['google_yuyin']['api_key'] return config
def get_config(cls): # FIXME: Replace this as soon as we have a config module config = {} # HMM dir # Try to get hmm_dir from config profile_path = xiaoheipath.config('profile.yml') if os.path.exists(profile_path): with open(profile_path, 'r') as f: profile = yaml.safe_load(f) try: config['hmm_dir'] = profile['pocketsphinx']['hmm_dir'] except KeyError: pass return config
def get_config(cls): conf = { 'fst_model': os.path.join(xiaoheipath.APP_PATH, os.pardir, 'phonetisaurus', 'g014b2b.fst') } # Try to get fst_model from config profile_path = xiaoheipath.config('profile.yml') if os.path.exists(profile_path): with open(profile_path, 'r') as f: profile = yaml.safe_load(f) if 'pocketsphinx' in profile: if 'fst_model' in profile['pocketsphinx']: conf['fst_model'] = \ profile['pocketsphinx']['fst_model'] if 'nbest' in profile['pocketsphinx']: conf['nbest'] = int(profile['pocketsphinx']['nbest']) return conf
def get_config(cls): # FIXME: Replace this as soon as we have a config module config = {} # Try to get baidu_yuyin config from config profile_path = xiaoheipath.config('profile.yml') if os.path.exists(profile_path): with open(profile_path, 'r') as f: profile = yaml.safe_load(f) if 'baidu_yuyin' in profile: if 'api_key' in profile['baidu_yuyin']: config['api_key'] = \ profile['baidu_yuyin']['api_key'] if 'secret_key' in profile['baidu_yuyin']: config['secret_key'] = \ profile['baidu_yuyin']['secret_key'] if 'per' in profile['baidu_yuyin']: config['per'] = \ profile['baidu_yuyin']['per'] return config