Code Monkey home page Code Monkey logo

snowboy's Introduction

Dear KITT.AI users,

We are writing this update to let you know that we plan to shut down all KITT.AI products (Snowboy, NLU and Chatflow) by Dec. 31st, 2020.

we launched our first product Snowboy in 2016, and then NLU and Chatflow later that year. Since then, we have served more than 85,000 developers, worldwide, accross all our products. It has been 4 extraordinary years in our life, and we appreciate the opportunity to be able to serve the community.

The field of artificial intelligence is moving rapidly. As much as we like our products, we still see that they are getting outdated and are becoming difficult to maintain. All official websites/APIs for our products will be taken down by Dec. 31st, 2020. Our github repositories will remain open, but only community support will be available from this point beyond.

Thank you all, and goodbye!

The KITT.AI Team
Mar. 18th, 2020

Snowboy Hotword Detection

by KITT.AI.

Home Page

Full Documentation and FAQ

Discussion Group (or send email to [email protected])

Commercial application FAQ

Version: 1.3.0 (2/19/2018)

Alexa support

Snowboy now brings hands-free experience to the Alexa AVS sample app on Raspberry Pi! See more info below regarding the performance and how you can use other hotword models. The following instructions currently support AVS sdk Version 1.12.1.

Performance

The performance of hotword detection usually depends on the actual environment, e.g., is it used with a quality microphone, is it used on the street, in a kitchen, or is there any background noise, etc. So we feel it is best for the users to evaluate it in their real environment. For the evaluation purpose, we have prepared an Android app which can be installed and run out of box: SnowboyAlexaDemo.apk (please uninstall any previous versions first if you have installed this app before).

Kittai KWD Engine

  • Set up Alexa AVS sample app following the official AVS instructions

  • Apply patch to replace the Sensory KWD engine with Kittai engine

# Copy the patch file to the root directory of Alexa AVS sample app. Please replace $ALEXA_AVS_SAMPLE_APP_PATH with the actual path where you
# cloned the Alexa AVS sample app repository, and replace $SNOWBOY_ROOT_PATH with the actual path where you clone the Snowboy repository
cd $ALEXA_AVS_SAMPLE_APP_PATH
cp $SNOWBOY_PATH/resource/alexa/alexa-avs-sample-app/avs-kittai.patch ./

# Apply the patch, this will modify the scripts setup.sh and pi.sh
patch < avs-kittai.patch
  • Re-compile the avs-device-sdk and sample app
sudo bash setup.sh config.json
  • Run the sample app
sudo bash startsample.sh

Here is a demo video for how to use Snowboy hotword engine in Alexa Voice Service.

Personal model

# Please put YOUR_PERSONAL_MODEL.pmdl in $ALEXA_AVS_SAMPLE_APP_PATH/third-party/snowboy/resources,
# and $ALEXA_AVS_SAMPLE_APP_PATH with the actual path where you put the Alexa AVS sample app repository.

cp YOUR_PERSONAL_MODEL.pmdl $ALEXA_AVS_SAMPLE_APP_PATH/third-party/snowboy/resources/

  • Replace the model name 'alexa.umdl' with your personal model name, update KITT_AI_SENSITIVITY, set KITT_AI_APPLY_FRONT_END_PROCESSING to false in the Alexa AVS sample app code and re-compile
# Modify $ALEXA_AVS_SAMPLE_APP_PATH/avs-device-sdk/blob/master/KWD/KWDProvider/src/KeywordDetectorProvider.cpp:
#     Replace the model name 'alexa.umdl' with your personal model name 'YOUR_PERSONAL_MODEL.pmdl' at line 52
#     Update `KITT_AI_SENSITIVITY` at line 26
#     Set `KITT_AI_APPLY_FRONT_END_PROCESSING` to `false` at line 32
sudo bash setup.sh config.json
  • Run the wake word agent with engine set to kitt_ai!

Here is a demo video for how to use a personal model in Alexa Voice Service.

Universal model

# Please put YOUR_UNIVERSAL_MODEL.umdl in $ALEXA_AVS_SAMPLE_APP_PATH/third-party/snowboy/resources,
# and $ALEXA_AVS_SAMPLE_APP_PATH with the actual path where you put the Alexa AVS sample app repository.

cp YOUR_UNIVERSAL_MODEL.umdl $ALEXA_AVS_SAMPLE_APP_PATH/third-party/snowboy/resources/

  • Replace the model name 'alexa.umdl' with your universal model name, update KITT_AI_SENSITIVITY in the Alexa AVS sample app code and re-compile
# Modify $ALEXA_AVS_SAMPLE_APP_PATH/avs-device-sdk/blob/master/KWD/KWDProvider/src/KeywordDetectorProvider.cpp:
#     Replace the model name 'alexa.umdl' with your universal model name 'YOUR_UNIVERSAL_MODEL.umdl' at line 52
#     Update `KITT_AI_SENSITIVITY` at line 26
sudo bash setup.sh config.json
  • Run the wake word agent with engine set to kitt_ai!

Hotword as a Service

Snowboy now offers Hotword as a Service through the https://snowboy.kitt.ai/api/v1/train/ endpoint. Check out the Full Documentation and example Python/Bash script (other language contributions are very welcome).

As a quick start, POST to https://snowboy.kitt.ai/api/v1/train:

{
    "name": "a word",
    "language": "en",
    "age_group": "10_19",
    "gender": "F",
    "microphone": "mic type",
    "token": "<your auth token>",
    "voice_samples": [
        {wave: "<base64 encoded wave data>"},
        {wave: "<base64 encoded wave data>"},
        {wave: "<base64 encoded wave data>"}
    ]
}

then you'll get a trained personal model in return!

Introduction

Snowboy is a customizable hotword detection engine for you to create your own hotword like "OK Google" or "Alexa". It is powered by deep neural networks and has the following properties:

  • highly customizable: you can freely define your own magic phrase here – let it be “open sesame”, “garage door open”, or “hello dreamhouse”, you name it.

  • always listening but protects your privacy: Snowboy does not use Internet and does not stream your voice to the cloud.

  • light-weight and embedded: it even runs on a Raspberry Pi and consumes less than 10% CPU on the weakest Pi (single-core 700MHz ARMv6).

  • Apache licensed!

Currently Snowboy supports (look into the lib folder):

  • all versions of Raspberry Pi (with Raspbian based on Debian Jessie 8.0)
  • 64bit Mac OS X
  • 64bit Ubuntu 14.04
  • iOS
  • Android
  • ARM64 (aarch64, Ubuntu 16.04)

It ships in the form of a C++ library with language-dependent wrappers generated by SWIG. We welcome wrappers for new languages -- feel free to send a pull request!

Currently we have built wrappers for:

  • C/C++
  • Java/Android
  • Go (thanks to @brentnd and @deadprogram)
  • Node (thanks to @evancohen and @nekuz0r)
  • Perl (thanks to @iboguslavsky)
  • Python2/Python3
  • iOS/Swift3 (thanks to @grimlockrocks)
  • iOS/Object-C (thanks to @patrickjquinn)

If you want support on other hardware/OS, please send your request to [email protected]

Note: Snowboy does not support Windows yet. Please build Snowboy on *nix platforms.

Pricing for Snowboy models

Hackers: free

  • Personal use
  • Community support

Business: please contact us at [email protected]

  • Personal use
  • Commercial license
  • Technical support

Pretrained universal models

We provide pretrained universal models for testing purpose. When you test those models, bear in mind that they may not be optimized for your specific device or environment.

Here is the list of the models, and the parameters that you have to use for them:

  • resources/alexa/alexa-avs-sample-app/alexa.umdl: Universal model for the hotword "Alexa" optimized for Alexa AVS sample app. Set SetSensitivity to 0.6, and set ApplyFrontend to true. This is so far the best "Alexa" model we released publicly, when ApplyFrontend is set to true.
  • resources/models/snowboy.umdl: Universal model for the hotword "Snowboy". Set SetSensitivity to 0.5 and ApplyFrontend to false.
  • resources/models/jarvis.umdl: Universal model for the hotword "Jarvis" (https://snowboy.kitt.ai/hotword/29). It has two different models for the hotword Jarvis, so you have to use two sensitivites. Set sensitivities to "0.8,0.80" and ApplyFrontend to true.
  • resources/models/smart_mirror.umdl: Universal model for the hotword "Smart Mirror" (https://snowboy.kitt.ai/hotword/47). Set sensitivity to Sensitivity to 0.5, and ApplyFrontend to false.
  • resources/models/subex.umdl: Universal model for the hotword "Subex" (https://snowboy.kitt.ai/hotword/22014). Set sensitivity to Sensitivity to 0.5, and ApplyFrontend to true.
  • resources/models/neoya.umdl: Universal model for the hotword "Neo ya" (https://snowboy.kitt.ai/hotword/22171). It has two different models for the hotword "Neo ya", so you have to use two sensitivites. Set sensitivities to "0.7,0.7", and ApplyFrontend to true.
  • resources/models/hey_extreme.umdl: Universal model for the hotword "Hey Extreme" (https://snowboy.kitt.ai/hotword/15428). Set sensitivity to Sensitivity to 0.6, and ApplyFrontend to true.
  • resources/models/computer.umdl: Universal model for the hotword "Computer" (https://snowboy.kitt.ai/hotword/46). Set sensitivity to Sensitivity to 0.6, and ApplyFrontend to true.
  • resources/models/view_glass.umdl: Universal model for the hotword "View Glass" (https://snowboy.kitt.ai/hotword/7868). Set Sensitivity to 0.7, and ApplyFrontend to true.

Precompiled node module

Snowboy is available in the form of a native node module precompiled for: 64 bit Ubuntu, MacOS X, and the Raspberry Pi (Raspbian 8.0+). For quick installation run:

npm install --save snowboy

For sample usage see the examples/Node folder. You may have to install dependencies like fs, wav or node-record-lpcm16 depending on which script you use.

Precompiled Binaries with Python Demo

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

Dependencies

To run the demo you will likely need the following, depending on which demo you use and what platform you are working with:

  • SoX (audio conversion)
  • PortAudio or PyAudio (audio capturing)
  • SWIG 3.0.10 or above (compiling Snowboy for different languages/platforms)
  • ATLAS or OpenBLAS (matrix computation)

You can also find the exact commands you need to install the dependencies on Mac OS X, Ubuntu or Raspberry Pi below.

Mac OS X

brew install swig, sox, portaudio and its Python binding pyaudio:

brew install swig portaudio sox
pip install pyaudio

If you don't have Homebrew installed, please download it here. If you don't have pip, you can install it here.

Make sure that you can record audio with your microphone:

rec t.wav

Ubuntu/Raspberry Pi/Pine64/Nvidia Jetson TX1/Nvidia Jetson TX2

First apt-get install sox, portaudio and its Python binding pyaudio:

sudo apt-get install python-pyaudio python3-pyaudio sox
pip install pyaudio

Compile a supported swig version (3.0.10 or above)

wget http://downloads.sourceforge.net/swig/swig-3.0.10.tar.gz
sudo apt-get install libpcre3 libpcre3-dev
./configure --prefix=/usr                  \
        --without-clisp                    \
        --without-maximum-compile-warnings &&
make
make install &&
install -v -m755 -d /usr/share/doc/swig-3.0.10 &&
cp -v -R Doc/* /usr/share/doc/swig-3.0.10

Then install the atlas matrix computing library:

sudo apt-get install libatlas-base-dev

Make sure that you can record audio with your microphone:

rec t.wav

If you need extra setup on your audio (especially on a Raspberry Pi), please see the full documentation.

Compile a Node addon

Compiling a node addon for Linux and the Raspberry Pi requires the installation of the following dependencies:

sudo apt-get install libmagic-dev libatlas-base-dev

Then to compile the addon run the following from the root of the snowboy repository:

npm install
./node_modules/node-pre-gyp/bin/node-pre-gyp clean configure build

Compile a Java Wrapper

# Make sure you have JDK installed.
cd swig/Java
make

SWIG will generate a directory called java which contains converted Java wrappers and a directory called jniLibs which contains the JNI library.

To run the Java example script:

cd examples/Java
make run

Compile a Python Wrapper

cd swig/Python
make

SWIG will generate a _snowboydetect.so file and a simple (but hard-to-read) python wrapper snowboydetect.py. We have provided a higher level python wrapper snowboydecoder.py on top of that.

Feel free to adapt the Makefile in swig/Python to your own system's setting if you cannot make it.

Compile a GO Wrapper

cd examples/Go
go get github.com/Kitt-AI/snowboy/swig/Go
go build -o snowboy main.go
./snowboy ../../resources/snowboy.umdl ../../resources/snowboy.wav

Expected Output:

Snowboy detecting keyword in ../../resources/snowboy.wav
Snowboy detected keyword  1

For more, please read examples/Go/readme.md.

Compile a Perl Wrapper

cd swig/Perl
make

The Perl examples include training personal hotword using the KITT.AI RESTful APIs, adding Google Speech API after the hotword detection, etc. To run the examples, do the following

cd examples/Perl

# Install cpanm, if you don't already have it.
curl -L https://cpanmin.us | perl - --sudo App::cpanminus

# Install the dependencies. Note, on Linux you will have to install the
# PortAudio package first, using e.g.:
# apt-get install portaudio19-dev
sudo cpanm --installdeps .

# Run the unit test.
./snowboy_unit_test.pl

# Run the personal model training example.
./snowboy_RESTful_train.pl <API_TOKEN> <Hotword> <Language>

# Run the Snowboy Google Speech API example. By default it uses the Snowboy
# universal hotword.
./snowboy_googlevoice.pl <Google_API_Key> [Hotword_Model]

Compile an iOS Wrapper

Using Snowboy library in Objective-C does not really require a wrapper. It is basically the same as using C++ library in Objective-C. We have compiled a "fat" static library for iOS devices, see the library here lib/ios/libsnowboy-detect.a.

To initialize Snowboy detector in Objective-C:

snowboy::SnowboyDetect* snowboyDetector = new snowboy::SnowboyDetect(
    std::string([[[NSBundle mainBundle]pathForResource:@"common" ofType:@"res"] UTF8String]),
    std::string([[[NSBundle mainBundle]pathForResource:@"snowboy" ofType:@"umdl"] UTF8String]));
snowboyDetector->SetSensitivity("0.45");        // Sensitivity for each hotword
snowboyDetector->SetAudioGain(2.0);             // Audio gain for detection

To run hotword detection in Objective-C:

int result = snowboyDetector->RunDetection(buffer[0], bufferSize);  // buffer[0] is a float array

You may want to play with the frequency of the calls to RunDetection(), which controls the CPU usage and the detection latency.

Thanks to @patrickjquinn and @grimlockrocks, we now have examples of using Snowboy in both Objective-C and Swift3. Check out the examples at examples/iOS/, and the screenshots below!

Obj-C Example Swift3 Example

Compile an Android Wrapper

Full README and tutorial is in Android README and here's a screenshot:

Android Alexa Demo

We have prepared an Android app which can be installed and run out of box: SnowboyAlexaDemo.apk (please uninstall any previous one first if you installed this app before).

Quick Start for Python Demo

Go to the examples/Python folder and open your python console:

In [1]: import snowboydecoder

In [2]: def detected_callback():
   ....:     print "hotword detected"
   ....:

In [3]: detector = snowboydecoder.HotwordDetector("resources/snowboy.umdl", sensitivity=0.5, audio_gain=1)

In [4]: detector.start(detected_callback)

Then speak "snowboy" to your microphone to see whetheer Snowboy detects you.

The snowboy.umdl file is a "universal" model that detect different people speaking "snowboy". If you want other hotwords, please go to snowboy.kitt.ai to record, train and downloand your own personal model (a .pmdl file).

When sensitiviy is higher, the hotword gets more easily triggered. But you might get more false alarms.

audio_gain controls whether to increase (>1) or decrease (<1) input volume.

Two demo files demo.py and demo2.py are provided to show more usages.

Note: if you see the following error:

TypeError: __init__() got an unexpected keyword argument 'model_str'

You are probably using an old version of SWIG. Please upgrade. We have tested with SWIG version 3.0.7 and 3.0.8.

Advanced Usages & Demos

See Full Documentation.

Change Log

v1.3.0, 2/19/2018

v1.2.0, 3/25/2017

  • Added better Alexa model for Alexa AVS sample app
  • New decoder that works well for short hotwords like Alexa

v1.1.1, 3/24/2017

  • Added Android demo
  • Added iOS demos
  • Added Samsung Artik support
  • Added Go support
  • Added Intel Edison support
  • Added Pine64 support
  • Added Perl Support
  • Added a more robust "Alexa" model (umdl)
  • Offering Hotword as a Service through /api/v1/train endpoint.
  • Decoder is not changed.

v1.1.0, 9/20/2016

  • Added library for Node.
  • Added support for Python3.
  • Added universal model alexa.umdl
  • Updated universal model snowboy.umdl so that it works in noisy environment.

v1.0.4, 7/13/2016

  • Updated universal snowboy.umdl model to make it more robust.
  • Various improvements to speed up the detection.
  • Bug fixes.

v1.0.3, 6/4/2016

  • Updated universal snowboy.umdl model to make it more robust in non-speech environment.
  • Fixed bug when using float as input data.
  • Added library support for Android ARMV7 architecture.
  • Added library for iOS.

v1.0.2, 5/24/2016

  • Updated universal snowboy.umdl model
  • added C++ examples, docs will come in next release.

v1.0.1, 5/16/2016

  • VAD now returns -2 on silence, -1 on error, 0 on voice and >0 on triggered models
  • added static library for Raspberry Pi in case people want to compile themselves instead of using the binary version

v1.0.0, 5/10/2016

  • initial release

snowboy's People

Contributors

13484956461 avatar arilotter avatar billwsy avatar brentnd avatar c4tz avatar carloalbertobarbano avatar chashmeetsingh avatar chenguoguo avatar cuitianxiang001 avatar d4n13lbc avatar deadprogram avatar dolanmiu avatar dseliahu avatar eiselems avatar evancohen avatar gcampax avatar gregfrench avatar gstraymond avatar iboguslavsky avatar jopedroliveira avatar kittdotai avatar leosampaio avatar lucasagranzotto avatar nekuz0r avatar nmctseb avatar patrickjquinn avatar rohantib avatar ryansydnor avatar webworxshop avatar xuchen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

snowboy's Issues

Alsa problems on RaspBerry Pi3

I'm using Raspberry Pi3 with raspbian for implementation.
When running the python demo, comes the error messages as follow:

ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.front.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM front
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround40.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround40
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround41
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround50
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround51
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround71.0:CARD=0'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround71
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM iec958
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdif
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
Listening. . . Press Ctrl + C to exit

I have followed the instructions on https://snowboy.kitt.ai/docs to modify the .asoundrc file. I am not able to figure out the problems here. Is it something about alsa configuration or the port audio settings?

Unable to make on openSUSE

I'm unable to make the python wrapper on my opensuse machine.

Specifically, I run into an error with 3 libraries (f77blas, lapack_atlas, and atlas):

>>> make
g++ -I../../ -O3 -fPIC -std=c++0x -L/usr/lib64/ -shared snowboy-detect-swig.o \
../..//lib/ubuntu64/libsnowboy-detect.a -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -lm -ldl -lf77blas -lcblas -llapack_atlas -latlas -o _snowboydetect.so
/usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: cannot find -lf77blas
/usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: cannot find -llapack_atlas
/usr/lib64/gcc/x86_64-suse-linux/6/../../../../x86_64-suse-linux/bin/ld: cannot find -latlas
collect2: error: ld returned 1 exit status
make: *** [Makefile:51: _snowboydetect.so] Error 1

One thing I did was add '-L/usr/lib64' as an additional flag in the hopes of finding these libraries, and that did work for cblas, but unfortunately that doesn't seem to have worked for the remaining 3.

Does anyone have an idea of what the issue may be? Do I need to compile blas, lapack and atlas on my own!? I would rather not...

pthread_join issue

Hi guys,

I had the snowboy demo working just fine for me but after tinkering around with things I've managed to break it somehow and can't figure out why. This is what I get when I run the demo script with a personal model:

Expression 'paTimedOut' failed in 'src/os/unix/pa_unix_util.c', line: 387 Expression 'PaUnixThread_New( &stream->thread, &CallbackThreadFunc, stream, 1., stream->rtSched )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2998 Expression 'pthread_join( self->thread, &pret )' failed in 'src/os/unix/pa_unix_util.c', line: 441

There's also the usual ALSA and jack server could not be started errors but these were there before too and didn't cause any issues. The quoted error is the new one.

Any help would be appreciated - thanks.

ImportError: No module named _snowboydetect

Hi Guys,

First of all, absolutely love the library, using it for a smart home and it's literally the way I get everything to work. I actually run this on a pi 3 which is the interface to all the cool stuff. However I develop on windows (mounted samba from the pi), but unfortunately, I can't test locally first and I have to keep running on the pi and its a bit of a pain. Is there any likelihood that you guys will get it running on windows?

Really so much love for all you've done though, keep up the great work! :D

Error when running `node microphone.js`: node: symbol lookup error: /home/pi/snowboytest/node_modules/snowboy/lib/node/binding/Release/node-v48-linux-x64/snowboy.node: undefined symbol: cblas_sdot

Ok, so I set up a new Debian x64 box and installed node v6.7.0:

$ node --version
v6.7.0

Then did:

cd
mkdir snowboytest
npm install --save snowboy

Everything installed successfully as far as I could tell. So based on the example, I came up with this code with the appropriate directories changed:

const record = require('node-record-lpcm16');
const snowboy = require( 'snowboy' );
//const {Detector, Models} = require('../../');

const Detector = snowboy.Detector;
const Models   = snowboy.Models;

const models = new Models();

models.add({
  file: './node_modules/snowboy/resources/snowboy.umdl',
  sensitivity: '0.5',
  hotwords : 'snowboy'
});

const detector = new Detector({
  resource: "./node_modules/snowboy/resources/common.res",
  models: models,
  audioGain: 2.0
});

detector.on('silence', function () {
  console.log('silence');
});

detector.on('sound', function () {
  console.log('sound');
});

detector.on('error', function () {
  console.log('error');
});

detector.on('hotword', function (index, hotword) {
  console.log('hotword', index, hotword);
});

const mic = record.start({
  threshold: 0,
  verbose: true
});

mic.pipe(detector);

But when I run it:


pi@alphared-agent-virtual2:~/snowboytest$ 
pi@alphared-agent-virtual2:~/snowboytest$ node microphone.js 
Recording with sample rate 16000...
Recording 12288 bytes
node: symbol lookup error: /home/pi/snowboytest/node_modules/snowboy/lib/node/binding/Release/node-v48-linux-x64/snowboy.node: undefined symbol: cblas_sdot

I'm not sure if it is related or not, but when running the examples directly, I got an error trying to find the file..:

pi@alphared-agent-virtual2:~/snowboy/node_modules$ cd snowboy/examples/Node/
pi@alphared-agent-virtual2:~/snowboy/node_modules/snowboy/examples/Node$ node microphone.js 
/home/pi/snowboy/node_modules/snowboy/lib/node/index.js:27
            throw new Error(`Model ${model.file} does not exists.`);
            ^

Error: Model resources/snowboy.umdl does not exists.
    at HotwordModels.add (/home/pi/snowboy/node_modules/snowboy/lib/node/index.js:27:19)
    at Object.<anonymous> (/home/pi/snowboy/node_modules/snowboy/examples/Node/microphone.js:6:8)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)

unexpected kwargs

when i try to run interactively as suggested, i get this error:

>>> detector = snowboydecoder.HotwordDetector("resources/snowboy.umdl", sensitivity=0.5, audio_gain=1) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "snowboydecoder.py", line 91, in __init__ resource_filename=resource, model_str=model_str) TypeError: __init__() got an unexpected keyword argument 'model_str'

it looks to me like snowboydecoder is sending in kwargs, but snowboydetect expects args?

Better rules to choose the hotword.

Hi, I m using your engine in a C++ project (for the moment it's more C) without problems, but I need to use a trick to reduce false positive.
It's perhaps due to microphone but if a record the word "momomo" I have a trigger when I say "tatata" (even with 0.5 sensitivity).
IDK how work your algorithm, but what can I do to choose a better Hotword. Its better to use long word/short word more vowel/more consonant, simple word+blank+simple word, ...

C support ?

Hi, I have take a look on your project, it s working perfectly, but I have some problem to use it in a C application.
Apparently the library is in C at the start but the header file is only for c++ project (in the include folder).

And I have some problem to convert it, have you a C example too ?

TypeError: __init__() got an unexpected keyword argument 'model_str'

After successfully building from source, I'm running the demo, but ran into this error:

pi@raspberrypi:~/Downloads/snowboy/examples/Python $ python demo.py ./resources/snowboy.umdl 
Traceback (most recent call last):
  File "demo.py", line 27, in <module>
    detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5)
  File "/home/pi/Downloads/snowboy/examples/Python/snowboydecoder.py", line 91, in __init__
    resource_filename=resource, model_str=model_str)
TypeError: __init__() got an unexpected keyword argument 'model_str'

Lines 90s in snowboydecoder.py:

        self.detector = snowboydetect.SnowboyDetect(
            resource_filename=resource, model_str=model_str)        # 91
        self.detector.SetAudioGain(audio_gain)
        self.num_hotwords = self.detector.NumHotwords()

But looking at snowboydetect.py, the constructor takes a pointer, so I'm not sure what it is complaining about. My python skills aren't great.

class SnowboyDetect(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, SnowboyDetect, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, SnowboyDetect, name)
    __repr__ = _swig_repr
    def __init__(self, *args): 
        this = _snowboydetect.new_SnowboyDetect(*args)
        try: self.this.append(this)
        except: self.this = this

GPIO relay On-Off script based on two models.

i need GPIO relay On-Off script based on two models. same as demo2.py but the script should be work as follows.

  1. when model 1 detects it plays ding sound and turn on relay 17.
  2. when model 2 detects it plays dong sound and turn off relay 17.

if anyone can make script like this i would really appreciate. Thanks in Advance..

"module not found" on Electron

Hi!

I'm currently using the python library and spawning a child process for snowboy in Electron to detect my hotwords, and it works pretty well!
I've noticed that you guys recently added the Node library so I wanted to update my code for better flexibility.

While adding the example code

const { Models, Detector } = require("snowboy");

Electron throws an error of

cannot find module /Users/user/node_modules/snowboy/lib/node/binding/Release/electron-v1.4-darwin-x64/snowboy.node'

Any ideas?

Support for other people?

So, the FAQ on this page:

Has this statement:

* My pmdl model works well for me, but does not work well for others
Models with suffix pmdl are personal models, and they are supposed to only work well for the person who provides the audio samples. If you are look for a model that works well for everyone, please use the universal model (with suffix umdl).

Which indicates to me that if I train my pmdl, then my girlfriend won't be able to initiate. I suppose I could pass multiple pmdl files to the snowboydecoder.HotwordDetector and use the same callback for each pmdl. But ideally, I'd be able to have each person generate a pmdl then pass that to the script.

But then, if I have guests over, and I want to use a term different from "snowboy", could I do this? Is there any way through your api to generate an umdl?

Silence Detection

Awesome project guys, I'm the author of the orignal RaspberryPi Alexa project :)

I'm looking at integrating your code into AlexaPi, one thing I need to work out is silence detection, have you got any tips?

The flow would need to go WakeWord>Record Command>DETECT END OF COMMAND>Post to Alexa Voice Service.

Strange issue with locale.

First, big thx for your lib ^^.

But I have a strange bug, I can't understand, compiled on raspberry.

snowboy::SnowboyDetect detector(resource_filename, model_filename);
if (setlocale(LC_ALL, "fr_FR") == NULL) setlocale(LC_ALL, "fr_FR.utf8");

Works fine but

if (setlocale(LC_ALL, "fr_FR") == NULL) setlocale(LC_ALL, "fr_FR.utf8");
snowboy::SnowboyDetect detector(resource_filename, model_filename);

Give

ERROR (ConvertStringToFloat():snowboy-utils.cc:149) ConvertStringToFloat: only part of the string can be converted: 0.1
terminate called after throwing an instance of 'std::runtime_error'
what(): ERROR (ConvertStringToFloat():snowboy-utils.cc:149) ConvertStringToFloat: only part of the string can be converted: 0.1
[stack trace: ]
./jarvis() [0x4431c]
./jarvis() [0x4495c]
./jarvis() [0x3a7a8]
./jarvis() [0x3ecf8]
./jarvis() [0x3f2d8]
./jarvis() [0x20284]
./jarvis() [0x1930c]
/lib/arm-linux-gnueabihf/libc.so.6(__libc_start_main+0x114) [0xb6a14294]

Java library

A swig java library would simplify the workflow for java projects.

Adjust for background noise?

Hi guys,

Love Snowboy, been using it for a while now for a voice-activated dashboard of sorts on my RPi at home. The problem I have though is that I seem to be getting a lot of false triggers whenever I turn the TV on. I've moved the mic further away from the TV, I'm using a personal model that was recorded using the RPi as well, so I think the obvious fronts are covered.

My question was, is there a way to adjust for background noise when instantiating a HotWordDetector? I feel like I had seen some code with a method like that months ago when initially looking into Snowboy, but I can't find anything like it now.

I'd appreciate letting me know if there is any such function, and if not, any other tips you guys might have to reduce false positives when there's some background noise (sleep time values, model adjustments, etc.).

Thanks a lot!

Make issue

make: python-config: Command not found
make: python-config: Command not found
g++ -I../../ -O3 -fPIC -std=c++0x -c snowboy-detect-swig.cc
snowboy-detect-swig.cc:154:21: fatal error: Python.h: No such file or directory

include <Python.h>

                 ^

compilation terminated.
Makefile:45: recipe for target 'snowboy-detect-swig.o' failed
make: *** [snowboy-detect-swig.o] Error 1

Any help figuring out what I'm doing wrong ?

"Alexa style" continuous speech instruction

Hi - great software!

I have your demo working with Ubuntu. What I'd like to do is detect the keyword in continuous speech in a similar way to the Amazon echo. Is that possible? For example, this:

"Alexa, turn on the lights"

instead of

"Alexa" [ding] "turn on the lights"

Ideally, I'd also want to know where in the audio the keyword was spoken so that it can be removed from audio before I send it to an online engine (such as api.ai or AVS).

Any suggestions would be great.

Thanks

The web site is down.

When's your web site is coming back online? I need to generate new voice commands.

Raspberry Pi Package

Hey, i'm new to developing with python, and am having trouble installing package with provided binary. When i uncompress the Raspberry Pi binary provided on the site I don't see a setup.py to use to install the package. Am I just supposed to run the script through the folder? I usually just install packages through pip so please excuse me if this a very simple question.

Create iOS Demo

Hi! This is great and I have a raspberry Pi 3 and this is way cool. However I would like to write a demo with iOS for you and then do a pull request. However getting it working is another story... I have the libsnowboy-detect.a library installed into my xCode project but I am getting an error in my header import which I have coded like so:

import <libsnowboy-detect/snowboy-detect.h>

"File not found" although I added it to build phases... If you can point me in the right direction I will write a nice demo... or just be eternally grateful

mac os x assertion error

Hello everyone, I'm having a little problem, whenever I'm trying to use snowboyy I get this error

||PaMacCore (AUHAL)|| Error on line 2466: err='-10863', msg=Audio Unit: cannot do in current context
Assertion failed: (!err), function AudioIOProc, file src/hostapi/coreaudio/pa_mac_core.c, line 2467

can somebody help me with that?

undefined symbol: cblas_sgemm

I'm trying to install snowboy on Ubuntu 16.04 LTS and get this when I run demo.py. This happens with both python3 and 2.

~/Downloads/ubuntu1404-x86_64-1.0.4$ sudo python3 demo.py resources/Marvin.pmdl 
Traceback (most recent call last):
  File "demo.py", line 1, in <module>
    import snowboydecoder
  File "/home/rithvik/Downloads/ubuntu1404-x86_64-1.0.4/snowboydecoder.py", line 5, in <module>
    import snowboydetect
  File "/home/rithvik/Downloads/ubuntu1404-x86_64-1.0.4/snowboydetect.py", line 28, in <module>
    _snowboydetect = swig_import_helper()
  File "/home/rithvik/Downloads/ubuntu1404-x86_64-1.0.4/snowboydetect.py", line 24, in swig_import_helper
    _mod = imp.load_module('_snowboydetect', fp, pathname, description)
  File "/usr/lib/python3.5/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: /home/rithvik/Downloads/ubuntu1404-x86_64-1.0.4/_snowboydetect.so: undefined symbol: cblas_sgemm

Any ideas?
EDIT: ubuntu1404-x86_64-1.0.4 is just the extracted tar for Ubuntu.

Windows Support

Is there going to be Windows support anytime soon? Because it wont work with my RPi

PS3 eye unplug/plug

Hi guys, great work!
have big Interest in snowboy and I've got it working on a Raspi with PS3 eye.
Problem is: after each reboot, ps3 eye isn't working. lsusb shows it, but no rec possible until I unplug and plug the Cam.
After days of testing and searching I'm now hoping for a little hint for configuring the cam correct.
uname -r shows 4.4.11+
OS is a raspian jessie 2016-05-10 with dist-upgrade

many greetings Michael

make: python-config: Command not found

Hello again,
After git clone of snowboy, I did:

cd swig/Python
make

And got these errors:

pi@raspberrypi:~/Downloads/snowboy/swig/Python $ make
make: python-config: Command not found
make: python-config: Command not found
swig -I../../ -c++ -python -o snowboy-detect-swig.cc snowboy-detect-swig.i
make: swig: Command not found
Makefile:45: recipe for target 'snowboy-detect-swig.cc' failed
make: *** [snowboy-detect-swig.cc] Error 127

I was able to get around this by running

pip install python-config
sudo apt-get install python-dev swig

Question though.... I see the set up section uses swig3.0. But when I ran make, it couldn't find swig until I installed just swig. Is there an issue with installing these 3 version of things? I see it also in the python3-pyaudio.

NodeJS Module fails to initialize: undefined symbol: cblas_sdot

Hi, I can't get the current version of snowboy (as published on npm) working. Running examples/node/microphone.js crashes with node: symbol lookup error: .../node_modules/snowboy/lib/node/binding/Release/node-v48-linux-x64/snowboy.node: undefined symbol: cblas_sdot

I've made sure I have libatlas-base-dev installed, but I thought I wouldn't need it because of the precompiled binaries.

Also, manually compiling by running node-pre-gyp --build-from-source doesn't resolve the issue.

I can reproduce this with the following example on Ubuntu 16.04.

const record = require('node-record-lpcm16');
const snowboy = require('snowboy');

const models = new snowboy.Models();
models.add({
  file: 'resources/snowboy.umdl',
  hotwords: 'snowboy'
});

const detector = new snowboy.Detector({
  resource: 'resources/common.res',
  models
});
record.start().pipe(detector);

suggestion: NodeJS module

Hello and thanks for the awesome job.

I was trying to create an NPM module for snowboy, but I kind of lost.
So, it might be easier to work together. If anyone could write simple C++ file to use snowboy, I can help with wrapping it as a javascript module and putting it in npm.

Or if anyone wants to go all the way, here are the directions to create c++ addons: https://nodejs.org/api/addons.html

Thanks

Logging

Getting snowboy integrated into the AlexaPi project :)

However there seems to be quite verbose logging printing to stdout I get INFO:snowboy:Silence every 100ms or so.

How do I turn off/adjust the output?

How to work on Android platform, I encountered a build error following your sop.

thanks for your excellent product.

Build environment:

  • Ubuntu14.04 64 bits
  • swig-3.0.7
  • android-ndk-r11c

$PATH:

king@wks:/Downloads/snowboy-master/swig/Android$ $PATH
bash: /home/king/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/king/AndroidDevelop/android-studio-sdk/android-sdk-linux/platform-tools:/home/king/AndroidDevelop/android-studio-sdk/android-sdk-linux/tools:/home/king/AndroidDevelop/swig_tool/bin:/home/king/AndroidDevelop/android-ndk-r11c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin: No such file or directory
king@wks:
/Downloads/snowboy-master/swig/Android$


I follow your step to build Android library by below:

cd swig/Android

Make sure you set up the NDKROOT variable in Makefile before you run.

We have only tested with NDK version r11c.

make

but I got an error like this:

OpenBLAS-0.2.18/version.h
OpenBLAS: Detecting fortran compiler failed. Cannot compile LAPACK. Only compile BLAS.
make[1]: Entering directory /home/king/Downloads/snowboy-master/swig/Android/OpenBLAS-Android' make[2]: Entering directory/home/king/Downloads/snowboy-master/swig/Android/OpenBLAS-Android/interface'
arm-linux-androideabi-gcc -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -marm -mfpu=neon -mfloat-abi=hard -march=armv7-a -Wl,--no-warn-mismatch -DASMNAME=saxpy -DASMFNAME=saxpy_ -DNAME=saxpy_ -DCNAME=saxpy -DCHAR_NAME="saxpy_" -DCHAR_CNAME="saxpy" -DNO_AFFINITY -I.. -I. -UDOUBLE -UCOMPLEX -c axpy.c -o saxpy.o
arm-linux-androideabi-gcc -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -marm -mfpu=neon -mfloat-abi=hard -march=armv7-a -Wl,--no-warn-mismatch -DASMNAME=sswap -DASMFNAME=sswap_ -DNAME=sswap_ -DCNAME=sswap -DCHAR_NAME="sswap_" -DCHAR_CNAME="sswap" -DNO_AFFINITY -I.. -I. -UDOUBLE -UCOMPLEX -c swap.c -o sswap.o
arm-linux-androideabi-gcc -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -marm -mfpu=neon -mfloat-abi=hard -march=armv7-a -Wl,--no-warn-mismatch -DASMNAME=scopy -DASMFNAME=scopy_ -DNAME=scopy_ -DCNAME=scopy -DCHAR_NAME="scopy_" -DCHAR_CNAME="scopy" -DNO_AFFINITY -I.. -I. -UDOUBLE -UCOMPLEX -c copy.c -o scopy.o
arm-linux-androideabi-gcc -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -marm -mfpu=neon -mfloat-abi=hard -march=armv7-a -Wl,--no-warn-mismatch -DASMNAME=sscal -DASMFNAME=sscal_ -DNAME=sscal_ -DCNAME=sscal -DCHAR_NAME="sscal_" -DCHAR_CNAME="sscal" -DNO_AFFINITY -I.. -I. -UDOUBLE -UCOMPLEX -c scal.c -o sscal.o
copy.c:39:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
make[2]: *** [scopy.o] Error 1
make[2]: *** Waiting for unfinished jobs....
axpy.c:39:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
make[2]: *** [saxpy.o] Error 1
scal.c:39:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
swap.c:39:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
make[2]: *** [sscal.o] Error 1
make[2]: *** [sswap.o] Error 1
make[2]: Leaving directory /home/king/Downloads/snowboy-master/swig/Android/OpenBLAS-Android/interface' make[1]: *** [libs] Error 1 make[1]: Leaving directory/home/king/Downloads/snowboy-master/swig/Android/OpenBLAS-Android'
make: [OpenBLAS-Android/install/lib/libopenblas.a] Error 1 (ignored)
arm-linux-androideabi-g++ -O3 --sysroot=/home/king/AndroidDevelop/android-ndk-r11c//platforms/android-17/arch-arm -shared -std=c++0x -rdynamic -I../../ -Wl,--fix-cortex-a8 -Wl,--no-warn-mismatch -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wno-sign-compare -Wa,--noexecstack -Wformat -Werror=format-security -fno-rtti -ffunction-sections -funwind-tables -fstack-protector-strong -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -fno-strict-aliasing -mthumb -no-canonical-prefixes -march=armv7-a -mfpu=vfpv3-d16 -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -DANDROID -c snowboy-detect-swig.cc -o snowboy-detect-swig.o
snowboy-detect-swig.cc:848:18: fatal error: string: No such file or directory
#include
^
compilation terminated.
make: *** [snowboy-detect-swig.o] Error 1

Could you provide a step in details about how to do it on Android platform, because I have no idea how to get information about snowboy, I have searched on internet, but no helps get.

In addition, could you provide the compiled android library and upload to this github project?

appreciate for your reply.

Doc issue: .asoundrc, not .asound

Hey guys,
I was going through the set up again and found I needed to set the hw value to get rec t.wav to work. I pasted in the settings doc'd in the "Set up audio" here: https://snowboy.kitt.ai/docs, but that says to save the file as .asound not .asoundrc which did work.

Call start() again after terminate()

Hi,

im trying to add snowboy to a personal assistant app i've been working on but to be able to record the audio i first need to terminate all recording streams from snowboy otherwise i get an Audio Deivce Busy Error.

After accessing detector.terminate() I can finally record my command and the python file processes it correctly. My only problem is, that while the prog loops detector.start(...) does not work anymore.

Is there a way to reenable detector.start(...) so snowboy listens for the Hotword and then kill everything with detector.terminate() (And so on and on)?

Thanks :)

Xubuntu 16.04 LTS linking error.

So I have Snowboy working nicely on Ubuntu 16.04 LTS, however when I try and run it on Xubtunu 16.04 via one of the demos, I get the error below. I haven't changed anything in your Make file, and installed Swig from source. Is the .a lib tied to 12.04 and 14.04?

Traceback (most recent call last): File "test.py", line 1, in <module> import snowboydecoder File "/home/robin/projects/dyson_mm_demo/third_party/snowboy/examples/Python/snowboydecoder.py", line 11, in <module> import snowboydetect File "/home/robin/projects/dyson_mm_demo/third_party/snowboy/examples/Python/snowboydetect.py", line 28, in <module> _snowboydetect = swig_import_helper() File "/home/robin/projects/dyson_mm_demo/third_party/snowboy/examples/Python/snowboydetect.py", line 24, in swig_import_helper _mod = imp.load_module('_snowboydetect', fp, pathname, description) ImportError: /home/robin/projects/dyson_mm_demo/third_party/snowboy/examples/Python/_snowboydetect.so: undefined symbol: _ZNK7snowboy13SnowboyDetect14GetSensitivityB5cxx11Ev

Using cron to start a python file that is wakeword enabled.

Im trying to start a python script upon raspberry pi start.
I have edited my root crontab file ( sudo crontab -e)
Ive asked cron to start the python script as well as the .pmdl file.
my crontab looks like
@ reboot /location_of_file/pythonscript.py Hotword.pmdl
the python script is starting, but but the startup error file for the script says that the .pmdl file is not found.

Am I going about this the right way? is there a special way i have to get snowboy started upon startup? or should it just work the same way it does using the command line.

Do i need to write a supplemental script to run the python file, and open the PMDL file at the same time?

Python 3.4 throws swig errors

Got it built for the pi, inside a venv. Super cool! However, although I'm able to run the demo with python 2.7, it fails when I try to run it using Python 3.4 (the default inside my virtual env).

Traceback (most recent call last):
  File "demo.py", line 1, in <module>
    import snowboydecoder
  File "/home/pi/jarvis/snowboy/examples/Python/snowboydecoder.py", line 5, in <module>
    import snowboydetect
  File "/home/pi/jarvis/snowboy/examples/Python/snowboydetect.py", line 28, in <module>
    _snowboydetect = swig_import_helper()
  File "/home/pi/jarvis/snowboy/examples/Python/snowboydetect.py", line 24, in swig_import_helper
    _mod = imp.load_module('_snowboydetect', fp, pathname, description)
  File "/usr/lib/python3.4/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
ImportError: dynamic module does not define init function (PyInit__snowboydetect)

I followed these instructions regarding getting it compiled:
#17

IOError: [Errno -9997] Invalid sample rate

Hey guys!
Great stuff! This is pretty much exactly what I was trying to build! But you guys are way further than I ever would have gotten. Er, but I didn't get very far.

I'm running this on a raspberry pi model B with a Cyber Acoustics USB microphone. I can successfully record something using AUDIODEV=hw:1,0 rec t.wav.

Anyway, when attempting the demo with this command:

pi@raspberrypi:~/Downloads/snowboy $ python demo.py ./resources/snowboy.umdl 

I get a bunch of garbage from ALSA that is apparently just warnings. But the last bit dumps this:

Expression 'paInvalidSampleRate' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2048
Expression 'PaAlsaStreamComponent_InitialConfigure( &self->capture, inParams, self->primeBuffers, hwParamsCapture, &realSr )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2719
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2843
Traceback (most recent call last):
  File "demo.py", line 27, in <module>
    detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5)
  File "/home/pi/Downloads/snowboy/snowboydecoder.py", line 115, in __init__
    stream_callback=audio_callback)
  File "/usr/local/lib/python2.7/dist-packages/pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
IOError: [Errno -9997] Invalid sample rate

I saw this while playing with another voice recognition and I was able to get past it by passing a sample rate. Is there an easy way to pass sample rate to your decoder?

For reference, here is the get_device_count dump:

import pyaudio
p = pyaudio.PyAudio()
for i in range(p.get_device_count()):
    print p.get_device_info_by_index(i)

Output: (formatted for reading!)

{
    'defaultSampleRate': 44100.0,
    'defaultLowOutputLatency': 0.005804988662131519,
    'defaultLowInputLatency': -1.0,
    'maxInputChannels': 0 L,
    'structVersion': 2 L,
    'hostApi': 0 L,
    'index': 0,
    'defaultHighOutputLatency': 0.034829931972789115,
    'maxOutputChannels': 2 L,
    'name': u 'bcm2835 ALSA: - (hw:0,0)',
    'defaultHighInputLatency': -1.0
} {
    'defaultSampleRate': 44100.0,
    'defaultLowOutputLatency': 0.005804988662131519,
    'defaultLowInputLatency': -1.0,
    'maxInputChannels': 0 L,
    'structVersion': 2 L,
    'hostApi': 0 L,
    'index': 1,
    'defaultHighOutputLatency': 0.034829931972789115,
    'maxOutputChannels': 2 L,
    'name': u 'bcm2835 ALSA: IEC958/HDMI (hw:0,1)',
    'defaultHighInputLatency': -1.0
} {
    'defaultSampleRate': 48000.0,
    'defaultLowOutputLatency': -1.0,
    'defaultLowInputLatency': 0.007979166666666667,
    'maxInputChannels': 2 L,
    'structVersion': 2 L,
    'hostApi': 0 L,
    'index': 2,
    'defaultHighOutputLatency': -1.0,
    'maxOutputChannels': 0 L,
    'name': u 'Cyber Acoustics USB device: Audio (hw:1,0)',
    'defaultHighInputLatency': 0.032
} {
    'defaultSampleRate': 44100.0,
    'defaultLowOutputLatency': 0.005804988662131519,
    'defaultLowInputLatency': -1.0,
    'maxInputChannels': 0 L,
    'structVersion': 2 L,
    'hostApi': 0 L,
    'index': 3,
    'defaultHighOutputLatency': 0.034829931972789115,
    'maxOutputChannels': 128 L,
    'name': u 'sysdefault',
    'defaultHighInputLatency': -1.0
} {
    'defaultSampleRate': 44100.0,
    'defaultLowOutputLatency': 0.005804988662131519,
    'defaultLowInputLatency': -1.0,
    'maxInputChannels': 0 L,
    'structVersion': 2 L,
    'hostApi': 0 L,
    'index': 4,
    'defaultHighOutputLatency': 0.034829931972789115,
    'maxOutputChannels': 128 L,
    'name': u 'default',
    'defaultHighInputLatency': -1.0
} {
    'defaultSampleRate': 48000.0,
    'defaultLowOutputLatency': 0.021333333333333333,
    'defaultLowInputLatency': -1.0,
    'maxInputChannels': 0 L,
    'structVersion': 2 L,
    'hostApi': 0 L,
    'index': 5,
    'defaultHighOutputLatency': 0.021333333333333333,
    'maxOutputChannels': 2 L,
    'name': u 'dmix',
    'defaultHighInputLatency': -1.0
}

add -infile option to read from pre-recorded wav file

For testing, I would like to record my voice and give the recorded sample to snowboy for testing my script without having to speak into my microphone everytime.

On pocket_sphinx continus there is an option to do that
pocketsphinx_continuous -infile file.wav

Make error - make: *** [_snowboydetect.so] Error 1

" g++ -I../../ -O3 -fPIC -std=c++0x -shared snowboy-detect-swig.o
../..//lib/ubuntu64/libsnowboy-detect.a -L/usr/local/lib/python2.7/config -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic -lm -ldl -lf77blas -lcblas -llapack_atlas -latlas -o _snowboydetect.so
/usr/bin/ld: /usr/local/lib/python2.7/config/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/python2.7/config/libpython2.7.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [_snowboydetect.so] Error 1 "

I am following the exact steps provided in the git documentation. I navigate to "swig/Python" and compile ( make ). I get the above make error. Any solutions for this??

Documentation not updated

Just to let you know that the documentation on the website is not up to date concerning the demo code.

It is showing
detector.start(detected_callback=snowboydecoder.ding_callback, interrupt_check=interrupt_callback, sleep_time=0.03)

Where it changed to
snowboydecoder.play_audio_file

Great tool !

Android demo app crash

I write a demo tool to use "hotword detection" function, but I encountered a crash when create a SnowboyDetect object, error msg is:

W/art (11495): Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
E/art (11495): No implementation found for long ai.kitt.snowboy.snowboyJNI.new_SnowboyDetect(java.lang.String, java.lang.String) (tried Java_ai_kitt_snowboy_snowboyJNI_new_1SnowboyDetect and Java_ai_kitt_snowboy_snowboyJNI_new_1SnowboyDetect__Ljava_lang_String_2Ljava_lang_String_2)
D/AndroidRuntime(11495): Shutting down VM
E/AndroidRuntime(11495): FATAL EXCEPTION: main
E/AndroidRuntime(11495): Process: com.wistron.demo.tool.snowboy_demo, PID: 11495
E/AndroidRuntime(11495): java.lang.UnsatisfiedLinkError: No implementation found for long ai.kitt.snowboy.snowboyJNI.new_SnowboyDetect(java.lang.String, java.lang.String) (tried Java_ai_kitt_snowboy_snowboyJNI_new_1SnowboyDetect and Java_ai_kitt_snowboy_snowboyJNI_new_1SnowboyDetect__Ljava_lang_String_2Ljava_lang_String_2)
E/AndroidRuntime(11495): at ai.kitt.snowboy.snowboyJNI.new_SnowboyDetect(Native Method)
E/AndroidRuntime(11495): at ai.kitt.snowboy.SnowboyDetect.(SnowboyDetect.java:39)
E/AndroidRuntime(11495): at com.wistron.demo.tool.snowboy_demo.MainActivity.onCreate(MainActivity.java:16)
E/AndroidRuntime(11495): at android.app.Activity.performCreate(Activity.java:5933)
E/AndroidRuntime(11495): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
E/AndroidRuntime(11495): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
E/AndroidRuntime(11495): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
E/AndroidRuntime(11495): at android.app.ActivityThread.access$800(ActivityThread.java:144)
E/AndroidRuntime(11495): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
E/AndroidRuntime(11495): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(11495): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(11495): at android.app.ActivityThread.main(ActivityThread.java:5219)
E/AndroidRuntime(11495): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(11495): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(11495): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:898)
E/AndroidRuntime(11495): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
W/ActivityManager( 828): Force finishing activity com.wistron.demo.tool.snowboy_demo/.MainActivity


My code snippet as below:

Java code:

    // Assume you put the model related files under /sdcard/snowboy/
    SnowboyDetect snowboyDetector = new SnowboyDetect("/storage/emulated/legacy/common.res",
            "/storage/emulated/legacy/snowboy.umdl");
    snowboyDetector.SetSensitivity("0.45");         // Sensitivity for each hotword
    snowboyDetector.SetAudioGain(2.0f);              // Audio gain for detection
    short[] buffer = new short[1024];
    int result = snowboyDetector.RunDetection(buffer, buffer.length);   // buffer is a short array.

I have pushed common.res and snowboy.umdl files to Android internal storage root folder. those files come from snowboy-master/resources/

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.wistron.demo.tool.snowboy_demo"> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>

thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.