From ab44f24c227839cd48d1749913cee71090ecb0df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Forslund?= Date: Thu, 31 Aug 2017 00:00:51 +0200 Subject: [PATCH 1/3] Use io.open instead of open to load utf-8 dialog ==== Fixed Issues ==== #1027 ==== Tech Notes ==== io.open is the default implementation of open for python3 and handles encodings in a better way defaulting to utf8 --- mycroft/dialog/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mycroft/dialog/__init__.py b/mycroft/dialog/__init__.py index 174aed6029..2e16aa097b 100644 --- a/mycroft/dialog/__init__.py +++ b/mycroft/dialog/__init__.py @@ -17,6 +17,7 @@ import pystache +from io import open import os import random from mycroft.util import log, resolve_resource_file From de8dff632061268a8619946d656eabe45277d065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Forslund?= Date: Thu, 31 Aug 2017 00:03:49 +0200 Subject: [PATCH 2/3] defaulting to TimeRulesEnUs now works ==== Tech Notes ==== Wheb a language without time rules were defaulted back to us-english time rules the class was instanciated prematurely. Now the default returns a class and not an object. --- mycroft/skills/time_rules.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mycroft/skills/time_rules.py b/mycroft/skills/time_rules.py index 5c03acd71c..5c8b8c6a04 100644 --- a/mycroft/skills/time_rules.py +++ b/mycroft/skills/time_rules.py @@ -167,5 +167,5 @@ KEY_MAP = { def create(lang): clazz = KEY_MAP.get(lang) if not clazz: - clazz = TimeRulesEnUs() + clazz = TimeRulesEnUs return clazz() From 9a6d28243557d2f665d762f26c90b2e569128a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Forslund?= Date: Thu, 31 Aug 2017 00:13:58 +0200 Subject: [PATCH 3/3] Warn when pocket sphinx model file is missing ==== Tech Notes ==== When a pocket sphinx model is missing an error is logged and the default (us english) model is tried. --- .../client/speech/recognizer/pocketsphinx_recognizer.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mycroft/client/speech/recognizer/pocketsphinx_recognizer.py b/mycroft/client/speech/recognizer/pocketsphinx_recognizer.py index a81ecd9349..cb76fbe049 100644 --- a/mycroft/client/speech/recognizer/pocketsphinx_recognizer.py +++ b/mycroft/client/speech/recognizer/pocketsphinx_recognizer.py @@ -20,7 +20,7 @@ import os import tempfile import time -from os.path import join, dirname, abspath +from os.path import join, dirname, abspath, exists from pocketsphinx import Decoder from mycroft.client.speech.recognizer.local_recognizer import LocalRecognizer @@ -52,7 +52,12 @@ class PocketsphinxRecognizer(LocalRecognizer): def create_config(self, dict_name): config = Decoder.default_config() - config.set_string('-hmm', join(BASEDIR, 'model', self.lang, 'hmm')) + model_file = join(BASEDIR, 'model', self.lang, 'hmm') + if not exists(model_file): + LOG.error('PocketSphinx model not found for {}', self.lang) + model_file = join(BASEDIR, 'model', 'en-us', 'hmm') + + config.set_string('-hmm', model_file) config.set_string('-dict', dict_name) config.set_string('-keyphrase', self.key_phrase) config.set_float('-kws_threshold', float(self.threshold))