From c6f9513e9d5925ae8e575c71d4f6096c341bddae Mon Sep 17 00:00:00 2001 From: Matthew Scholefield Date: Tue, 4 Sep 2018 22:59:52 -0500 Subject: [PATCH] Allow local model file in precise --- mycroft/client/speech/hotword_factory.py | 12 +++++++++--- mycroft/configuration/mycroft.conf | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mycroft/client/speech/hotword_factory.py b/mycroft/client/speech/hotword_factory.py index 0ebf62e26d..159e6a6309 100644 --- a/mycroft/client/speech/hotword_factory.py +++ b/mycroft/client/speech/hotword_factory.py @@ -126,9 +126,14 @@ class PreciseHotword(HotWordEngine): self.show_download_progress = Timer(0, lambda: None) precise_config = Configuration.get()['precise'] precise_exe = self.install_exe(precise_config['dist_url']) - self.precise_model = self.install_model( - precise_config['model_url'], key_phrase.replace(' ', '-') - ).replace('.tar.gz', '.pb') + + local_model = self.config.get('local_model_file') + if local_model: + self.precise_model = expanduser(local_model) + else: + self.precise_model = self.install_model( + precise_config['model_url'], key_phrase.replace(' ', '-') + ).replace('.tar.gz', '.pb') self.has_found = False self.stream = ReadWriteStream() @@ -280,6 +285,7 @@ class HotWordFactory(object): if not config: config = Configuration.get()['hotwords'] config = config[hotword] + module = config.get("module", "pocketsphinx") return cls.load_module(module, hotword, config, lang, loop) or \ cls.load_module('pocketsphinx', hotword, config, lang, loop) or \ diff --git a/mycroft/configuration/mycroft.conf b/mycroft/configuration/mycroft.conf index 5837309174..2365143a81 100644 --- a/mycroft/configuration/mycroft.conf +++ b/mycroft/configuration/mycroft.conf @@ -166,6 +166,8 @@ "phonemes": "HH EY . M AY K R AO F T", "threshold": 1e-90, "lang": "en-us" + // Specify custom model via: + // "local_model_file": "~/.mycroft/precise/models/something.pb" }, "wake up": {