Skip to content

Commit 20be762

Browse files
authored
Merge pull request #143 from MycroftAI/feature/snap
Add snap packaging recipe
2 parents 88dc92e + dd0fff5 commit 20be762

File tree

2 files changed

+200
-0
lines changed

2 files changed

+200
-0
lines changed

SNAPCRAFT.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Mycroft-Precise Snap package
2+
3+
## Package details
4+
The package is a fairly standard configuration using the Snap [Python Plugin](https://snapcraft.io/docs/python-plugin).
5+
6+
The package version is extracted from the `setup.py` script to remain consistent with the pip information. In addition a comparison with the repo is made to see if this commit matches the latest release commit. If it doesn't match _-dev_ is appended to the version info.
7+
8+
Since Precise uses pyaudio, ALSA is required for the audio to work. This Snap uses the [alsa-mixin](https://snapcraft-alsa.readthedocs.io/en/latest/snapcraft_usage.html) to setup the ALSA components. This results in some minor issues that need to be handled. Library conflicts may occur if audio packages are included as part of the main application part, making them appear twice in conflicting versions. This is the reason that libportaudio2 and pulseaudio are in the stage-packages for the alsa-mixin part.
9+
10+
This package also includes the current pretrained "hey mycroft" model accessed through `/snap/mycroft-precise/current/hey-mycroft/hey-mycroft.pb`.
11+
12+
## Plugs
13+
Plugs allow the Snap to connect to specific aspects of the host system. Without any specified plugs the application will run entirely within a read-only file system dedicated to the application. It will not be able to access the system, including audio devices, that are outside of the Snap container.
14+
15+
**Plugs used:**
16+
- home: access to the user's home directory (excluding hidden files)
17+
- audio-record: Access to the system's audio input devices
18+
- audio-playback: Access to the system's audio output devices

snap/snapcraft.yaml

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: mycroft-precise
2+
adopt-info: mycroft-precise
3+
license: Apache-2.0
4+
summary: A wake word listener from Mycroft AI
5+
description: >
6+
A lightweight, simple-to-use, RNN wake word listener, including all the tools to train your own custom wake word.
7+
8+
Mycroft Precise monitors an audio stream (usually a microphone) and when it recognizes a specific phrase it triggers an event. For example, by default users of the Mycroft Voice Assistant are using a Precise model trained to spot the phrase "Hey Mycroft". When Precise recognizes this phrase it puts the Mycroft Voice Assistant into command mode performing speech recognition on whatever is next said by the person using the device.
9+
10+
Mycroft Precise is fully open source and can be trained to recognize any short-phrase or sound, from a name to a cough.
11+
12+
The default "Hey Mycroft" model is included, to test it, try:
13+
`mycroft-precise.listen /snap/mycroft-precise/current/hey-mycroft/hey-mycroft.pb`
14+
15+
16+
**USAGE**
17+
18+
19+
Running the listener
20+
21+
mycroft-precise - Alias for mycroft-precise.engine
22+
mycroft-precise.engine - Run a model on raw audio data from stdin
23+
mycroft-precise.listen - Run a model on microphone audio input
24+
mycroft-precise.listen-pocketsphinx - Run the PocketSphinx listener
25+
26+
Data collection
27+
28+
mycroft-precise.collect - Record audio samples for use with Precise
29+
mycroft-precise.add-noise - Create a duplicate dataset with added noise
30+
31+
Training
32+
33+
mycroft-precise.train - Train a new model on a dataset
34+
mycroft-precise.train-generated - Train a model on infinitely generated batches
35+
mycroft-precise.train-incremental - Train a model to inhibit activation by marking false activations and retraining
36+
mycroft-precise.train-optimize - Use black box optimization to tune model hyperparameters
37+
mycroft-precise.train-sampled - Train a model, sampling data points with the highest loss from a larger dataset
38+
39+
Evaluation and analysis
40+
41+
mycroft-precise.test - Test a model against a dataset
42+
mycroft-precise.test-pocketsphinx - Test PocketSphinx against a dataset
43+
mycroft-precise.eval - Evaluate a list of models on a dataset
44+
mycroft-precise.calc-threshold - Update the threshold values of a model for a dataset to make the sensitivity more accurate and linear
45+
mycroft-precise.graph - Show ROC curves for a series of models
46+
mycroft-precise.simulate - Simulate listening to long chunks of audio to find unbiased false positive metrics
47+
48+
Model conversion
49+
50+
mycroft-precise.convert - Convert wake-word model from Keras to TensorFlow
51+
base: core18
52+
grade: stable
53+
confinement: strict
54+
build-packages: [python3-dev, python3-setuptools, libtool, libffi-dev, libssl-dev, autoconf, build-essential]
55+
parts:
56+
alsa-mixin:
57+
build-packages:
58+
- libasound2-dev
59+
plugin: dump
60+
source: https://github.com/diddlesnaps/snapcraft-alsa.git
61+
source-subdir: snapcraft-assets
62+
stage-packages:
63+
- libslang2
64+
- libasound2
65+
- libasound2-plugins
66+
- libportaudio2
67+
- pulseaudio
68+
- alsa-utils
69+
mycroft-precise:
70+
after: [alsa-mixin]
71+
plugin: python
72+
python-version: python3
73+
source: https://github.com/MycroftAI/mycroft-precise.git
74+
source-type: git
75+
source-branch: dev
76+
override-pull: |
77+
snapcraftctl pull
78+
# Set version to setup.py version if current commit is the latest
79+
# tag, otherwise append "-dev" to the version string.
80+
set +e
81+
if [[ git describe --exact-match --tags $(git log -n1 --pretty='%h') ]]
82+
then
83+
VERSION=$(/usr/bin/python3 setup.py --version)
84+
else
85+
VERSION="$(/usr/bin/python3 setup.py --version)-dev"
86+
fi
87+
set -e
88+
snapcraftctl set-version $VERSION
89+
build-packages:
90+
- python-setuptools
91+
- python3-pip
92+
- curl
93+
- libopenblas-dev
94+
- python3-scipy
95+
- cython
96+
- libhdf5-dev
97+
- python3-h5py
98+
- portaudio19-dev
99+
- swig
100+
- libatlas-base-dev
101+
stage-packages:
102+
- libopenblas-base
103+
- python3
104+
- python3-scipy
105+
- cython
106+
- libhdf5-100
107+
- libhdf5-cpp-100
108+
- python3-h5py
109+
- swig
110+
- libatlas3-base
111+
hey-mycroft:
112+
plugin: dump
113+
source: https://github.com/MycroftAI/precise-data/raw/models/hey-mycroft.tar.gz
114+
source-type: tar
115+
organize:
116+
'*': /hey-mycroft/
117+
118+
layout:
119+
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib:
120+
bind: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/alsa-lib
121+
122+
apps:
123+
mycroft-precise:
124+
plugs: [home]
125+
command: bin/precise-engine
126+
add-noise:
127+
plugs: [home]
128+
command: bin/precise-add-noise
129+
calc-threshold:
130+
plugs: [home]
131+
command: bin/precise-calc-threshold
132+
collect:
133+
plugs: [home, audio-record, audio-playback]
134+
command-chain:
135+
- snap/command-chain/alsa-launch
136+
command: bin/precise-collect
137+
convert:
138+
plugs: [home]
139+
command: bin/precise-convert
140+
eval:
141+
plugs: [home]
142+
command: bin/precise-eval
143+
engine:
144+
plugs: [home]
145+
command: bin/precise-engine
146+
graph:
147+
plugs: [home]
148+
command: bin/precise-graph
149+
listen:
150+
command-chain:
151+
- snap/command-chain/alsa-launch
152+
plugs: [home, audio-record, audio-playback]
153+
command: bin/precise-listen
154+
listen-pocketsphinx:
155+
command-chain:
156+
- snap/command-chain/alsa-launch
157+
plugs: [home, audio-record, audio-playback]
158+
command: bin/precise-listen-pocketsphinx
159+
simulate:
160+
plugs: [home]
161+
command: bin/precise-simulate
162+
test:
163+
plugs: [home]
164+
command: bin/precise-test
165+
test-pocketsphinx:
166+
plugs: [home]
167+
command: bin/precise-test-pocketsphinx
168+
train:
169+
plugs: [home]
170+
command: bin/precise-train
171+
train-generated:
172+
plugs: [home]
173+
command: bin/precise-train-generated
174+
train-incremental:
175+
plugs: [home]
176+
command: bin/precise-train-incremental
177+
train-optimize:
178+
plugs: [home]
179+
command: bin/precise-train-optimize
180+
train-sampled:
181+
plugs: [home]
182+
command: bin/precise-train-sampled

0 commit comments

Comments
 (0)