Skip to content

Commit ca4061a

Browse files
authored
Merge pull request #55 from Kitt-AI/devel
v1.1.0
2 parents 2a03ff1 + b1e3ddd commit ca4061a

27 files changed

+786
-14
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ snowboydetect.py
1616
/swig/Android/java/
1717
/swig/Android/jniLibs/
1818

19+
/build
20+
/node_modules
21+
/lib/node/binding
22+
/lib/node/index.js

.npmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/lib/libsnowboy-detect.a
2+
snowboy-detect-swig.cc
3+
snowboydetect.py
4+
.DS_Store
5+
6+
*.pyc
7+
*.o
8+
*.so
9+
10+
/examples/C++/*
11+
/examples/Python/*
12+
13+
/swig/Android/*
14+
/swig/Python/*
15+
16+
/build
17+
/node_modules
18+
19+
/lib/node/*.ts
20+
/lib/node/*.d.ts
21+
22+
.npmignore
23+
.travis.yml

.travis.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
language: cpp
2+
3+
# Cache node dependencies
4+
cache:
5+
directories:
6+
- node_modules
7+
8+
# Ubuntu 14.04 Trusty support
9+
sudo: required
10+
dist: trusty
11+
12+
addons:
13+
apt:
14+
sources:
15+
# add PPAs with more up-to-date toolchains
16+
- ubuntu-toolchain-r-test
17+
- llvm-toolchain-precise-3.9
18+
packages:
19+
# install toolchains
20+
- libmagic-dev
21+
- libatlas-base-dev
22+
- gcc-5
23+
- g++-5
24+
- clang-3.8
25+
26+
os:
27+
- linux
28+
- osx
29+
30+
env:
31+
global:
32+
- secure: Hpft/SbwPrjQbHq+3DeJ8aMCpg2uW4z9MY4XaPPA5FQ80QkUdFMqALRvdBhXf/hm6bEZVLbIMXxqCImL5C4nx1SMUmsL6w/FbJjnamYEopk2MKCPZHKtZOdxsbdUwpL30WRH85DQ0KbcG9LatEr+qLwf9adRQrozhh5zhoRXzju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EFGMTRWkYTdV+0ZVeqEQjEPo4fRNJ6PT1Tem8VqIoHEKGivGkwiAZ6FhQ/TNkVD7tv5Vhq7eK3ZPXDRakuBsLJ5Nc9QnLCpoEqbuIYqjr8ODKV2HSjS16VaGPbvtYPWzhGKU9C4=
34+
matrix:
35+
- NODE_VERSION="4.0.0"
36+
- NODE_VERSION="5.0.0"
37+
- NODE_VERSION="6.0.0"
38+
39+
before_install:
40+
# use the correct version of node
41+
- rm -rf ~/.nvm/ && git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm
42+
- source ~/.nvm/nvm.sh
43+
- nvm install $NODE_VERSION
44+
- nvm use $NODE_VERSION
45+
# get commit message
46+
- COMMIT_MESSAGE=$(git show -s --format=%B $TRAVIS_COMMIT | tr -d '\n')
47+
# put local node-pre-gyp on PATH
48+
- export PATH=./node_modules/.bin/:$PATH
49+
# put global node-gyp on PATH
50+
- npm install node-gyp -g
51+
# install aws-sdk so it is available for publishing
52+
- npm install aws-sdk
53+
# figure out if we should publish or republish
54+
- PUBLISH_BINARY=false
55+
- REPUBLISH_BINARY=false
56+
# if we are building a tag then publish
57+
- if [[ $TRAVIS_BRANCH == `git describe --tags --always HEAD` ]]; then PUBLISH_BINARY=true; fi;
58+
# or if we put [publish binary] in the commit message
59+
- if test "${COMMIT_MESSAGE#*'[publish binary]'}" != "$COMMIT_MESSAGE"; then PUBLISH_BINARY=true; fi;
60+
# alternativly we can [republish binary] which will replace any existing binary
61+
- if test "${COMMIT_MESSAGE#*'[republish binary]'}" != "$COMMIT_MESSAGE"; then PUBLISH_BINARY=true && REPUBLISH_BINARY=true; fi;
62+
install:
63+
# ensure source install works
64+
- npm install --build-from-source
65+
# test our module
66+
- node lib/node/index.js
67+
68+
before_script:
69+
# if publishing, do it
70+
- if [[ $REPUBLISH_BINARY == true ]]; then node-pre-gyp package unpublish; fi;
71+
- if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp package publish; fi;
72+
# cleanup
73+
- node-pre-gyp clean
74+
- node-gyp clean
75+
76+
script:
77+
# if publishing, test installing from remote
78+
- INSTALL_RESULT=0
79+
- if [[ $PUBLISH_BINARY == true ]]; then INSTALL_RESULT=$(npm install --fallback-to-build=false > /dev/null)$? || true; fi;
80+
# if install returned non zero (errored) then we first unpublish and then call false so travis will bail at this line
81+
- if [[ $INSTALL_RESULT != 0 ]]; then echo "returned $INSTALL_RESULT";node-pre-gyp unpublish;false; fi
82+
# If success then we arrive here so lets clean up
83+
- node-pre-gyp clean
84+
85+
after_success:
86+
# if success then query and display all published binaries
87+
- node-pre-gyp info

README.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ by [KITT.AI](http://kitt.ai).
1010

1111
(The discussion group is new since September 2016 as we are getting many messages every day. Please send general questions there. For bugs, use Github issues.)
1212

13-
Version: 1.0.4 (7/13/2016)
13+
Version: 1.1.0 (9/20/2016)
1414

1515
Snowboy is a customizable hotword detection engine for you to create your own
1616
hotword like "OK Google" or "Alexa". It is powered by deep neural networks and
@@ -42,12 +42,24 @@ pull request!
4242
If you want support on other hardware/OS, please send your request to
4343
[[email protected]](mailto:snowboy.kitt.ai)
4444

45+
## Precompiled node module
46+
47+
Snowboy is available in the form of a native node module precompiled for:
48+
64 bit Ubuntu, MacOS X, and the Raspberry Pi (Raspbian 8.0+). For quick
49+
installation run:
50+
51+
npm install --save snowboy
52+
53+
For sample usage see the `examples/Node` folder. You may have to install
54+
dependencies like `fs`, `wav` or `node-record-lpcm16` depending on which script
55+
you use.
56+
4557
## Precompiled Binaries with Python Demo
46-
* 64 bit Ubuntu [12.04](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/ubuntu1204-x86_64-1.0.4.tar.bz2)
47-
/ [14.04](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/ubuntu1404-x86_64-1.0.4.tar.bz2)
48-
* [MacOS X](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/osx-x86_64-1.0.4.tar.bz2)
58+
* 64 bit Ubuntu [12.04](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/ubuntu1204-x86_64-1.1.0.tar.bz2)
59+
/ [14.04](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/ubuntu1404-x86_64-1.1.0.tar.bz2)
60+
* [MacOS X](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/osx-x86_64-1.1.0.tar.bz2)
4961
* Raspberry Pi with Raspbian 8.0, all versions
50-
([1/2/3/Zero](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/rpi-arm-raspbian-8.0-1.0.4.tar.bz2))
62+
([1/2/3/Zero](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/rpi-arm-raspbian-8.0-1.1.0.tar.bz2))
5163

5264
If you want to compile a version against your own environment/language, read on.
5365

@@ -85,6 +97,15 @@ Make sure that you can record audio with your microphone:
8597
8698
If you need extra setup on your audio (especially on a Raspberry Pi), please see the [full documentation](http://docs.kitt.ai/snowboy).
8799

100+
## Compile a Node addon
101+
Compiling a node addon for Linux and the Raspberry Pi requires the installation of the following dependencies:
102+
103+
sudo apt-get install libmagic-dev libatlas-base-dev
104+
105+
Then to compile the addon run the following from the root of the snowboy repository:
106+
107+
node-pre-gyp clean configure build
108+
88109
## Compile a Python Wrapper
89110

90111
cd swig/Python
@@ -172,6 +193,13 @@ See [Full Documentation](http://docs.kitt.ai/snowboy).
172193

173194
## Change Log
174195

196+
**v1.1.0, 9/20/2016**
197+
198+
* Added library for Node.
199+
* Added support for Python3.
200+
* Added universal model `alexa.umdl`
201+
* Updated universal model `snowboy.umdl` so that it works in noisy environment.
202+
175203
**v1.0.4, 7/13/2016**
176204

177205
* Updated universal `snowboy.umdl` model to make it more robust.

binding.gyp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
'targets': [{
3+
'target_name': 'snowboy',
4+
'sources': [
5+
'swig/Node/snowboy.cc'
6+
],
7+
'conditions': [
8+
['OS=="mac"', {
9+
'link_settings': {
10+
'libraries': [
11+
'<(module_root_dir)/lib/osx/libsnowboy-detect.a',
12+
]
13+
}
14+
}],
15+
['OS=="linux" and target_arch=="x64"', {
16+
'link_settings': {
17+
'libraries': [
18+
'<(module_root_dir)/lib/ubuntu64/libsnowboy-detect.a',
19+
]
20+
}
21+
}],
22+
['OS=="linux" and target_arch=="arm"', {
23+
'link_settings': {
24+
'libraries': [
25+
'<(module_root_dir)/lib/rpi/libsnowboy-detect.a',
26+
]
27+
}
28+
}]
29+
],
30+
'cflags': [
31+
'-std=c++11',
32+
'-fexceptions',
33+
'-Wall',
34+
'-D_GLIBCXX_USE_CXX11_ABI=0'
35+
],
36+
'cflags!': [
37+
'-fno-exceptions'
38+
],
39+
'cflags_cc!': [
40+
'-fno-exceptions'
41+
],
42+
'include_dirs': [
43+
"<!(node -e \"require('nan')\")",
44+
"<!(pwd)/include"
45+
],
46+
'libraries': [
47+
'-lcblas'
48+
],
49+
'xcode_settings': {
50+
'MACOSX_DEPLOYMENT_TARGET': '10.11',
51+
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
52+
'OTHER_CFLAGS': [
53+
'-std=c++11',
54+
'-stdlib=libc++'
55+
]
56+
}
57+
},
58+
{
59+
"target_name": "action_after_build",
60+
"type": "none",
61+
"dependencies": [ "<(module_name)" ],
62+
"copies": [
63+
{
64+
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
65+
"destination": "<(module_path)"
66+
}
67+
]
68+
}]
69+
}

examples/Node/file.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const fs = require('fs');
2+
const wav = require('wav');
3+
const {Detector, Models} = require('../../');
4+
5+
const models = new Models();
6+
7+
models.add({
8+
file: 'resources/snowboy.umdl',
9+
sensitivity: '0.5',
10+
hotwords : 'snowboy'
11+
});
12+
13+
const detector = new Detector({
14+
resource: "resources/common.res",
15+
models: models,
16+
audioGain: 1.0
17+
});
18+
19+
detector.on('silence', function () {
20+
console.log('silence');
21+
});
22+
23+
detector.on('sound', function () {
24+
console.log('sound');
25+
});
26+
27+
detector.on('error', function () {
28+
console.log('error');
29+
});
30+
31+
detector.on('hotword', function (index, hotword) {
32+
console.log('hotword', index, hotword);
33+
});
34+
35+
const file = fs.createReadStream('resources/snowboy.wav');
36+
const reader = new wav.Reader();
37+
38+
file.pipe(reader).pipe(detector);

examples/Node/microphone.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const record = require('node-record-lpcm16');
2+
const {Detector, Models} = require('../../');
3+
4+
const models = new Models();
5+
6+
models.add({
7+
file: 'resources/snowboy.umdl',
8+
sensitivity: '0.5',
9+
hotwords : 'snowboy'
10+
});
11+
12+
const detector = new Detector({
13+
resource: "resources/common.res",
14+
models: models,
15+
audioGain: 2.0
16+
});
17+
18+
detector.on('silence', function () {
19+
console.log('silence');
20+
});
21+
22+
detector.on('sound', function () {
23+
console.log('sound');
24+
});
25+
26+
detector.on('error', function () {
27+
console.log('error');
28+
});
29+
30+
detector.on('hotword', function (index, hotword) {
31+
console.log('hotword', index, hotword);
32+
});
33+
34+
const mic = record.start({
35+
threshold: 0,
36+
verbose: true
37+
});
38+
39+
mic.pipe(detector);

examples/Node/resources

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../resources/

examples/Python/snowboydecoder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def extend(self, data):
2929

3030
def get(self):
3131
"""Retrieves data from the beginning of buffer and clears it"""
32-
tmp = ''.join(self._buf)
32+
tmp = bytes(bytearray(self._buf))
3333
self._buf.clear()
3434
return tmp
3535

@@ -88,7 +88,7 @@ def audio_callback(in_data, frame_count, time_info, status):
8888
model_str = ",".join(decoder_model)
8989

9090
self.detector = snowboydetect.SnowboyDetect(
91-
resource_filename=resource, model_str=model_str)
91+
resource_filename=resource.encode(), model_str=model_str.encode())
9292
self.detector.SetAudioGain(audio_gain)
9393
self.num_hotwords = self.detector.NumHotwords()
9494

@@ -100,7 +100,7 @@ def audio_callback(in_data, frame_count, time_info, status):
100100
"(%d) does not match" % (self.num_hotwords, len(sensitivity))
101101
sensitivity_str = ",".join([str(t) for t in sensitivity])
102102
if len(sensitivity) != 0:
103-
self.detector.SetSensitivity(sensitivity_str);
103+
self.detector.SetSensitivity(sensitivity_str.encode())
104104

105105
self.ring_buffer = RingBuffer(
106106
self.detector.NumChannels() * self.detector.SampleRate() * 5)
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)