├── README.md └── docker-pulseaudio ├── Dockerfile ├── VERSION ├── client.conf ├── daemon.conf ├── default.pa └── snips-entrypoint.sh /README.md: -------------------------------------------------------------------------------- 1 | # Snips Platform Docker Container 2 | 3 | ## Scope 4 | 5 | This repository provides the instructions, DockerFile and scripts needed to: 6 | 7 | - Run the snips platform components in a docker container. 8 | - Provide the host platform audio capture and playback interfaces to the container. 9 | 10 | > Those instructions assume that the reader is familiar with the use of docker containers. 11 | 12 | ## Build the snips platform container 13 | 14 | ### Prerequisites 15 | 16 | - [Docker](https://docs.docker.com/ee/desktop/) is up and running on your host operating system. 17 | 18 | ### Clone this repository 19 | 20 | ```bash 21 | git clone git@github.com:snipsco/snips-platform-docker.git 22 | ``` 23 | 24 | ### Build the container 25 | 26 | Enter the `docker-pulseaudio` sub folder and build the container. 27 | 28 | ```bash 29 | cd docker-pulseaudio 30 | docker build --no-cache -t snips-pulseaudio-docker . 31 | ``` 32 | 33 | Once completed, this operation should return the following message. 34 | 35 | ```bash 36 | Successfully tagged snips-pulseaudio-docker:latest 37 | ``` 38 | 39 | This container is preconfigured for the `snips-audio-server` component to use `PulseAudio` audio backend. 40 | 41 | Hence, a `PulseAudio` **server** must be started on the host operating system to share its capture and playback interfaces with the container running the snips platform. 42 | 43 | ```ascii 44 | + ----------------------------------------------------------- + 45 | | Host OS +------------------------+ | 46 | | | Docker Container | | 47 | | +----------------------+ tcp | +--------------------+ | | 48 | | | PulseAudio Server | <----> | | PulseAudio Client | | | 49 | | +----------------------+ | +--------------------+ | | 50 | | | ^ ️ | | ^ | | 51 | | ️ v | | v | | | 52 | | +----------------------+ | +--------------------+ | | 53 | | | Host Audio | | | snips-audio-server | | | 54 | | | Capture and Playback | | +--------------------+ | | 55 | | +----------------------+ +------------------------+ | 56 | + ----------------------------------------------------------- + 57 | ``` 58 | 59 | ## Configure PulseAudio server 60 | 61 | ### Install on Windows 62 | 63 | - Retrieve Windows [v1.1 binaries](https://www.freedesktop.org/wiki/Software/PulseAudio/Ports/Windows/Support/) 64 | - Unzip the content of the archive. 65 | - Open a terminal and navigate to the `bin` subfolder. 66 | 67 | ### Install on MacOS (homebrew) 68 | 69 | ```bash 70 | brew install pulseaudio 71 | ``` 72 | 73 | ### Run PulseAudio Server 74 | 75 | The host capture and playback interface will be interfaced to the container using `module-native-protocol-tcp` PulseAudio module. 76 | 77 | Execute the following command in a terminal to launch the server as backgroung process 78 | 79 | ```bash 80 | # Windows 81 | pulseaudio.exe --load="module-native-protocol-tcp auth-anonymous=1" --exit-idle-time=-1 --daemon 82 | ``` 83 | 84 | ```bash 85 | # MacOS and Linux 86 | pulseaudio --load="module-native-protocol-tcp auth-anonymous=1" --exit-idle-time=-1 --daemon 87 | ``` 88 | 89 | Notes: 90 | 91 | - Using Windows or MacOS, make sure that the PulseAudio server is allowed to use the network and audio interfaces. 92 | - Using Windows, the PulseAudio Server can be terminated using the task manager. 93 | - For debug purpose, remove `--daemon` flag to observe the server logs in a terminal. 94 | - In this example, no authentication is needed to connect to the PulseAudio Server. Please refer to PulseAudio [documentation](https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Network/#index2h2) for other authentication methods. 95 | 96 | ## Run the Snips Platform docker container 97 | 98 | ### PulseAudio Server IP Address 99 | 100 | The host IP address must be passed to the container for it to connect to the PulseAudio server. 101 | 102 | Identify the host IP address and replace the `` place holder by the correct value. 103 | 104 | ### Start the docker container 105 | 106 | ```bash 107 | docker run -it -e PULSE_SERVER= -e SNIPS_AUDIO_SERVER_ARGS="--alsa_capture=pulse --alsa_playback=pulse -v" -e SNIPS_AUDIO_SERVER_ENABLED="true" snips-pulseaudio-docker:latest 108 | ``` 109 | 110 | > **Note** 111 | > 112 | > On Windows, when starting the container, the following error log appears when the entry point script as been modified with windows end of line caracter: `standard_init_linux.go:211: exec user process caused "no such file or directory"` 113 | > 114 | > Use a tool such as `dos2unix` to reformat `snips-entrypoint.sh` correctly and rebuild your container. 115 | 116 | ### Inspect the platform with snips-watch 117 | 118 | You can then connect to the running container and start `snips-watch` to check if everything is working as expected. 119 | 120 | To do so, find your snips container `Id` or `name` and start `snips-watch`. 121 | 122 | ```bash 123 | docker ps -a 124 | docker exec -it snips-watch -v 125 | ``` 126 | 127 | ## Deploy your assistant 128 | 129 | You might want to replace the default weather demo assistant with your own assistant. 130 | 131 | To do so, retrieve an assistant package on the console and unzip it on your machine. 132 | 133 | Then, you can either mount your assistant folder within the snips-platform container or build a new container to include your assistant. 134 | 135 | ### Method 1 - Mount your assistant in your snips platform container 136 | 137 | To provide this assistant to your container without modifiying it, execute the following command to override the default assistant subfolder located at `/usr/share/snips/assistant`. 138 | 139 | Replace `` placeholder by the correct path to your assistant. 140 | 141 | ```bash 142 | docker run -it -e PULSE_SERVER= -e SNIPS_AUDIO_SERVER_ARGS="--alsa_capture=pulse --alsa_playback=pulse -v" -e SNIPS_AUDIO_SERVER_ENABLED="true" -v :/usr/share/snips/assistant snips-pulseaudio-docker:latest 143 | ``` 144 | 145 | ### Method 2 - Build a new container with your assistant 146 | 147 | If you want a single container that include your assistant, modify the docker file to `COPY` it to your container at build time. 148 | 149 | To do so, modify the `Dockerfile` to copy your assistant folder into the container. 150 | 151 | If your assistant folder is located in the `docker-pulseaudio` sub folder, add this line to your `Dockerfile`. 152 | 153 | ```bash 154 | COPY assistant /usr/share/snips/assistant 155 | ``` 156 | 157 | Once done, rebuild your docker container and start it. 158 | 159 | ## Integration with your action code 160 | 161 | There is also multiple ways to proceed, one can either: 162 | 163 | - Expose mosquitto MQTT broker port to the host operating system and run the action code locally. 164 | - Package and run the action code within the container. 165 | 166 | ### Method 1 - Expose the MQTT broker to the host 167 | 168 | Mosquitto MQTT broker is already running on the container on the port `1883`. 169 | 170 | To expose this port to the host, modify the DockerFile, `EXPOSE` this port and rebuild the container. 171 | 172 | ```bash 173 | # e.g. expose port 1883 using port 8888 on the host at build time. 174 | EXPOSE 8888:1883 175 | ``` 176 | 177 | It is also possible to do it at execution time by adding the option `-p :` to the command line. 178 | 179 | ```bash 180 | # e.g. expose port 1883 using port 8888 on the host at execution time. 181 | docker run -it -e PULSE_SERVER= -e SNIPS_AUDIO_SERVER_ARGS="--alsa_capture=pulse --alsa_playback=pulse -v" -e SNIPS_AUDIO_SERVER_ENABLED="true" -p 8888:1883 snips-pulseaudio-docker:latest 182 | ``` 183 | 184 | Then you can test that the MQTT broker is correctly exposed on your local host using a MQTT client such as `mosquitto_pub` 185 | 186 | ```bash 187 | mosquitto_pub -t hermes/tts/say -h localhost -p 8888 -m '{"siteId":"default", "lang":"en-us", "text": "Can you ear this? Thanks for your attention.", "id": "123456", "sessionId": "1234"}' 188 | ``` 189 | 190 | Your action code is now able to communicate with the snips platform through the MQTT broker. 191 | 192 | ### Method 2 - Run your action code in the container 193 | 194 | - Modify the `DockerFile` to include your action code. 195 | - Modify the `snips-entrypoint.sh` to launch your services. 196 | - Rebuild the container. 197 | -------------------------------------------------------------------------------- /docker-pulseaudio/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | 3 | RUN apt-get update \ 4 | && apt-get install -y --force-yes apt-transport-https \ 5 | ca-certificates \ 6 | dirmngr 7 | 8 | 9 | ENV UNAME snips 10 | 11 | RUN DEBIAN_FRONTEND=noninteractive apt-get install --yes alsa-utils \ 12 | libasound2 \ 13 | libasound2-plugins \ 14 | pulseaudio \ 15 | pulseaudio-utils \ 16 | --no-install-recommends 17 | 18 | RUN bash -c 'echo "deb [trusted=yes] https://debian.snips.ai/stretch stable main" > /etc/apt/sources.list.d/snips.list' 19 | 20 | RUN apt-get update 21 | RUN apt-get install -y snips-platform-voice snips-watch snips-platform-demo 22 | RUN apt-get install -y snips-template snips-skill-server 23 | 24 | RUN apt-get install -y --force-yes \ 25 | jq \ 26 | supervisor \ 27 | mosquitto \ 28 | mosquitto-clients \ 29 | sox \ 30 | unzip \ 31 | --yes \ 32 | --no-install-recommends \ 33 | && mkdir -p /var/lib/snips \ 34 | && apt-get -y autoclean \ 35 | && apt-get -y autoremove \ 36 | && rm -rf /var/lib/apt/lists/* 37 | 38 | RUN usermod -aG audio,pulse,pulse-access _snips 39 | RUN usermod -aG audio,pulse,pulse-access root 40 | 41 | COPY snips-entrypoint.sh /opt/snips/snips-entrypoint.sh 42 | COPY VERSION /VERSION 43 | 44 | COPY default.pa /etc/pulse/default.pa 45 | COPY client.conf /etc/pulse/client.conf 46 | COPY daemon.conf /etc/pulse/daemon.conf 47 | 48 | 49 | ENTRYPOINT ["/opt/snips/snips-entrypoint.sh"] 50 | -------------------------------------------------------------------------------- /docker-pulseaudio/VERSION: -------------------------------------------------------------------------------- 1 | TYPE=development 2 | -------------------------------------------------------------------------------- /docker-pulseaudio/client.conf: -------------------------------------------------------------------------------- 1 | # This file is part of PulseAudio. 2 | # 3 | # PulseAudio is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU Lesser General Public License as published by 5 | # the Free Software Foundation; either version 2 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # PulseAudio is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with PulseAudio; if not, write to the Free Software 15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 16 | # USA. 17 | 18 | ## Configuration file for PulseAudio clients. See pulse-client.conf(5) for 19 | ## more information. Default values are commented out. Use either ; or # for 20 | ## commenting. 21 | 22 | ; default-sink = 23 | ; default-source = 24 | ; default-server = 25 | ; default-dbus-server = 26 | 27 | autospawn = no 28 | daemon-binary = /bin/true 29 | ; extra-arguments = --log-target=syslog 30 | 31 | ; cookie-file = 32 | 33 | ; enable-shm = yes 34 | ; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB 35 | 36 | ; auto-connect-localhost = no 37 | ; auto-connect-display = no 38 | 39 | -------------------------------------------------------------------------------- /docker-pulseaudio/daemon.conf: -------------------------------------------------------------------------------- 1 | # This file is part of PulseAudio. 2 | # 3 | # PulseAudio is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU Lesser General Public License as published by 5 | # the Free Software Foundation; either version 2 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # PulseAudio is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with PulseAudio; if not, see . 15 | 16 | ## Configuration file for the PulseAudio daemon. See pulse-daemon.conf(5) for 17 | ## more information. Default values are commented out. Use either ; or # for 18 | ## commenting. 19 | 20 | ; daemonize = no 21 | ; fail = yes 22 | ; allow-module-loading = yes 23 | ; allow-exit = yes 24 | ; use-pid-file = yes 25 | ; system-instance = no 26 | ; local-server-type = user 27 | ; enable-shm = yes 28 | ; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB 29 | ; lock-memory = no 30 | ; cpu-limit = no 31 | 32 | ; high-priority = yes 33 | ; nice-level = -11 34 | 35 | ; realtime-scheduling = yes 36 | ; realtime-priority = 5 37 | 38 | exit-idle-time = 180 39 | ; scache-idle-time = 20 40 | 41 | ; dl-search-path = (depends on architecture) 42 | 43 | ; load-default-script-file = yes 44 | ; default-script-file = /etc/pulse/default.pa 45 | 46 | ; log-target = auto 47 | ; log-level = notice 48 | ; log-meta = no 49 | ; log-time = no 50 | ; log-backtrace = 0 51 | 52 | ; resample-method = speex-float-1 53 | ; enable-remixing = yes 54 | ; enable-lfe-remixing = no 55 | 56 | flat-volumes = yes 57 | 58 | ; rlimit-fsize = -1 59 | ; rlimit-data = -1 60 | ; rlimit-stack = -1 61 | ; rlimit-core = -1 62 | ; rlimit-as = -1 63 | ; rlimit-rss = -1 64 | ; rlimit-nproc = -1 65 | ; rlimit-nofile = 256 66 | ; rlimit-memlock = -1 67 | ; rlimit-locks = -1 68 | ; rlimit-sigpending = -1 69 | ; rlimit-msgqueue = -1 70 | ; rlimit-nice = 31 71 | ; rlimit-rtprio = 9 72 | ; rlimit-rttime = 200000 73 | 74 | ; default-sample-format = s16le 75 | default-sample-rate = 16000 76 | alternate-sample-rate = 48000 77 | ; default-sample-channels = 2 78 | ; default-channel-map = front-left,front-right 79 | 80 | default-fragments = 5 81 | default-fragment-size-msec = 2 82 | 83 | ; enable-deferred-volume = yes 84 | ; deferred-volume-safety-margin-usec = 8000 85 | ; deferred-volume-extra-delay-usec = 0 86 | 87 | 88 | -------------------------------------------------------------------------------- /docker-pulseaudio/default.pa: -------------------------------------------------------------------------------- 1 | # Replace the *entire* content of this file with these few lines and 2 | # read the comments 3 | 4 | .fail 5 | # Set tsched=0 here if you experience glitchy playback. This will 6 | # revert back to interrupt-based scheduling and should fix it. 7 | # 8 | # Replace the device= part if you want pulse to use a specific device 9 | # such as "dmix" and "dsnoop" so it doesn't lock an hw: device. 10 | 11 | # INPUT/RECORD 12 | load-module module-alsa-source device="default" tsched=1 13 | 14 | # OUTPUT/PLAYBACK 15 | load-module module-alsa-sink device="default" tsched=1 16 | 17 | # Accept clients -- very important 18 | load-module module-native-protocol-unix 19 | load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/24 auth-anonymous=1 20 | 21 | .nofail 22 | .ifexists module-x11-publish.so 23 | # Publish to X11 so the clients know how to connect to Pulse. Will 24 | # clear itself on unload. 25 | load-module module-x11-publish 26 | .endif 27 | -------------------------------------------------------------------------------- /docker-pulseaudio/snips-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Execute cli if requested 4 | if [ "$1" = "snips" ] 5 | then 6 | shift 7 | exec snips "$@" 8 | fi 9 | 10 | 11 | ASSISTANT_FILE=/usr/share/snips/assistant/assistant.json 12 | if [ ! -f "$ASSISTANT_FILE" ] 13 | then 14 | echo "Couldn't find any assistant" 15 | exit 1 16 | fi 17 | 18 | SUPERVISORD_CONF_FILE="/etc/supervisor/conf.d/supervisord.conf" 19 | ASR_TYPE=`cat $ASSISTANT_FILE|jq --raw-output '.asr.type'` 20 | SNIPS_MOSQUITTO_FLAG="-h localhost -p 1883" 21 | 22 | 23 | if [ -z "$SNIPS_AUDIO_SERVER_MQTT_ARGS" ] 24 | then 25 | SNIPS_AUDIO_SERVER_MQTT_ARGS="--frame=256" 26 | fi 27 | 28 | if [ -d "/opt/snips/asr" ] 29 | then 30 | SNIPS_ASR_MODEL="" 31 | else 32 | SNIPS_ASR_MODEL="" 33 | fi 34 | if [ -z "$SNIPS_ASR_ARGS" ] 35 | then 36 | SNIPS_ASR_ARGS="$SNIPS_ASR_MODEL --beam_size=8" 37 | fi 38 | 39 | if [ -z "$SNIPS_ASR_MQTT_ARGS" ] 40 | then 41 | SNIPS_ASR_MQTT_ARGS="" 42 | fi 43 | 44 | if [ -z "$SNIPS_DIALOGUE_MQTT_ARGS" ] 45 | then 46 | SNIPS_DIALOGUE_MQTT_ARGS="" 47 | fi 48 | 49 | if [ -z "$SNIPS_ASR_GOOGLE_MQTT_ARGS" ] 50 | then 51 | SNIPS_ASR_GOOGLE_MQTT_ARGS="" 52 | fi 53 | 54 | if [ -z "$SNIPS_HOTWORD_ARGS" ] 55 | then 56 | SNIPS_HOTWORD_ARGS="" 57 | fi 58 | if [ -z "$SNIPS_HOTWORD_MQTT_ARGS" ] 59 | then 60 | SNIPS_HOTWORD_MQTT_ARGS="" 61 | fi 62 | 63 | if [ -z "$SNIPS_QUERIES_MQTT_ARGS" ] 64 | then 65 | SNIPS_QUERIES_MQTT_ARGS="" 66 | fi 67 | 68 | 69 | # Read "global" arguments 70 | USE_INTERNAL_MQTT=true 71 | ALL_SNIPS_COMPONENTS=("snips-asr-google" "snips-asr" "snips-audio-server" "snips-tts" "snips-hotword" "snips-nlu" "snips-dialogue" "snips-debug") 72 | declare -A SNIPS_COMPONENTS 73 | for c in ${ALL_SNIPS_COMPONENTS[@]} 74 | do 75 | SNIPS_COMPONENTS[$c]=true 76 | done 77 | 78 | if [ "$ASR_TYPE" != "google" ] 79 | then 80 | SNIPS_COMPONENTS["snips-asr-google"]=false 81 | elif [ "$ASR_TYPE" != "snips" ] 82 | then 83 | SNIPS_COMPONENTS["snips-asr"]=false 84 | fi 85 | 86 | if [ "$SNIPS_AUDIO_SERVER_ENABLED" != "true" ] 87 | then 88 | SNIPS_COMPONENTS["snips-audio-server"]=false 89 | fi 90 | 91 | for i in `seq 1 $#` 92 | do 93 | j=$((i+1)) 94 | TYPE_ARG="${!i}" 95 | VALUE_ARG="${!j}" 96 | if [[ "$TYPE_ARG" = "--verbose" || "$TYPE_ARG" = "-v" ]] 97 | then 98 | SNIPS_DEBUG=true 99 | fi 100 | done 101 | 102 | if [ "${SNIPS_DEBUG}" == true ] 103 | then 104 | echo "Execution env:" 105 | env 106 | LOGLEVEL="-v" 107 | SNIPS_COMPONENTS["snips-debug"]=true 108 | else 109 | LOGLEVEL="" 110 | SNIPS_COMPONENTS["snips-debug"]=false 111 | fi 112 | 113 | 114 | for i in `seq 1 $#` 115 | do 116 | j=$((i+1)) 117 | TYPE_ARG="${!i}" 118 | VALUE_ARG="${!j}" 119 | if [ "$TYPE_ARG" = "--exclude-components" ] 120 | then 121 | USE_EXCLUDE=true 122 | if [ "USE_INCLUDE" = true ] 123 | then 124 | echo "Cannot use --include-components and --exclude-components simultaneously" 125 | exit 1 126 | fi 127 | 128 | for i in `echo $VALUE_ARG|tr ',' ' '` 129 | do 130 | if [ -z ${SNIPS_COMPONENTS[$i]} ] 131 | then 132 | echo "Unknown snips component $i. Must be one of [${ALL_SNIPS_COMPONENTS[@]}]." 133 | exit 1 134 | fi 135 | unset SNIPS_COMPONENTS["$i"] 136 | done 137 | elif [ "$TYPE_ARG" = "--include-components" ] 138 | then 139 | USE_INCLUDE=true 140 | if [ "USE_EXCLUDE" = true ] 141 | then 142 | echo "Cannot use --include-components and --exclude-components simultaneously" 143 | exit 1 144 | elif [ -z "$VALUE_ARG" ] 145 | then 146 | echo "--include-components must be followed by a command-line list of components to include (${ALL_SNIPS_COMPONENTS[@]})" 147 | exit 1 148 | fi 149 | 150 | for c in ${ALL_SNIPS_COMPONENTS[@]} 151 | do 152 | SNIPS_COMPONENTS[$c]=false 153 | done 154 | for i in `echo $VALUE_ARG|tr ',' ' '` 155 | do 156 | if [[ -z "${SNIPS_COMPONENTS[$i]}" && $i != "none" ]] 157 | then 158 | echo "Unknown snips component $i. Must be one of [${ALL_SNIPS_COMPONENTS[@]} none]." 159 | exit 1 160 | fi 161 | SNIPS_COMPONENTS["$i"]=true 162 | done 163 | elif [ "$TYPE_ARG" = "--mqtt" ] 164 | then 165 | if [ -z "$VALUE_ARG" ] 166 | then 167 | echo "':' must be specified when using --mqtt" 168 | exit 1 169 | elif [ `echo "$VALUE_ARG" | tr -cd ':' | wc -c` != 1 ] 170 | then 171 | echo "--mqtt value must follow the pattern ':' with server and port separated by a single ':'" 172 | exit 1 173 | elif [ `echo "$VALUE_ARG" | tr -cd '#' | wc -c` != 0 ] 174 | then 175 | echo "--mqtt value must follow the pattern ':'. '#' character is not allowed." 176 | exit 1 177 | fi 178 | 179 | SNIPS_MQTT_HOST=`echo "$VALUE_ARG"| cut -d : -f 1` 180 | if [ -z "$SNIPS_MQTT_HOST" ] 181 | then 182 | echo "Must specify a server when using --mqtt" 183 | exit 1 184 | fi 185 | 186 | SNIPS_MQTT_PORT=`echo "$VALUE_ARG"| cut -d : -f 2` 187 | case "$SNIPS_MQTT_PORT" in 188 | ''|*[!0-9]*) 189 | echo "Must specify a numeric value for port when using --mqtt" 190 | exit 1 ;; 191 | *) ;; 192 | esac 193 | 194 | USE_INTERNAL_MQTT=false 195 | SNIPS_MQTT_FLAG="--mqtt '$SNIPS_MQTT_HOST:$SNIPS_MQTT_PORT'" 196 | SNIPS_MOSQUITTO_FLAG="-h $SNIPS_MQTT_HOST -p $SNIPS_MQTT_PORT" 197 | fi 198 | done 199 | 200 | # Generate global configuration 201 | cat < $SUPERVISORD_CONF_FILE 202 | [supervisord] 203 | nodaemon=true 204 | 205 | EOT 206 | 207 | 208 | # Generate snips-asr-google 209 | if [ "${SNIPS_COMPONENTS['snips-asr-google']}" = true ] 210 | then 211 | echo Spawning /usr/bin/snips-asr-google $LOGLEVEL $SNIPS_ASR_GOOGLE_ARGS $SNIPS_MQTT_FLAG $SNIPS_ASR_GOOGLE_MQTT_ARGS 212 | cat <> $SUPERVISORD_CONF_FILE 213 | 214 | [program:snips-asr-google] 215 | command=/usr/bin/snips-asr-google $LOGLEVEL $SNIPS_ASR_GOOGLE_ARGS $SNIPS_MQTT_FLAG $SNIPS_ASR_GOOGLE_MQTT_ARGS 216 | autorestart=true 217 | directory=/root 218 | environment=RUMQTT_READ_TIMEOUT_MS="50" 219 | stderr_logfile=/dev/fd/1 220 | stderr_logfile_maxbytes=0 221 | stdout_logfile=/dev/fd/1 222 | stdout_logfile_maxbytes=0 223 | EOT 224 | else 225 | echo "snips-asr-google is disabled" 226 | fi 227 | 228 | 229 | # Generate snips-asr 230 | if [ "${SNIPS_COMPONENTS['snips-asr']}" = true ] 231 | then 232 | echo Spawning /usr/bin/snips-asr $LOGLEVEL $SNIPS_ASR_ARGS $SNIPS_MQTT_FLAG $SNIPS_ASR_MQTT_ARGS 233 | cat <> $SUPERVISORD_CONF_FILE 234 | 235 | [program:snips-asr] 236 | command=/usr/bin/snips-asr $LOGLEVEL $SNIPS_ASR_ARGS $SNIPS_MQTT_FLAG $SNIPS_ASR_MQTT_ARGS 237 | autorestart=true 238 | directory=/root 239 | environment=RUMQTT_READ_TIMEOUT_MS="50" 240 | stderr_logfile=/dev/fd/1 241 | stderr_logfile_maxbytes=0 242 | stdout_logfile=/dev/fd/1 243 | stdout_logfile_maxbytes=0 244 | EOT 245 | else 246 | echo "snips-asr is disabled" 247 | fi 248 | 249 | 250 | # Generate snips-audio-server 251 | if [ "${SNIPS_COMPONENTS['snips-audio-server']}" = true ] 252 | then 253 | echo Spawning /usr/bin/snips-audio-server $LOGLEVEL $SNIPS_AUDIO_SERVER_ARGS $SNIPS_MQTT_FLAG $SNIPS_AUDIO_SERVER_MQTT_ARGS 254 | cat <> $SUPERVISORD_CONF_FILE 255 | 256 | [program:snips-audio-server] 257 | command=/usr/bin/snips-audio-server $LOGLEVEL $SNIPS_AUDIO_SERVER_ARGS $SNIPS_MQTT_FLAG $SNIPS_AUDIO_SERVER_MQTT_ARGS 258 | autorestart=true 259 | directory=/root 260 | user=root 261 | environment=RUMQTT_READ_TIMEOUT_MS="50",HOME="/root" 262 | stderr_logfile=/dev/fd/1 263 | stderr_logfile_maxbytes=0 264 | stdout_logfile=/dev/fd/1 265 | stdout_logfile_maxbytes=0 266 | EOT 267 | else 268 | echo "snips-audio-server is disabled" 269 | fi 270 | 271 | 272 | # Generate snips-tts 273 | if [ "${SNIPS_COMPONENTS['snips-tts']}" = true ] 274 | then 275 | echo Spawning /usr/bin/snips-tts $LOGLEVEL $SNIPS_TTS_ARGS $SNIPS_MQTT_FLAG $SNIPS_TTS_MQTT_FLAG 276 | cat <> $SUPERVISORD_CONF_FILE 277 | [program:snips-tts] 278 | command=/usr/bin/snips-tts $LOGLEVEL $SNIPS_TTS_ARGS $SNIPS_MQTT_FLAG $SNIPS_TTS_MQTT_FLAG 279 | autorestart=true 280 | directory=/root 281 | environment=RUMQTT_READ_TIMEOUT_MS="50" 282 | stderr_logfile=/dev/fd/1 283 | stderr_logfile_maxbytes=0 284 | stdout_logfile=/dev/fd/1 285 | stdout_logfile_maxbytes=0 286 | EOT 287 | else 288 | echo "snips-tts is disabled" 289 | fi 290 | 291 | 292 | # Generate snips-hotword 293 | if [ "${SNIPS_COMPONENTS['snips-hotword']}" = true ] 294 | then 295 | echo Spawning /usr/bin/snips-hotword $SNIPS_HOTWORD_ARGS $LOGLEVEL $SNIPS_MQTT_FLAG $SNIPS_HOTWORD_MQTT_ARGS 296 | cat <> $SUPERVISORD_CONF_FILE 297 | [program:snips-hotword] 298 | command=/usr/bin/snips-hotword $SNIPS_HOTWORD_ARGS $LOGLEVEL $SNIPS_MQTT_FLAG $SNIPS_HOTWORD_MQTT_ARGS 299 | autorestart=true 300 | directory=/root 301 | environment=RUMQTT_READ_TIMEOUT_MS="50" 302 | stderr_logfile=/dev/fd/1 303 | stderr_logfile_maxbytes=0 304 | stdout_logfile=/dev/fd/1 305 | stdout_logfile_maxbytes=0 306 | EOT 307 | else 308 | echo "snips-hotword is disabled" 309 | fi 310 | 311 | 312 | # Generate snips-nlu 313 | if [ "${SNIPS_COMPONENTS['snips-nlu']}" = true ] 314 | then 315 | echo Spawning /usr/bin/snips-nlu $LOGLEVEL $SNIPS_MQTT_FLAG $SNIPS_QUERIES_MQTT_ARGS 316 | cat <> $SUPERVISORD_CONF_FILE 317 | [program:snips-nlu] 318 | command=/usr/bin/snips-nlu $LOGLEVEL $SNIPS_MQTT_FLAG $SNIPS_QUERIES_MQTT_ARGS 319 | autorestart=true 320 | directory=/root 321 | environment=RUMQTT_READ_TIMEOUT_MS="50" 322 | stderr_logfile=/dev/fd/1 323 | stderr_logfile_maxbytes=0 324 | stdout_logfile=/dev/fd/1 325 | stdout_logfile_maxbytes=0 326 | EOT 327 | else 328 | echo "snips-nlu is disabled" 329 | fi 330 | 331 | 332 | # Generate snips-dialogue 333 | if [ "${SNIPS_COMPONENTS['snips-dialogue']}" = true ] 334 | then 335 | echo Spawning /usr/bin/snips-dialogue $LOGLEVEL $SNIPS_DIALOGUE_ARGS $SNIPS_MQTT_FLAG $SNIPS_DIALOGUE_MQTT_ARGS 336 | cat <> $SUPERVISORD_CONF_FILE 337 | [program:snips-dialogue] 338 | command=/usr/bin/snips-dialogue $LOGLEVEL $SNIPS_DIALOGUE_ARGS $SNIPS_MQTT_FLAG $SNIPS_DIALOGUE_MQTT_ARGS 339 | autorestart=true 340 | directory=/root 341 | environment=RUMQTT_READ_TIMEOUT_MS="50" 342 | stderr_logfile=/dev/fd/1 343 | stderr_logfile_maxbytes=0 344 | stdout_logfile=/dev/fd/1 345 | stdout_logfile_maxbytes=0 346 | EOT 347 | else 348 | echo "snips-dialogue is disabled" 349 | fi 350 | 351 | 352 | # Generate snips-debug 353 | if [ "${SNIPS_COMPONENTS['snips-debug']}" = true ] 354 | then 355 | echo Spawning snips-debug 356 | cat <> $SUPERVISORD_CONF_FILE 357 | [program:snips-debug] 358 | command=mosquitto_sub -v $SNIPS_MOSQUITTO_FLAG -t "hermes/#" -T "hermes/audioServer/+/audioFrame" 359 | autorestart=true 360 | directory=/root 361 | stderr_logfile=/dev/fd/1 362 | stderr_logfile_maxbytes=0 363 | stdout_logfile=/dev/fd/1 364 | stdout_logfile_maxbytes=0 365 | EOT 366 | else 367 | echo "snips-debug is disabled" 368 | fi 369 | 370 | 371 | if [ "${USE_INTERNAL_MQTT}" = true ] 372 | then 373 | service mosquitto start 374 | sleep 2 375 | fi 376 | 377 | export RUMQTT_READ_TIMEOUT_MS=50 378 | 379 | #service supervisor start & 380 | #snips-audio-server $LOGLEVEL $SNIPS_AUDIO_SERVER_ARGS $SNIPS_MQTT_FLAG $SNIPS_AUDIO_SERVER_MQTT_ARGS 381 | /usr/bin/supervisord -c $SUPERVISORD_CONF_FILE 382 | --------------------------------------------------------------------------------