diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..6f0e2e8e --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.tgz +/SHA256SUMS +/lib/ +/package/ +/snips.tar diff --git a/SHA256SUMS b/SHA256SUMS deleted file mode 100644 index ce2070a4..00000000 --- a/SHA256SUMS +++ /dev/null @@ -1,17 +0,0 @@ -ab29d42bc6edbf84ac11e900843085d1fb98e0eba1f286cbbcbcd2f3e9baa66a bootstrap.py -551fa7c962d3a375441c849a47709227c689f2220eb2fc13abe91e96092e4312 main.py -f92bfacbafe517c929f4e0f691a70c29a21dd0dbeb49e7ad345439bb55e9d6cf snips.tar -96a1583b9ab56d4a4b3c3893c8b0a3c7f1b341f8a59b142dcbb7abde7c3d1258 pkg/__init__.py -0ac41dfa182f9fb4439092bc5ec5d64b3ed1c41378090a2b5bdac13956464e47 pkg/intentions.py -c691489a3a6fa417f6242a0e29640f2156c74937602e3def9374ac90f45e67cd pkg/util.py -3957ba3e7ee0f996a41da85ac4933b30b6e7e4c6299f981c2f8aef07669dc346 pkg/voco_adapter.py -ca140a593b2bbef27dc89d1b95dc6c0860344626a5ee3bab3e76e1f044dd85fa pkg/voco_device.py -3574a7f1c0d074cc37fea9a48a8a75dcc53ff493e0509a1aa0f31b8b2a8c89d8 pkg/voco_notifier.py -4848c45f0cfb9afd928e03d4e21314a1348aa5e58b2d4f612399265235596013 sounds/alarm.wav -1fa5643e91cc360949926777ba11ba9b91257899e43248b508ed070040d9c7e6 sounds/end_of_input.wav -81bcde2e3d3ff43895bb40ac2a971d0024b70dc5bf2211f6c1bd60125655c1fe sounds/end_spot.wav -3026ac341b1d5a184bbc9a1c7ca986ad2762d855fad4cdc321fc2bf74c312d86 sounds/error.wav -139119a7ce354e3866cb7e7ae18a2e952740292ad9206e9f0adbaf52631dbe76 sounds/start_of_input.wav -1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5 LICENSE -7a4a8849443443685c3f8c8aba60c80e6da793623b8b0580286946f695ae9833 requirements.txt -a20925c72a1ebd31cb4ee977fc2f36b8685d89de4fc3355bfc3666fb0abed77b setup.cfg diff --git a/asound.conf b/asound.conf deleted file mode 100644 index d7b73320..00000000 --- a/asound.conf +++ /dev/null @@ -1,11 +0,0 @@ -pcm.!default { - type asym - playback.pcm { - type plug - slave.pcm 'hw:0,0' - } - capture.pcm { - type plug - slave.pcm 'hw:1,0' - } - } diff --git a/assistant.json b/assistant.json deleted file mode 100644 index cb401cb2..00000000 --- a/assistant.json +++ /dev/null @@ -1,311 +0,0 @@ -{ - "id" : "proj_rY5Wq4dr6qK", - "name" : "Candle", - "intents" : [ { - "id" : "createcandle:stop_timer", - "type" : "registry", - "version" : "5.0.0", - "language" : "en", - "slots" : [ { - "name" : "timer_last", - "id" : "4LrrXCANN", - "entityId" : "entity_9VD5m64v9wo", - "missingQuestion" : "", - "required" : false, - "description" : "How many timers to remove" - }, { - "name" : "timer_type", - "id" : "zgPXDlm5C", - "entityId" : "entity_K37nnN5lEnD", - "missingQuestion" : "", - "required" : false - }, { - "name" : "number", - "id" : "pkLgrGvR_", - "entityId" : "snips/number", - "missingQuestion" : "", - "required" : false - } ], - "name" : "stop_timer", - "enabledByDefault" : true - }, { - "id" : "createcandle:get_timer_count", - "type" : "registry", - "version" : "2.0.0", - "language" : "en", - "slots" : [ { - "name" : "timer_type", - "id" : "FUoen_34w", - "entityId" : "entity_K37nnN5lEnD", - "missingQuestion" : "", - "required" : false - } ], - "name" : "get_timer_count", - "enabledByDefault" : true - }, { - "id" : "createcandle:get_boolean", - "type" : "registry", - "version" : "3.0.0", - "language" : "en", - "slots" : [ { - "name" : "property", - "id" : "luRtA7rKN", - "entityId" : "entity_y538wwAo2Db", - "missingQuestion" : "", - "required" : false - }, { - "name" : "thing", - "id" : "CSdKtwlLV", - "entityId" : "entity_b7POWzl4n0y", - "missingQuestion" : "", - "required" : false - }, { - "name" : "boolean", - "id" : "kRvZ8Etwi", - "entityId" : "entity_e9KxqKv030g", - "missingQuestion" : "", - "required" : false - } ], - "name" : "get_boolean", - "enabledByDefault" : true - }, { - "id" : "createcandle:set_state", - "type" : "registry", - "version" : "8.0.0", - "language" : "en", - "slots" : [ { - "name" : "property", - "id" : "fRJttOAaE", - "entityId" : "entity_y538wwAo2Db", - "missingQuestion" : "", - "required" : false - }, { - "name" : "thing", - "id" : "thDpdoaSA", - "entityId" : "entity_b7POWzl4n0y", - "missingQuestion" : "", - "required" : false - }, { - "name" : "boolean", - "id" : "Q1n0r-NT5", - "entityId" : "entity_e9KxqKv030g", - "missingQuestion" : "Do you want it to be on or off?", - "required" : true, - "description" : "Something that can be only one of two twings." - }, { - "name" : "duration", - "id" : "lHx2bJfPj", - "entityId" : "snips/duration", - "missingQuestion" : "", - "required" : false, - "description" : "A length of time" - }, { - "name" : "time", - "id" : "p10gSn4-t", - "entityId" : "snips/datetime", - "missingQuestion" : "", - "required" : false - }, { - "name" : "number", - "id" : "qrBKDUxUl", - "entityId" : "snips/number", - "missingQuestion" : "", - "required" : false - }, { - "name" : "period", - "id" : "avgg9dKcd", - "entityId" : "entity_WwwYZqOnGQp", - "missingQuestion" : "", - "required" : false - }, { - "name" : "space", - "id" : "4UnnesMP_", - "entityId" : "entity_7qYEVPPrB85", - "missingQuestion" : "", - "required" : false - }, { - "name" : "special_time", - "id" : "1QFAs3-Ah", - "entityId" : "entity_1aabnglkxzW", - "missingQuestion" : "", - "required" : false - }, { - "name" : "pleasantries", - "id" : "lZtnZe8yL", - "entityId" : "entity_Vxkz5yZ5ObN", - "missingQuestion" : "", - "required" : false - } ], - "name" : "set_state", - "enabledByDefault" : true - }, { - "id" : "createcandle:set_value", - "type" : "registry", - "version" : "7.0.0", - "language" : "en", - "slots" : [ { - "name" : "property", - "id" : "LSK_2R_vL", - "entityId" : "entity_y538wwAo2Db", - "missingQuestion" : "", - "required" : false - }, { - "name" : "thing", - "id" : "CWG6ioAZp", - "entityId" : "entity_b7POWzl4n0y", - "missingQuestion" : "", - "required" : false - }, { - "name" : "percentage", - "id" : "2O6AfPgRb", - "entityId" : "snips/percentage", - "missingQuestion" : "", - "required" : false - }, { - "name" : "number", - "id" : "dYEGDUn38", - "entityId" : "snips/number", - "missingQuestion" : "", - "required" : false - }, { - "name" : "color", - "id" : "9FIfyZW8O", - "entityId" : "entity_1aMwo1B8z4P", - "missingQuestion" : "", - "required" : false - }, { - "name" : "duration", - "id" : "fZVtmVXPy", - "entityId" : "snips/duration", - "missingQuestion" : "", - "required" : false - }, { - "name" : "time", - "id" : "Xql194VF7", - "entityId" : "snips/datetime", - "missingQuestion" : "", - "required" : false - }, { - "name" : "pleasantries", - "id" : "ieDpdgpQd", - "entityId" : "entity_Vxkz5yZ5ObN", - "missingQuestion" : "", - "required" : false - }, { - "name" : "period", - "id" : "Z-5uEF6CL", - "entityId" : "entity_WwwYZqOnGQp", - "missingQuestion" : "", - "required" : false - }, { - "name" : "string", - "id" : "7_1yABi0F", - "entityId" : "entity_4nrZBAypl0V", - "missingQuestion" : "", - "required" : false - } ], - "name" : "set_value", - "enabledByDefault" : true - }, { - "id" : "createcandle:set_timer", - "type" : "registry", - "version" : "8.0.0", - "language" : "en", - "slots" : [ { - "name" : "duration", - "id" : "zSvK1V8G6", - "entityId" : "snips/duration", - "missingQuestion" : "", - "required" : false - }, { - "name" : "timer_type", - "id" : "lDbC5Bmql", - "entityId" : "entity_K37nnN5lEnD", - "missingQuestion" : "", - "required" : false - }, { - "name" : "time", - "id" : "qx4cE-b6h", - "entityId" : "snips/datetime", - "missingQuestion" : "When should I reminded you?", - "required" : false, - "description" : "The time the reminder should be spoken by Snips" - } ], - "name" : "set_timer", - "enabledByDefault" : true - }, { - "id" : "createcandle:get_value", - "type" : "registry", - "version" : "1.0.0", - "language" : "en", - "slots" : [ { - "name" : "thing", - "id" : "slot_imported_lr5zYJ8dq", - "entityId" : "entity_b7POWzl4n0y", - "missingQuestion" : "", - "required" : false - }, { - "name" : "property", - "id" : "slot_imported_8VkR0CeSQ9", - "entityId" : "entity_y538wwAo2Db", - "missingQuestion" : "", - "required" : false - }, { - "name" : "ordinal", - "id" : "slot_imported_wW-EiI7dSS", - "entityId" : "snips/ordinal", - "missingQuestion" : "", - "required" : false - } ], - "name" : "get_value", - "enabledByDefault" : true - }, { - "id" : "createcandle:list_timers", - "type" : "registry", - "version" : "3.0.0", - "language" : "en", - "slots" : [ { - "name" : "timer_type", - "id" : "M7RoiIz6v", - "entityId" : "entity_K37nnN5lEnD", - "missingQuestion" : "", - "required" : false - }, { - "name" : "timer_last", - "id" : "lquDZ6jlX", - "entityId" : "entity_9VD5m64v9wo", - "missingQuestion" : "", - "required" : false - }, { - "name" : "pleasantries", - "id" : "u8k5ei945", - "entityId" : "entity_Vxkz5yZ5ObN", - "missingQuestion" : "", - "required" : false - } ], - "name" : "list_timers", - "enabledByDefault" : true - }, { - "id" : "createcandle:get_time", - "type" : "registry", - "version" : "4.0.0", - "language" : "en", - "slots" : [ ], - "name" : "get_time", - "enabledByDefault" : true - } ], - "createdAt" : "2019-07-22T18:41:41.981Z", - "language" : "en", - "version" : { - "nluModel" : "0.19.7" - }, - "platform" : { - "type" : "raspberrypi" - }, - "asr" : { - "type" : "snips" - }, - "analyticsEnabled" : false, - "heartbeatEnabled" : false, - "hotword" : "hey_snips" -} \ No newline at end of file diff --git a/bootstrap.py b/bootstrap.py deleted file mode 100644 index 57a7f422..00000000 --- a/bootstrap.py +++ /dev/null @@ -1,73 +0,0 @@ -""" -This script exists to ensure that required dependencies are present. - -To prevent the need for building dependencies for every possible OS/arch/Python -combination, this script will build the required dependencies. After doing so, -or if the dependencies are already present, main.py will be started. -""" - -import os -import subprocess -import sys - -_BASE_DIR = os.path.dirname(os.path.abspath(__file__)) - -print("") -print("") -print("HELLO THERE") -def install_packages(): - """Install all packages listed in requirements.txt.""" - system_option = '' - try: - import lsb_release - print("lsb_release.get_distro_information()['ID'] = " + str(lsb_release.get_distro_information()['ID'])) - if lsb_release.get_distro_information()['ID'] in ['Raspbian', - 'Debian']: - system_option = '--system' - except ImportError: - print("unable to determine your linux distribution. Will try to continue.") - pass - - #cmd = ( - # '{} -m pip install {} --install-option="--prefix=" -t lib ' - # '-r requirements.txt'.format(sys.executable, system_option)) - - - cmd = 'pip3 install -r requirements.txt -t lib --no-binary fuzzywuzzy,paho-mqtt --prefix ""' - #cmd = ( - # '{} -m pip install --install-option="--prefix=" -t lib ' - # '-r requirements.txt'.format(sys.executable)) - - - print("Command that will install the dependencies: " + str(cmd)) - try: - subprocess.check_call(cmd, - stderr=subprocess.STDOUT, - shell=True, - cwd=_BASE_DIR) - return True - except subprocess.CalledProcessError as e: - print("Unable to install dependencies: " + str(e)) - return False - - -try: - print("_BASE_DIR = " + str(_BASE_DIR)) - sys.path.append(os.path.join(_BASE_DIR, 'lib')) - - #from hermes_python.hermes import Hermes # noqa: F401 - #from hermes_python.ontology import * # noqa: F401 - import fuzzywuzzy # noqa: F401 - import alsaaudio # noqa: F401 - import dateutil # noqa: F401 - import pytz # noqa: F401 - import paho # noqa: F401 - #import pyttsx3 # noqa: F401 -except ImportError as ex: - print("Import error: " + str(ex)) - # If installation failed, exit with 100 to tell the gateway not to restart - # this process. - if not install_packages(): - sys.exit(100) - -os.execl(sys.executable, sys.executable, os.path.join(_BASE_DIR, 'main.py')) \ No newline at end of file diff --git a/install_snips.sh b/install_snips.sh deleted file mode 100644 index 7fe6784f..00000000 --- a/install_snips.sh +++ /dev/null @@ -1,196 +0,0 @@ -#!/bin/bash - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -echo $DIR -BUSYPATH="$DIR/busy_installing" -DONEPATH="$DIR/snips_installed" -RESPEAKERDONEPATH="$DIR/respeaker_installed" -ASSISTANTPATH="$DIR/snips/assistant.zip" -ASSISTANTDONEPATH="$DIR/respeaker_installed" - -#echo $DONEPATH - -#set -e - - -# snips/libwebsockets8_2.0.3-2+b1~rpt1_armhf.deb -# snips/mosquitto_1.4.10-3+deb9u4_armhf.deb - -required_packages=( - libportaudio2_19.6.0-1_armhf.deb - libblas-common_3.7.0-2_armhf.deb - libatlas3-base_3.10.3-1-snips_armhf.deb - libgfortran3_6.3.0-18+rpi1+deb9u1_armhf.deb - libttspico-data_1.0+git20130326-5_all.deb - libttspico0_1.0+git20130326-5_armhf.deb - libttspico-utils_1.0+git20130326-5_armhf.deb - snips-platform-common_0.63.2_armhf.deb - snips-kaldi-atlas_0.24.2_armhf.deb - snips-asr_0.63.2_armhf.deb - snips-audio-server_0.63.2_armhf.deb - snips-dialogue_0.63.2_armhf.deb - snips-hotword_0.63.2_armhf.deb - snips-injection_0.63.2_armhf.deb - snips-nlu_0.63.2_armhf.deb - snips-platform-voice_0.63.2_armhf.deb - snips-tts_0.63.2_armhf.deb -) - -check_pkg() { - pkg_="$(cut -d'_' -f1 <<<"$1")" - dpkg-query -s "$pkg_" >/dev/null 2>&1 -} - - - -install_snips() { - echo "path to check: $DONEPATH" - if [ -f $DONEPATH ]; then - echo "Already installed. Remove the 'snips_installed' file to unblock this. (shell)" - exit 0 - fi - echo "The snips_installed file was not present, installing now (shell)" - - echo "Updating APT (shell)" - sudo apt update -y - sudo apt-get update - - echo "Installing mosquitto" - sudo apt-get install mosquitto -y - - # Unzip and prepare the assistant first - - if [ ! -d "/usr/share/snips" ]; then - echo "/usr/share/snips directory did not exist yet. Creating it now." - sudo mkdir /usr/share/snips - else - echo "/usr/share/snips directory already existed" - fi - - if [ ! -d "/usr/share/snips/assistant" ]; then - if [ -f $ASSISTANTPATH ]; then - echo "Copying the assistant into /usr/share/snips/assistant (shell)" - sudo unzip -o "$ASSISTANTPATH" -d /usr/share/snips - else - echo "ERROR: could not find assistant.zip file" - fi - else - echo "/usr/share/snips/assistant directory already existed" - fi - - - #echo "Installing gdebi" - #sudo apt-get install gdebi -y - #echo "Installing mosquitto" - #sudo apt-get install mosquitto -y - echo "Installing pulseaudio" - sudo apt-get install pulseaudio -y - echo "Installing Snips packages" - for pkg in ${required_packages[@]}; do - echo "installing $pkg from $DIR/snips/$pkg" - #sudo gdebi "$pkg" -n - sudo dpkg -i --force-depends "$DIR/snips/$pkg" - done - echo "Doing api-get -f install" - #sudo apt-get -f install -y - sudo chown -R _snips:_snips /usr/share/snips/assistant/ - sudo systemctl restart mosquitto - sudo systemctl restart snips-hotword - sudo systemctl restart snips-dialogue - sudo systemctl restart snips-injection - echo "Finished giving install commands. (shell)" -} - - -install_assistant() { - echo "Installing assistant (shell)" - sudo rm -rf /usr/share/snips/assistant - sudo unzip -o snips/assistant.zip -d /usr/share/snips - sudo chown -R _snips:_snips /usr/share/snips/assistant/ - sudo systemctl restart snips-hotword - sudo systemctl restart snips-dialogue - sudo systemctl restart snips-injection - echo "Command success (shell)" -} - - -add_vocabulary() { - if [ -f "vocabulary_installed" ]; then - echo "In theory the vocabulary is already installed. Remove the 'vocabulary_installed' file to unblock this." - exit 1 - fi - touch busy_installing_vocabulary - #echo "Downloading and installing 150Mb dictionary, please be patient" # Handled by Python now. - #wget https://raspbian.snips.ai/stretch/pool/s/sn/snips-asr-model-en-500MB_0.6.0-alpha.4_armhf.deb - echo "Installing 500Mb voice dictionary, please be patient (shell)" - chmod +x snips/snips-asr-model-en-500MB_0.6.0-alpha.4_armhf.deb - #sudo gdebi snips/snips-asr-model-en-500MB_0.6.0-alpha.4_armhf.deb - ar -xv snips/snips-asr-model-en-500MB_0.6.0-alpha.4_armhf.deb - #sudo dpkg-deb snips/bigger_vocabulary.deb - if [ -d "/usr/share/snips/snips-asr-model-en-500MB" ]; then - sudo cp snips/snips_extra.toml /etc/snips.toml - sudo chown -R _snips:_snips /usr/share/snips/ - touch vocabulary_installed - echo "Command success (shell)" - fi - rm busy_installing_vocabulary - -} - -install_respeaker_driver() { - git clone https://github.com/respeaker/seeed-voicecard - cd seeed-voicecard - sudo ./install.sh n - if [ -f "/etc/voicecard" ]; then - touch $RESPEAKERDONEPATH - echo "succesfully installed respeaker driver (shell)" - echo "Command success (shell)" - fi - touch $RESPEAKERDONEPATH - #echo "Command success (from sh)" - #sudo reboot -} - - -uninstall() { - for pkg in ${required_packages[@]}; do - pkg_="$(cut -d'_' -f1 <<<"$pkg")" - sudo dpkg --purge --force-depends "$pkg_" - done - sudo rm -rf /usr/share/snips/ - if [ -f $DONEPATH ]; then - echo "Uninstall complete" - rm $DONEPATH - fi -} - - -if [[ $1 == "install" ]]; then - printf '%s\n' "${PWD##*/}" # to print to stdout - touch $BUSYPATH - install_snips - #install_assistant - rm $BUSYPATH - if [ -d "/usr/share/snips/g2p-models" ]; then - if [ -d "/usr/share/snips/assistant" ]; then - touch $DONEPATH - echo "succesfully installed snips and assistant (shell)" - echo "Command success (shell)" - else - echo "Error: Snips was installed, but the assistant was not (shell)." - fi - else - echo "ERROR: Snips was NOT installed (shell)" - fi -elif [[ $1 == "install_assistant" ]]; then - install_assistant -elif [[ $1 == "install_respeaker_driver" ]]; then - install_respeaker_driver -elif [[ $1 == "install_extra_vocabulary" ]]; then - add_vocabulary -elif [[ $1 == "uninstall" ]]; then - uninstall -else - echo "use 'install' or 'install_assistant' parameter" -fi - diff --git a/main.py b/main.py index 980e557b..603b974d 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,5 @@ """Voco adapter and notifier for Mozilla WebThings Gateway.""" -"""MySensors adapter for Mozilla WebThings Gateway.""" - from os import path import functools import gateway_addon diff --git a/package.json b/package.json index 69d9fe17..65212c8f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "0.0.6", "description": "Privacy friendly voice control. Say 'Hey Snips' to start a voice command.", "author": "CreateCandle", - "main": "bootstrap.py", + "main": "main.py", "keywords": [ "mozilla", "iot", @@ -24,7 +24,6 @@ "files": [ "LICENSE", "SHA256SUMS", - "bootstrap.py", "main.py", "pkg/__init__.py", "pkg/voco_adapter.py", @@ -37,9 +36,7 @@ "sounds/end_of_input.wav", "sounds/end_spot.wav", "sounds/error.wav", - "snips.tar", - "requirements.txt", - "setup.cfg" + "snips.tar" ], "moziot": { "api": { @@ -47,7 +44,7 @@ "max": 2 }, "plugin": true, - "exec": "python3 {path}/bootstrap.py", + "exec": "python3 {path}/main.py", "config": { "Microphone": "Attached device (1,0)", "Speaker": "Built-in headphone jack (0,0)", diff --git a/package.sh b/package.sh old mode 100644 new mode 100755 index dcf58984..c5b48217 --- a/package.sh +++ b/package.sh @@ -38,13 +38,13 @@ mkdir lib # Pull down Python dependencies pip3 install -r requirements.txt -t lib --no-binary fuzzywuzzy,python-dateutil,pytz,paho-mqtt --prefix "" -cp -r pkg lib snips.tar sounds LICENSE package.json *.py requirements.txt setup.cfg package/ +cp -r pkg lib snips.tar sounds LICENSE package.json *.py package/ find package -type f -name '*.pyc' -delete find package -type d -empty -delete # Generate checksums cd package -sha256sum *.py snips.tar pkg/*.py sounds/*.wav LICENSE requirements.txt setup.cfg > SHA256SUMS +sha256sum *.py snips.tar pkg/*.py sounds/*.wav LICENSE > SHA256SUMS cd - # Make the tarball diff --git a/pkg/util.py b/pkg/util.py index 359c4f06..81f219df 100644 --- a/pkg/util.py +++ b/pkg/util.py @@ -212,36 +212,6 @@ def clean_up_string_for_speaking(sentence): -def run_command(command): - try: - p = subprocess.Popen(command, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - shell=True) - # Read stdout from subprocess until the buffer is empty ! - for bline in iter(p.stdout.readline, b''): - line = bline.decode('ASCII') #decodedLine = lines.decode('ISO-8859-1') - if line: # Don't print blank lines - yield line - # This ensures the process has completed, AND sets the 'returncode' attr - while p.poll() is None: - sleep(.1) #Don't waste CPU-cycles - # Empty STDERR buffer - err = p.stderr.read() - if p.returncode == 0: - yield("Command success") - else: - # The run_command() function is responsible for logging STDERR - #print("len(err) = " + str(len(err))) - if len(err) > 1: - yield("Error: " + str(err.decode('utf-8'))) - yield("Command failed") - #return False - except Exception as ex: - print("Error running shell command: " + str(ex)) - - - def split_sentences(st): sentences = re.split(r'[.?!]\s*', st) if sentences[-1]: @@ -342,9 +312,9 @@ def download_file(url, target_file): -def run_command(command): +def run_command(command, cwd=None): try: - return_code = subprocess.call(command, shell=True) + return_code = subprocess.call(command, shell=True, cwd=cwd) return return_code except Exception as ex: @@ -384,4 +354,4 @@ def run_command_with_lines(command): #return False except Exception as ex: print("Error running shell command: " + str(ex)) - \ No newline at end of file + diff --git a/pkg/voco_adapter.py b/pkg/voco_adapter.py index 18169644..c9ed0a74 100644 --- a/pkg/voco_adapter.py +++ b/pkg/voco_adapter.py @@ -116,7 +116,7 @@ def __init__(self, verbose=True): self.DEBUG = True self.DEV = True self.name = self.__class__.__name__ - Adapter.__init__(self, 'voco-adapter', 'voco', verbose=verbose) + Adapter.__init__(self, 'voco', 'voco', verbose=verbose) #print("Adapter ID = " + self.get_id()) self.persistence_file_path = "/home/pi/.mozilla/config/voco-persistence.json" @@ -592,19 +592,29 @@ def add_from_config(self): config['Speaker'] = self.playback_devices[0] # If the prefered device in config does not actually exist, but the scan did sho connected hardware, then select the first item from the scan results instead. self.speaker = self.playback_devices[0] store_updated_settings = True - - if 'Custom assistant' in config: + + should_install = True + if 'Custom assistant' in config and config['Custom assistant']: print("-Custom assistant was in config") possible_url = str(config['Custom assistant']) #print(str(possible_url)) if possible_url.startswith("http") and possible_url.endswith(".zip") and self.snips_installed: print("-Custom assistant data was a good URL.") self.custom_assistant_url = possible_url + if not self.download_assistant(): + should_install = False elif possible_url == "Your new assistant has succesfully been installed": print("--The 'assistant succesfully installed' message was present in the config") else: print("--Cannot use what is in the Custom assistant input field") + + # Install assistant if it hasn't been installed already + if should_install: + try: + self.assistant_installed = self.install_assistant() + except Exception as ex: + print("Error while trying to install assistant/check if should be installed: " + str(ex)) # Store the settings that were changed by the add-on. if store_updated_settings: @@ -755,15 +765,13 @@ def download_assistant(self): def install_assistant(self): """Install snips/assistant.zip into /usr/share/snips/assistant""" - return True - print("Installing assistant") try: if not os.path.isfile( os.path.join(self.addon_path,"snips","assistant.zip") ): print("Error: cannot install assistant: there doesn't seem to be an assistant.zip file in the snips folder of the addon.") - return - command = "unzip " + str(os.path.join(self.addon_path,"snips","assistant.zip")) + " " + str(os.path.join(self.addon_path,"snips")) - if run_command(command) == 0: + return False + command = "unzip assistant.zip" + if run_command(command, cwd=os.path.join(self.addon_path,"snips")) == 0: self.set_status_on_thing("Succesfully installed assistant") return True else: diff --git a/snips/libatlas3-base_3.10.3-1-snips_armhf.deb b/snips/libatlas3-base_3.10.3-1-snips_armhf.deb deleted file mode 100644 index 5515fb0a..00000000 Binary files a/snips/libatlas3-base_3.10.3-1-snips_armhf.deb and /dev/null differ diff --git a/snips/libblas-common_3.7.0-2_armhf.deb b/snips/libblas-common_3.7.0-2_armhf.deb deleted file mode 100644 index cc25eca6..00000000 Binary files a/snips/libblas-common_3.7.0-2_armhf.deb and /dev/null differ diff --git a/snips/libgfortran3_6.3.0-18+rpi1+deb9u1_armhf.deb b/snips/libgfortran3_6.3.0-18+rpi1+deb9u1_armhf.deb deleted file mode 100644 index 40e6b481..00000000 Binary files a/snips/libgfortran3_6.3.0-18+rpi1+deb9u1_armhf.deb and /dev/null differ diff --git a/snips/libportaudio2_19.6.0-1_armhf.deb b/snips/libportaudio2_19.6.0-1_armhf.deb deleted file mode 100644 index 22ecc300..00000000 Binary files a/snips/libportaudio2_19.6.0-1_armhf.deb and /dev/null differ diff --git a/snips/libttspico-data_1.0+git20130326-5_all.deb b/snips/libttspico-data_1.0+git20130326-5_all.deb deleted file mode 100644 index cbfbbd94..00000000 Binary files a/snips/libttspico-data_1.0+git20130326-5_all.deb and /dev/null differ diff --git a/snips/libttspico-utils_1.0+git20130326-5_armhf.deb b/snips/libttspico-utils_1.0+git20130326-5_armhf.deb deleted file mode 100644 index 3b57c991..00000000 Binary files a/snips/libttspico-utils_1.0+git20130326-5_armhf.deb and /dev/null differ diff --git a/snips/libttspico0_1.0+git20130326-5_armhf.deb b/snips/libttspico0_1.0+git20130326-5_armhf.deb deleted file mode 100644 index 2d472893..00000000 Binary files a/snips/libttspico0_1.0+git20130326-5_armhf.deb and /dev/null differ diff --git a/snips/libwebsockets8_2.0.3-2+b1~rpt1_armhf.deb b/snips/libwebsockets8_2.0.3-2+b1~rpt1_armhf.deb deleted file mode 100644 index ba9ee76f..00000000 Binary files a/snips/libwebsockets8_2.0.3-2+b1~rpt1_armhf.deb and /dev/null differ diff --git a/snips/mosquitto b/snips/mosquitto old mode 100644 new mode 100755 diff --git a/snips/mosquitto_1.4.10-3+deb9u4_armhf.deb b/snips/mosquitto_1.4.10-3+deb9u4_armhf.deb deleted file mode 100644 index 40bd046c..00000000 Binary files a/snips/mosquitto_1.4.10-3+deb9u4_armhf.deb and /dev/null differ diff --git a/snips/mosquitto_passwd b/snips/mosquitto_passwd old mode 100644 new mode 100755 diff --git a/snips/nanotts b/snips/nanotts old mode 100644 new mode 100755 diff --git a/snips/snips-asr b/snips/snips-asr old mode 100644 new mode 100755 diff --git a/snips/snips-asr_0.63.2_armhf.deb b/snips/snips-asr_0.63.2_armhf.deb deleted file mode 100644 index f5b87b56..00000000 Binary files a/snips/snips-asr_0.63.2_armhf.deb and /dev/null differ diff --git a/snips/snips-audio-server b/snips/snips-audio-server old mode 100644 new mode 100755 diff --git a/snips/snips-audio-server_0.63.2_armhf.deb b/snips/snips-audio-server_0.63.2_armhf.deb deleted file mode 100644 index a0cb7ef4..00000000 Binary files a/snips/snips-audio-server_0.63.2_armhf.deb and /dev/null differ diff --git a/snips/snips-dialogue b/snips/snips-dialogue old mode 100644 new mode 100755 diff --git a/snips/snips-dialogue_0.63.2_armhf.deb b/snips/snips-dialogue_0.63.2_armhf.deb deleted file mode 100644 index 589ac0b2..00000000 Binary files a/snips/snips-dialogue_0.63.2_armhf.deb and /dev/null differ diff --git a/snips/snips-extra.toml b/snips/snips-extra.toml old mode 100644 new mode 100755 diff --git a/snips/snips-hotword b/snips/snips-hotword old mode 100644 new mode 100755 diff --git a/snips/snips-hotword_0.63.2_armhf.deb b/snips/snips-hotword_0.63.2_armhf.deb deleted file mode 100644 index bcfa4933..00000000 Binary files a/snips/snips-hotword_0.63.2_armhf.deb and /dev/null differ diff --git a/snips/snips-injection b/snips/snips-injection old mode 100644 new mode 100755 diff --git a/snips/snips-injection_0.63.2_armhf.deb b/snips/snips-injection_0.63.2_armhf.deb deleted file mode 100644 index bb8441f4..00000000 Binary files a/snips/snips-injection_0.63.2_armhf.deb and /dev/null differ diff --git a/snips/snips-kaldi-atlas_0.24.2_armhf.deb b/snips/snips-kaldi-atlas_0.24.2_armhf.deb deleted file mode 100644 index 93413d10..00000000 Binary files a/snips/snips-kaldi-atlas_0.24.2_armhf.deb and /dev/null differ diff --git a/snips/snips-nlu b/snips/snips-nlu old mode 100644 new mode 100755 diff --git a/snips/snips-nlu_0.63.2_armhf.deb b/snips/snips-nlu_0.63.2_armhf.deb deleted file mode 100644 index f43caacb..00000000 Binary files a/snips/snips-nlu_0.63.2_armhf.deb and /dev/null differ diff --git a/snips/snips-platform-common_0.63.2_armhf.deb b/snips/snips-platform-common_0.63.2_armhf.deb deleted file mode 100644 index 0992ab18..00000000 Binary files a/snips/snips-platform-common_0.63.2_armhf.deb and /dev/null differ diff --git a/snips/snips-platform-voice_0.63.2_armhf.deb b/snips/snips-platform-voice_0.63.2_armhf.deb deleted file mode 100644 index acaebfac..00000000 Binary files a/snips/snips-platform-voice_0.63.2_armhf.deb and /dev/null differ diff --git a/snips/snips-tts b/snips/snips-tts old mode 100644 new mode 100755 diff --git a/snips/snips-tts_0.63.2_armhf.deb b/snips/snips-tts_0.63.2_armhf.deb deleted file mode 100644 index e528369d..00000000 Binary files a/snips/snips-tts_0.63.2_armhf.deb and /dev/null differ diff --git a/snips/snips-watch b/snips/snips-watch old mode 100644 new mode 100755 diff --git a/snips/snips.toml b/snips/snips.toml index 6876800f..3b0174cf 100644 --- a/snips/snips.toml +++ b/snips/snips.toml @@ -72,7 +72,7 @@ provider = "customtts" ## customtts specific configuration (here configured to use picotts using the en-US language) ## available placeholder variables : %%OUTPUT_FILE%%, %%LANG%%, %%TEXT%% # customtts = { command = ["pico2wave", "-w", "%%OUTPUT_FILE%%", "-l", "en-US", "%%TEXT%%"] } -customtts = { command = ["/home/pi/.mozilla/addons/vodo/snips/speak.sh", "%%TEXT%%" ] } +customtts = { command = ["/home/pi/.mozilla/addons/voco/snips/speak.sh", "%%TEXT%%" ] } [snips-pegasus] diff --git a/snips/speak.sh b/snips/speak.sh old mode 100644 new mode 100755 diff --git a/speak.sh b/speak.sh deleted file mode 100644 index 8270e9e6..00000000 --- a/speak.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -echo "Current dir is called $DIR" -echo "$1" | ${DIR}/snips/nanotts -o ./playme.wav -l ${DIR}/snips/lang --speed 0.85 --pitch 1.2 --volume 1 -p -#echo "Done speaking (shell)" -exit 0 \ No newline at end of file diff --git a/start.sh b/start.sh deleted file mode 100644 index be168c07..00000000 --- a/start.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -echo $DIR - -SNIPSPATH="$DIR/snips/" -WORKPATH="$DIR/snips/work/" -echo "Snipspath = $SNIPSPATH" - -export PATH=${SNIPSPATH}:$PATH - -echo "Stopping any existing snips processes" -pkill -f snips - -# Add path -export LD_LIBRARY_PATH=${SNIPSPATH}:"${SNIPSPATH}arm-linux-gnueabihf/":$LD_LIBRARY_PATH - -#export PA_ALSA_PLUGHW=1 - -echo "Playing a test audio file" -# START THE AUDIO -amixer sset PCM unmute -amixer cset numid=3 1 -amixer cset numid=1 100% -aplay -D plughw:0,0 "$DIR/assets/end_spot.wav" - -echo "Starting moquitto" -LD_LIBRARY_PATH=${SNIPSPATH}:"${SNIPSPATH}arm-linux-gnueabihf" "${SNIPSPATH}mosquitto" & - -sleep 3 - -echo "Starting Snips Audio Server" -LD_LIBRARY_PATH=${SNIPSPATH}:"${SNIPSPATH}arm-linux-gnueabihf" "${SNIPSPATH}snips-audio-server" -u ${WORKPATH} -c "${SNIPSPATH}snips.toml" -a "${SNIPSPATH}assistant" --alsa_capture plughw:1,0 --alsa_playback plughw:0,0 & - -echo "Starting Snips Dialogue" -LD_LIBRARY_PATH=${SNIPSPATH}:"${SNIPSPATH}arm-linux-gnueabihf" "${SNIPSPATH}snips-dialogue" -u ${WORKPATH} -c "${SNIPSPATH}snips.toml" -a "${SNIPSPATH}assistant" & - -echo "Starting Snips ASR in the background" -LD_LIBRARY_PATH=${SNIPSPATH}:"${SNIPSPATH}arm-linux-gnueabihf" "${SNIPSPATH}snips-asr" -u ${WORKPATH} -c "${SNIPSPATH}snips.toml" -a "${SNIPSPATH}assistant" & - -echo "Starting Snips NLU" -LD_LIBRARY_PATH=${SNIPSPATH}:"${SNIPSPATH}arm-linux-gnueabihf" "${SNIPSPATH}snips-nlu" -u ${WORKPATH} -c "${SNIPSPATH}snips.toml" -a "${SNIPSPATH}assistant" & - -echo "Starting Snips Injection" -LD_LIBRARY_PATH=${SNIPSPATH}:"${SNIPSPATH}arm-linux-gnueabihf" "${SNIPSPATH}snips-injection" -u ${WORKPATH} -c "${SNIPSPATH}snips.toml" -a "${SNIPSPATH}assistant" -g "${SNIPSPATH}g2p-models" & - -echo "Starting Snips TTS" -LD_LIBRARY_PATH=${SNIPSPATH}:"${SNIPSPATH}arm-linux-gnueabihf" "${SNIPSPATH}snips-tts" -u ${WORKPATH} -c "${SNIPSPATH}snips.toml" -a "${SNIPSPATH}assistant" & - - -echo "Starting Snips Hotword" -LD_LIBRARY_PATH=${SNIPSPATH}:"${SNIPSPATH}arm-linux-gnueabihf" "${SNIPSPATH}snips-hotword" -u ${WORKPATH} -c "${SNIPSPATH}snips.toml" -a "${SNIPSPATH}assistant" & - - -echo "Command success" -#exit 0 \ No newline at end of file diff --git a/start_snips.sh b/start_snips.sh deleted file mode 100644 index c9e530c4..00000000 --- a/start_snips.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -echo $DIR -BUSYPATH="$DIR/busy_installing" -DONEPATH="$DIR/snips_installed" -RESPEAKERDONEPATH="$DIR/respeaker_installed" -ASSISTANTPATH="$DIR/snips/assistant.zip" -ASSISTANTDONEPATH="$DIR/respeaker_installed" - -LIBPATH="$DIR/snips/usr/lib" -BINPATH="$DIR/snips/usr/bin" - -PATH=/home/pi/.mozilla/addons/voco/snips/usr/bin/:$PATH - -echo "Starting moquitto" -./snips/usr/lib/mosquitto - -echo "Starting Snips Hotword" -LD_LIBRARY_PATH=/home/pi/.mozilla-iot/addons/voco/snips/usr/lib:/home/pi/.mozilla-iot/addons/voco/snips/usr/lib/arm-linux-gnueabihf /home/pi/.mozilla-iot/addons/voco/snips/usr/lib/snips-hotword -u /home/pi/.mozilla-iot/addons/voco/work -c /home/pi/.mozilla-iot/addons/voco/snips/etc/snips.toml -a /home/pi/.mozilla-iot/addons/voco/snips/assistant - -#LD_LIBRARY_PATH=/home/pi/.mozilla/addons/voco/snips/usr/lib ./usr/bin/snips-hotword -#LD_LIBRARY_PATH=${LIBPATH} ./usr/bin/snips-hotword - -echo "Starting Snips ASR in the background" -LD_LIBRARY_PATH=/home/pi/.mozilla-iot/addons/voco/snips/usr/lib:/home/pi/.mozilla-iot/addons/voco/snips/usr/lib/arm-linux-gnueabihf /home/pi/.mozilla-iot/addons/voco/snips/usr/lib/snips-asr -u /home/pi/.mozilla-iot/addons/voco/work -c /home/pi/.mozilla-iot/addons/voco/snips/etc/snips.toml -a /home/pi/.mozilla-iot/addons/voco/snips/assistant -#LD_LIBRARY_PATH=${LIBPATH} .snips/usr/bin/snips-hotword -#LD_LIBRARY_PATH=/home/pi/.mozilla/addons/voco/snips/usr/lib ./usr/bin/snips-asr - -echo "Starting Snips NLU" -LD_LIBRARY_PATH=/home/pi/.mozilla-iot/addons/voco/snips/usr/lib:/home/pi/.mozilla-iot/addons/voco/snips/usr/lib/arm-linux-gnueabihf /home/pi/.mozilla-iot/addons/voco/snips/usr/lib/snips-nlu -u /home/pi/.mozilla-iot/addons/voco/work -c /home/pi/.mozilla-iot/addons/voco/snips/etc/snips.toml -a /home/pi/.mozilla-iot/addons/voco/snips/assistant - - - -#echo $DONEPATH - -#set -e - - -# snips/libwebsockets8_2.0.3-2+b1~rpt1_armhf.deb -# snips/mosquitto_1.4.10-3+deb9u4_armhf.deb - -required_packages=( - libportaudio2_19.6.0-1_armhf.deb - libblas-common_3.7.0-2_armhf.deb - libatlas3-base_3.10.3-1-snips_armhf.deb - libgfortran3_6.3.0-18+rpi1+deb9u1_armhf.deb - libttspico-data_1.0+git20130326-5_all.deb - libttspico0_1.0+git20130326-5_armhf.deb - libttspico-utils_1.0+git20130326-5_armhf.deb - snips-platform-common_0.63.2_armhf.deb - snips-kaldi-atlas_0.24.2_armhf.deb - snips-asr_0.63.2_armhf.deb - snips-audio-server_0.63.2_armhf.deb - snips-dialogue_0.63.2_armhf.deb - snips-hotword_0.63.2_armhf.deb - snips-injection_0.63.2_armhf.deb - snips-nlu_0.63.2_armhf.deb - snips-platform-voice_0.63.2_armhf.deb - snips-tts_0.63.2_armhf.deb -) - diff --git a/stop.sh b/stop.sh deleted file mode 100644 index a63cc880..00000000 --- a/stop.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -echo "Stopping any existing snips processes (shell)" -pkill -f snips -#echo "Command succesful" -exit 0