From 4ca656caac0de236cd31c81981da4bd8ca708f7d Mon Sep 17 00:00:00 2001 From: mathmauney Date: Fri, 23 Aug 2019 15:32:59 -0400 Subject: [PATCH 1/8] Issue-2232 Add warning when AVX is not detected and fallback. --- dev_setup.sh | 16 ++++++++++++++++ mycroft/client/speech/hotword_factory.py | 9 +++++++++ mycroft/configuration/mycroft.conf | 1 + 3 files changed, 26 insertions(+) diff --git a/dev_setup.sh b/dev_setup.sh index 4290850bda..68b10cba3e 100755 --- a/dev_setup.sh +++ b/dev_setup.sh @@ -174,6 +174,22 @@ This script is designed to make working with Mycroft easy. During this first run of dev_setup we will ask you a few questions to help setup your environment.' sleep 0.5 + if ! grep -q avx /proc/cpuinfo; then + echo " +The Precise Wake Word Engine requires the AVX instruction set, which is +not supported on your CPU. Do you want to fall back to the PocketSphinx +engine? Advanced users can build the precise engine with an older +version of TensorFlow (v1.13) if desired and change use_precise to true +in mycroft.conf. + Y)es, I want to use the PocketSphinx engine or my own. + N)o, stop the installation." + if get_YN ; then + sed -i "s/\"use_precise\": true/\"use_precise\": false/" config/ + else + echo -e "$HIGHLIGHT N - quit the installation $RESET" + exit 1 + fi + fi echo " Do you want to run on 'master' or against a dev branch? Unless you are a developer modifying mycroft-core itself, you should run on the diff --git a/mycroft/client/speech/hotword_factory.py b/mycroft/client/speech/hotword_factory.py index e5385bf5ed..1f69035f87 100644 --- a/mycroft/client/speech/hotword_factory.py +++ b/mycroft/client/speech/hotword_factory.py @@ -47,6 +47,10 @@ class NoModelAvailable(Exception): pass +class PreciseUnavailable(Exception): + pass + + def msec_to_sec(msecs): """Convert milliseconds to seconds. @@ -190,6 +194,8 @@ class PreciseHotword(HotWordEngine): PreciseRunner, PreciseEngine, ReadWriteStream ) local_conf = LocalConf(USER_CONFIG) + if not local_conf.get('precise', {}).get('use_precise', True): + raise PreciseUnavailable if (local_conf.get('precise', {}).get('dist_url') == 'http://bootstrap.mycroft.ai/artifacts/static/daily/'): del local_conf['precise']['dist_url'] @@ -487,6 +493,9 @@ class HotWordFactory: hotword, module )) instance = None + except PreciseUnavailable: + LOG.warning('Settings prevent Precise Engine use, falling back to default.') + instance = None except Exception: LOG.exception( 'Could not create hotword. Falling back to default.') diff --git a/mycroft/configuration/mycroft.conf b/mycroft/configuration/mycroft.conf index b07fe137e3..6d8e0113bb 100644 --- a/mycroft/configuration/mycroft.conf +++ b/mycroft/configuration/mycroft.conf @@ -199,6 +199,7 @@ // Settings used for any precise wake words "precise": { + "use_precise": true, "dist_url": "https://github.com/MycroftAI/precise-data/raw/dist/{arch}/latest", "model_url": "https://raw.githubusercontent.com/MycroftAI/precise-data/models/{wake_word}.tar.gz" }, From 011c3899a94da6781b1e166f38f10324313f4119 Mon Sep 17 00:00:00 2001 From: mathmauney Date: Fri, 23 Aug 2019 15:50:02 -0400 Subject: [PATCH 2/8] Fix line too long --- mycroft/client/speech/hotword_factory.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mycroft/client/speech/hotword_factory.py b/mycroft/client/speech/hotword_factory.py index 1f69035f87..878c0fc5d1 100644 --- a/mycroft/client/speech/hotword_factory.py +++ b/mycroft/client/speech/hotword_factory.py @@ -494,7 +494,8 @@ class HotWordFactory: )) instance = None except PreciseUnavailable: - LOG.warning('Settings prevent Precise Engine use, falling back to default.') + LOG.warning('Settings prevent Precise Engine use, + falling back to default.') instance = None except Exception: LOG.exception( From e9265041579fae95dca348f9ffbc7d3002803f76 Mon Sep 17 00:00:00 2001 From: mathmauney Date: Sat, 24 Aug 2019 10:20:29 -0400 Subject: [PATCH 3/8] Ignore missing AVX for ARM systems --- dev_setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev_setup.sh b/dev_setup.sh index 68b10cba3e..dda4985959 100755 --- a/dev_setup.sh +++ b/dev_setup.sh @@ -174,7 +174,7 @@ This script is designed to make working with Mycroft easy. During this first run of dev_setup we will ask you a few questions to help setup your environment.' sleep 0.5 - if ! grep -q avx /proc/cpuinfo; then + if ! grep -q avx /proc/cpuinfo && [[ ! $(uname -m) == 'arm'* ]]; then echo " The Precise Wake Word Engine requires the AVX instruction set, which is not supported on your CPU. Do you want to fall back to the PocketSphinx From 305b93625a8e5dc6e6c8b9b425c7a6d3c650a73e Mon Sep 17 00:00:00 2001 From: mathmauney Date: Sat, 24 Aug 2019 17:34:30 -0400 Subject: [PATCH 4/8] Update hotword_factory.py Fix long line string --- mycroft/client/speech/hotword_factory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mycroft/client/speech/hotword_factory.py b/mycroft/client/speech/hotword_factory.py index 878c0fc5d1..af39f2eb57 100644 --- a/mycroft/client/speech/hotword_factory.py +++ b/mycroft/client/speech/hotword_factory.py @@ -494,8 +494,8 @@ class HotWordFactory: )) instance = None except PreciseUnavailable: - LOG.warning('Settings prevent Precise Engine use, - falling back to default.') + LOG.warning('Settings prevent Precise Engine use, ' + 'falling back to default.') instance = None except Exception: LOG.exception( From 9c09f1739b2c581fc385b5a2145369f6194d9334 Mon Sep 17 00:00:00 2001 From: mathmauney Date: Thu, 29 Aug 2019 11:28:36 -0400 Subject: [PATCH 5/8] Edit system .conf and make if needed --- dev_setup.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dev_setup.sh b/dev_setup.sh index dda4985959..a9c7b32112 100755 --- a/dev_setup.sh +++ b/dev_setup.sh @@ -184,7 +184,13 @@ in mycroft.conf. Y)es, I want to use the PocketSphinx engine or my own. N)o, stop the installation." if get_YN ; then - sed -i "s/\"use_precise\": true/\"use_precise\": false/" config/ + if [[ ! -f /etc/mycroft/mycroft.conf ]]; then + if [[ ! -e /etc/mycroft/ ]]; then + $SUDO mkdir /etc/mycroft + fi + $SUDO cp $TOP/mycroft/configuration/mycroft.conf /etc/mycroft/ + fi + sed -i "s/\"use_precise\": true/\"use_precise\": false/" /etc/mycroft/mycroft.conf else echo -e "$HIGHLIGHT N - quit the installation $RESET" exit 1 From e846d97a244bcf3ff3863e382b97409c64184559 Mon Sep 17 00:00:00 2001 From: mathmauney Date: Thu, 29 Aug 2019 11:40:33 -0400 Subject: [PATCH 6/8] Sed needs sudo --- dev_setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev_setup.sh b/dev_setup.sh index a9c7b32112..92ee65ae6f 100755 --- a/dev_setup.sh +++ b/dev_setup.sh @@ -190,7 +190,7 @@ in mycroft.conf. fi $SUDO cp $TOP/mycroft/configuration/mycroft.conf /etc/mycroft/ fi - sed -i "s/\"use_precise\": true/\"use_precise\": false/" /etc/mycroft/mycroft.conf + $SUDO sed -i "s/\"use_precise\": true/\"use_precise\": false/" /etc/mycroft/mycroft.conf else echo -e "$HIGHLIGHT N - quit the installation $RESET" exit 1 From 771b8aa36b89882e485d1fefe521a9c0e2c24b02 Mon Sep 17 00:00:00 2001 From: Kris Gesling Date: Wed, 26 May 2021 19:10:42 +0930 Subject: [PATCH 7/8] Improve writing of config under different conditions --- dev_setup.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dev_setup.sh b/dev_setup.sh index 92ee65ae6f..b9ba0ed4d6 100755 --- a/dev_setup.sh +++ b/dev_setup.sh @@ -185,16 +185,18 @@ in mycroft.conf. N)o, stop the installation." if get_YN ; then if [[ ! -f /etc/mycroft/mycroft.conf ]]; then - if [[ ! -e /etc/mycroft/ ]]; then - $SUDO mkdir /etc/mycroft - fi - $SUDO cp $TOP/mycroft/configuration/mycroft.conf /etc/mycroft/ + $SUDO mkdir -p /etc/mycroft + $SUDO touch /etc/mycroft/mycroft.conf + $SUDO bash -c 'echo "{ \"use_precise\": true }" > /etc/mycroft/mycroft.conf' + else + $SUDO bash -c 'jq ". + { \"use_precise\": true }" /etc/mycroft/mycroft.conf > tmp.mycroft.conf' + $SUDO mv -f tmp.mycroft.conf /etc/mycroft/mycroft.conf fi - $SUDO sed -i "s/\"use_precise\": true/\"use_precise\": false/" /etc/mycroft/mycroft.conf else echo -e "$HIGHLIGHT N - quit the installation $RESET" exit 1 fi + echo fi echo " Do you want to run on 'master' or against a dev branch? Unless you are From ff2db272b88d31ad3c53f1aea12f286676ec5b11 Mon Sep 17 00:00:00 2001 From: Kris Gesling Date: Mon, 31 May 2021 08:19:18 +0930 Subject: [PATCH 8/8] Add comment explaining no check for AVX on ARM --- dev_setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev_setup.sh b/dev_setup.sh index b9ba0ed4d6..3bbfabc247 100755 --- a/dev_setup.sh +++ b/dev_setup.sh @@ -174,6 +174,8 @@ This script is designed to make working with Mycroft easy. During this first run of dev_setup we will ask you a few questions to help setup your environment.' sleep 0.5 + # The AVX instruction set is an x86 construct + # ARM has a range of equivalents, unsure which are (un)supported by TF. if ! grep -q avx /proc/cpuinfo && [[ ! $(uname -m) == 'arm'* ]]; then echo " The Precise Wake Word Engine requires the AVX instruction set, which is