mirror of
https://github.com/wassname/BitLit_test1.git
synced 2026-06-27 16:28:23 +08:00
moving files into subfolders
This commit is contained in:
+91
-4
@@ -1,6 +1,94 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/linux,macos,python
|
||||
# Edit at https://www.gitignore.io/?templates=linux,macos,python
|
||||
/outputs/
|
||||
/snowboy/
|
||||
|
||||
# Created by https://www.gitignore.io/api/c,c++,cmake,linux,macos,python
|
||||
# Edit at https://www.gitignore.io/?templates=c,c++,cmake,linux,macos,python
|
||||
|
||||
### C ###
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Linker output
|
||||
*.ilk
|
||||
*.map
|
||||
*.exp
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
*.idb
|
||||
*.pdb
|
||||
|
||||
# Kernel Module Compile Results
|
||||
*.mod*
|
||||
*.cmd
|
||||
.tmp_versions/
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
### C++ ###
|
||||
# Prerequisites
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
|
||||
# Precompiled Headers
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
|
||||
# Executables
|
||||
|
||||
### CMake ###
|
||||
CMakeLists.txt.user
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
@@ -52,7 +140,6 @@ __pycache__/
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
@@ -165,4 +252,4 @@ dmypy.json
|
||||
### Python Patch ###
|
||||
.venv/
|
||||
|
||||
# End of https://www.gitignore.io/api/linux,macos,python
|
||||
# End of https://www.gitignore.io/api/c,c++,cmake,linux,macos,python
|
||||
|
||||
BIN
Binary file not shown.
@@ -1,10 +1,11 @@
|
||||
#### RUNNING THE MODEL
|
||||
#Michels-MacBook-Pro:~ ShebMichel$ cd documents/pmlg/wake/decoder
|
||||
#Michels-MacBook-Pro:decoder ShebMichel$ python demo.py resources/HiBitLit.pmdl
|
||||
import snowboydecoder
|
||||
import sys
|
||||
import signal
|
||||
import sys, os
|
||||
import sys
|
||||
|
||||
import snowboydecoder
|
||||
import signal
|
||||
#import BitLit_main ## MAIN PROGRAM
|
||||
|
||||
####
|
||||
@@ -65,4 +66,4 @@ detector.start(detected_callback=snowboydecoder.run,
|
||||
detector.terminate()
|
||||
t1 =time.time()
|
||||
total=t1-t0
|
||||
print 'Time spent is about:', np.round(total), 'seconds'
|
||||
print(('Time spent is about:', np.round(total), 'seconds'))
|
||||
+9
-8
@@ -30,15 +30,15 @@ t0=time.time()
|
||||
r = sr.Recognizer()
|
||||
with sr.Microphone() as source:
|
||||
tts = gTTS(text='HELLO! My Name is BIT-LIT. PLEASE SPEAK IN ABOUT 3 SECONDS.', lang='en')
|
||||
tts.save("BitLit.mp3")
|
||||
os.system("afplay BitLit.mp3")
|
||||
tts.save("outputs/BitLit.mp3")
|
||||
os.system("afplay outputs/BitLit.mp3")
|
||||
# ######
|
||||
|
||||
print("SPEAK NOW-SPEAK NOW-SPEAK NOW:")
|
||||
audio = r.listen(source)
|
||||
tts = gTTS(text='THANK YOU! GIVE ME A SECOND TO READ OUT YOUR POEM', lang='en')
|
||||
tts.save("BitLit.mp3")
|
||||
os.system("afplay BitLit.mp3")
|
||||
tts.save("outputs/BitLit.mp3")
|
||||
os.system("afplay outputs/BitLit.mp3")
|
||||
try:
|
||||
# for testing purposes, we're just using the default API key
|
||||
# to use another API key, use `r.recognize_google(audio, key="GOOGLE_SPEECH_RECOGNITION_API_KEY")`
|
||||
@@ -57,18 +57,19 @@ text_generated=poem(USER_INPUT)
|
||||
################# FEED POEM TO TRANSCRIBER
|
||||
print('ML POEM is:', text_generated)
|
||||
tts = gTTS(text=text_generated, lang='en')
|
||||
tts.save("BitLit.mp3")
|
||||
os.system("afplay BitLit.mp3")
|
||||
tts.save("outputs/BitLit.mp3")
|
||||
os.system("afplay outputs/BitLit.mp3")
|
||||
#########################################################
|
||||
####
|
||||
print("BIT-LIT ENDING STATEMENT:")
|
||||
tts = gTTS(text='THANK YOU! CHECK ME OUT IN THE NEWS SOON.', lang='en')
|
||||
tts.save("BitLit.mp3")
|
||||
os.system("afplay BitLit.mp3")
|
||||
tts.save("outputs/BitLit.mp3")
|
||||
os.system("afplay outputs/BitLit.mp3")
|
||||
######
|
||||
t1 =time.time()
|
||||
total=t1-t0
|
||||
print 'Time spent is about:', np.round(total), 'seconds'
|
||||
|
||||
### USING JUPITER
|
||||
# import IPython.display as ipd
|
||||
# ipd.Audio(filename='path/to/file.mp3')
|
||||
|
||||
+3
-2
@@ -5,8 +5,9 @@ Created on Tue Dec 4 13:52:18 2018
|
||||
@author: 22029152
|
||||
"""
|
||||
import numpy as np
|
||||
import os
|
||||
|
||||
parameters_poems = np.load('model_poems.npy')[()]
|
||||
parameters_poems = np.load(os.path.join('weights', 'model_poems.npy'))[()]
|
||||
embedding_weights_poems = parameters_poems['embedding_weights']
|
||||
gru_weights_poems = parameters_poems['gru_weights']
|
||||
fc_weights_poems = parameters_poems['fc_weights']
|
||||
@@ -21,7 +22,7 @@ BUFFER_SIZE_poems = parameters_poems['BUFFER_SIZE']
|
||||
vocab_size_poems = len(dict(idx2char_poems))
|
||||
|
||||
# Load hyperparameters and layers' weights previously saved
|
||||
parameters_rhymes = np.load('model_rhymes.npy')[()]
|
||||
parameters_rhymes = np.load(os.path.join('weights', 'model_rhymes.npy'))[()]
|
||||
embedding_weights_rhymes = parameters_rhymes['embedding_weights']
|
||||
gru_weights_rhymes = parameters_rhymes['gru_weights']
|
||||
fc_weights_rhymes = parameters_rhymes['fc_weights']
|
||||
|
||||
@@ -1,419 +1,27 @@
|
||||
# Snowboy Hotword Detection
|
||||
|
||||
by [KITT.AI](http://kitt.ai).
|
||||
|
||||
[Home Page](https://snowboy.kitt.ai)
|
||||
|
||||
[Full Documentation](http://docs.kitt.ai/snowboy) and [FAQ](http://docs.kitt.ai/snowboy#faq)
|
||||
# Run
|
||||
To run the program once installed
|
||||
>> python BitLit_decoder1.py HiBitLit.pmdl
|
||||
After sometimes you should say " HI BitLit" then wait till the poetbot speak to you..and enjoy the rest.. At the end you just need to say again " Hi BitLit" to a different vocal input for so that the poetbot can generate a new poem and the cycle can go days and weeks..
|
||||
WARNING::: Might be slow depending on your computer capabilities..
|
||||
|
||||
[Discussion Group](https://groups.google.com/a/kitt.ai/forum/#!forum/snowboy-discussion) (or send email to snowboy-discussion@kitt.ai)
|
||||
# Setup
|
||||
|
||||
(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.)
|
||||
- clone the repositry
|
||||
|
||||
Version: 1.1.1 (3/24/2017)
|
||||
Requirements:
|
||||
- Python2, pip
|
||||
- for mac
|
||||
- Brew (mac: sudo apt-get install linuxbrew-wrapper)
|
||||
- PIP (sudo apt-get install python-pip)
|
||||
- PortAudio (mac: brew install portaudio)
|
||||
- for ubuntu:
|
||||
- PortAudio (sudo apt install portaudio19-dev)
|
||||
- gTTS (pip install gTTS)
|
||||
- SpeechRecognition (pip install SpeechRecognition)
|
||||
- PyAudio (pip install pyaudio)
|
||||
- Tensorflow (pip install tensorflow)
|
||||
- Unzip SNOWBOY v1.1.1 (http://docs.kitt.ai/snowboy/#downloads)
|
||||
|
||||
## Alexa support
|
||||
|
||||
Snowboy now brings hands-free experience to the [Alexa AVS sample app](https://github.com/alexa/alexa-avs-sample-app) on Raspberry Pi! Here is how you can use other Snowboy models
|
||||
|
||||
**Personal model**
|
||||
* Create your personal hotword model through our [website](https://snowboy.kitt.ai) or [hotword API](https://snowboy.kitt.ai/api/v1/train/)
|
||||
* Replace the hotword model in [Alexa AVS sample app](https://github.com/alexa/alexa-avs-sample-app) (after installation) with your personal model
|
||||
|
||||
```
|
||||
# Please replace YOUR_PERSONAL_MODEL.pmdl with the personal model you just
|
||||
# created, and $ALEXA_AVS_SAMPLE_APP_PATH with the actual path where you
|
||||
# cloned the Alexa AVS sample app repository.
|
||||
cp YOUR_PERSONAL_MODEL.pmdl $ALEXA_AVS_SAMPLE_APP_PATH/samples/wakeWordAgent/ext/resources/alexa.umdl
|
||||
```
|
||||
|
||||
* Set `APPLY_FRONTEND` to `false` and update `SENSITIVITY` in the [Alexa AVS sample app code](https://github.com/alexa/alexa-avs-sample-app/blob/master/samples/wakeWordAgent/src/KittAiSnowboyWakeWordEngine.cpp) and re-compile
|
||||
|
||||
```
|
||||
# Please replace $ALEXA_AVS_SAMPLE_APP_PATH with the actual path where you
|
||||
# cloned the Alexa AVS sample app repository.
|
||||
cd $ALEXA_AVS_SAMPLE_APP_PATH/samples/wakeWordAgent/src/
|
||||
|
||||
# Modify KittAiSnowboyWakeWordEngine.cpp and update SENSITIVITY at line 28.
|
||||
# Modify KittAiSnowboyWakeWordEngine.cpp and set APPLY_FRONTEND to false at
|
||||
# line 30.
|
||||
make
|
||||
```
|
||||
|
||||
* Run the wake word agent with engine set to `kitt_ai`!
|
||||
|
||||
**Universal model**
|
||||
* Replace the hotword model in [Alexa AVS sample app](https://github.com/alexa/alexa-avs-sample-app) (after installation) with your universal model
|
||||
|
||||
```
|
||||
# Please replace YOUR_UNIVERSAL_MODEL.umdl with the personal model you just
|
||||
# created, and $ALEXA_AVS_SAMPLE_APP_PATH with the actual path where you
|
||||
# cloned the Alexa AVS sample app repository.
|
||||
cp YOUR_UNIVERSAL_MODEL.umdl $ALEXA_AVS_SAMPLE_APP_PATH/samples/wakeWordAgent/ext/resources/alexa.umdl
|
||||
```
|
||||
|
||||
* Update `SENSITIVITY` in the [Alexa AVS sample app code](https://github.com/alexa/alexa-avs-sample-app/blob/master/samples/wakeWordAgent/src/KittAiSnowboyWakeWordEngine.cpp) and re-compile
|
||||
|
||||
```
|
||||
# Please replace $ALEXA_AVS_SAMPLE_APP_PATH with the actual path where you
|
||||
# cloned the Alexa AVS sample app repository.
|
||||
cd $ALEXA_AVS_SAMPLE_APP_PATH/samples/wakeWordAgent/src/
|
||||
|
||||
# Modify KittAiSnowboyWakeWordEngine.cpp and update SENSITIVITY at line 28.
|
||||
make
|
||||
```
|
||||
|
||||
* 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](http://docs.kitt.ai/snowboy) and example [Python/Bash script](examples/REST_API) (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:
|
||||
|
||||
* all versions of Raspberry Pi (with Raspbian based on Debian Jessie 8.0)
|
||||
* 64bit Mac OS X
|
||||
* 64bit Ubuntu (12.04 and 14.04)
|
||||
* iOS
|
||||
* Android
|
||||
* Pine64 (Debian Jessie 8.5, 3.10.102 BSP2)
|
||||
* Intel Edison (Ubilinux based on Debian Wheezy 7.8)
|
||||
* Samsung Artik (built with Fedora 25 for ARMv7)
|
||||
|
||||
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:
|
||||
|
||||
* Java/Android
|
||||
* Go (thanks to @brentnd)
|
||||
* Node (thanks to @evancohen)
|
||||
* Perl (thanks to @iboguslavsky)
|
||||
* Python
|
||||
* iOS/Swift3 (thanks to @grimlockrocks)
|
||||
* iOS/Object-C (thanks to @patrickjquinn)
|
||||
|
||||
If you want support on other hardware/OS, please send your request to
|
||||
[snowboy@kitt.ai](mailto:snowboy.kitt.ai)
|
||||
|
||||
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 [snowboy@kitt.ai](mailto:snowboy@kitt.ai)
|
||||
|
||||
* 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/snowboy.umdl**: Universal model for the hotword "Snowboy". Set
|
||||
SetSensitivity to 0.5 for better performance.
|
||||
* **resources/alexa.umdl**: Universal model for the hotword "Alexa". Set
|
||||
SetSensitivity to 0.5, and preferably set ApplyFrontend to true. This model is
|
||||
depressed.
|
||||
* **resources/alexa_02092017.umdl**: Universal model for the hotword "Alexa". This
|
||||
is still work in progress. Set SetSensitivity to 0.15.
|
||||
|
||||
## 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
|
||||
* 64 bit Ubuntu [12.04](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/ubuntu1204-x86_64-1.1.1.tar.bz2)
|
||||
/ [14.04](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/ubuntu1404-x86_64-1.1.1.tar.bz2)
|
||||
* [MacOS X](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/osx-x86_64-1.1.1.tar.bz2)
|
||||
* Raspberry Pi with Raspbian 8.0, all versions
|
||||
([1/2/3/Zero](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/rpi-arm-raspbian-8.0-1.1.1.tar.bz2))
|
||||
* Pine64 (Debian Jessie 8.5 (3.10.102)) ([download](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/pine64-debian-jessie-1.1.1.tar.bz2))
|
||||
* Intel Edison (Ubilinux based on Debian Wheezy 7.8) ([download](https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/edison-ubilinux-1.1.1.tar.bz2))
|
||||
|
||||
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](http://brew.sh/). If you don't have `pip`, you can install it [here](https://pip.pypa.io/en/stable/installing/).
|
||||
|
||||
Make sure that you can record audio with your microphone:
|
||||
|
||||
rec t.wav
|
||||
|
||||
### Ubuntu/Raspberry Pi/Pine64
|
||||
|
||||
First `apt-get` install `swig`, `sox`, `portaudio` and its Python binding `pyaudio`:
|
||||
|
||||
sudo apt-get install swig3.0 python-pyaudio python3-pyaudio sox
|
||||
pip install pyaudio
|
||||
|
||||
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](http://docs.kitt.ai/snowboy).
|
||||
|
||||
## 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:
|
||||
|
||||
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!
|
||||
|
||||
<img src=https://s3-us-west-2.amazonaws.com/kittai-cdn/Snowboy/Obj-C_Demo_02172017.png alt="Obj-C Example" width=300 /> <img src=https://s3-us-west-2.amazonaws.com/kittai-cdn/Snowboy/Swift3_Demo_02172017.png alt="Swift3 Example" width=300 />
|
||||
|
||||
|
||||
## Compile an Android Wrapper
|
||||
|
||||
Full README and tutorial is in [Android README](examples/Android/README.md) and here's a screenshot:
|
||||
|
||||
<img src="https://s3-us-west-2.amazonaws.com/kittai-cdn/Snowboy/SnowboyAlexaDemo-Andriod.jpeg" alt="Android Alexa Demo" width=300 />
|
||||
|
||||
|
||||
## 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](https://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](http://docs.kitt.ai/snowboy).
|
||||
|
||||
## Change Log
|
||||
|
||||
**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 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
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
To run the program once installed
|
||||
>> python BitLit_decoder1.py HiBitLit.pmdl
|
||||
After sometimes you should say " HI BitLit" then wait till the poetbot speak to you..and enjoy the rest.. At the end you just need to say again " Hi BitLit" to a different vocal input for so that the poetbot can generate a new poem and the cycle can go days and weeks..
|
||||
WARNING::: Might be slow depending on your computer capabilities..
|
||||
|
||||
REQUIRED MODULES
|
||||
1- Python (cmd python to check version??? If not then INSTALL)
|
||||
2- PIP (sudo apt-get install python-pip)
|
||||
3- gTTS (pip install gTTS)
|
||||
4- SpeechRecognition (pip install SpeechRecognition)
|
||||
5- Brew (sudo apt-get install linuxbrew-wrapper)
|
||||
6- PortAudio (brew install portaudio)
|
||||
|
||||
Just make sure all required module are updated (sudo apt update && sudo apt
|
||||
|
||||
upgrade)
|
||||
|
||||
7- PyAudio (pip install pyaudio)
|
||||
8- Tensorflow (pip install tensorflow)
|
||||
9- SNOWBOY
|
||||
|
||||
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
@@ -15,36 +15,6 @@ import re
|
||||
from textblob import TextBlob
|
||||
import random
|
||||
from BitLit_param import*
|
||||
#BitLit_param()
|
||||
#parameters_poems = np.load('model_poems.npy')[()]
|
||||
#embedding_weights_poems = parameters_poems['embedding_weights']
|
||||
#gru_weights_poems = parameters_poems['gru_weights']
|
||||
#fc_weights_poems = parameters_poems['fc_weights']
|
||||
#char2idx_poems = parameters_poems['char2idx']
|
||||
#idx2char_poems = parameters_poems['idx2char']
|
||||
#max_length_poems = parameters_poems['max_length']
|
||||
#embedding_dim_poems = parameters_poems['embedding_dim']
|
||||
#units_poems = parameters_poems['units']
|
||||
#BATCH_SIZE_poems = parameters_poems['BATCH_SIZE']
|
||||
#BUFFER_SIZE_poems = parameters_poems['BUFFER_SIZE']
|
||||
#
|
||||
#vocab_size_poems = len(dict(idx2char_poems))
|
||||
#
|
||||
## Load hyperparameters and layers' weights previously saved
|
||||
#parameters_rhymes = np.load('model_rhymes.npy')[()]
|
||||
#embedding_weights_rhymes = parameters_rhymes['embedding_weights']
|
||||
#gru_weights_rhymes = parameters_rhymes['gru_weights']
|
||||
#fc_weights_rhymes = parameters_rhymes['fc_weights']
|
||||
#word2idx_rhymes = parameters_rhymes['word2idx']
|
||||
#idx2word_rhymes = parameters_rhymes['idx2word']
|
||||
#max_length_rhymes = parameters_rhymes['max_length']
|
||||
#embedding_dim_rhymes = parameters_rhymes['embedding_dim']
|
||||
#units_rhymes = parameters_rhymes['units']
|
||||
#BATCH_SIZE_rhymes = parameters_rhymes['BATCH_SIZE']
|
||||
#BUFFER_SIZE_rhymes = parameters_rhymes['BUFFER_SIZE']
|
||||
#
|
||||
#vocab_size_rhymes = len(dict(idx2word_rhymes))
|
||||
|
||||
|
||||
# Architechture of the GRU
|
||||
|
||||
@@ -132,28 +102,6 @@ def poem(USER_INPUT):
|
||||
#################################################################################
|
||||
### ML POEM PREDICTOR
|
||||
|
||||
#####################
|
||||
# BACKGROUND STUFF #
|
||||
#####################
|
||||
|
||||
'''
|
||||
|
||||
Each time we run the script, we load the parameters and set the weights.
|
||||
This is inefficient. Is there a way to run the background stuff only once ? (lines 60 to 140)
|
||||
|
||||
'''
|
||||
# Load the poems model parameters (hyperparameters and weights)
|
||||
#parameters_poems = np.load('model_poems.npy')[()]
|
||||
|
||||
|
||||
|
||||
|
||||
'''
|
||||
|
||||
End of the background thingy
|
||||
|
||||
'''
|
||||
|
||||
|
||||
###########################
|
||||
# USER INPUT a line #
|
||||
|
||||
Binary file not shown.
+11
-8
@@ -1,21 +1,24 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import collections
|
||||
import pyaudio
|
||||
import snowboydetect
|
||||
import time
|
||||
import wave
|
||||
import os
|
||||
import time
|
||||
import logging
|
||||
import collections
|
||||
|
||||
import pyaudio
|
||||
import wave
|
||||
|
||||
os.sys.path.append('./snowboy')
|
||||
import snowboydetect
|
||||
|
||||
logging.basicConfig()
|
||||
logger = logging.getLogger("snowboy")
|
||||
logger.setLevel(logging.INFO)
|
||||
TOP_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
RESOURCE_FILE = os.path.join(TOP_DIR, "resources/common.res")
|
||||
DETECT_DING = os.path.join(TOP_DIR, "resources/ding.wav")
|
||||
DETECT_DONG = os.path.join(TOP_DIR, "resources/dong.wav")
|
||||
RESOURCE_FILE = os.path.join(TOP_DIR, "snowboy/resources/common.res")
|
||||
DETECT_DING = os.path.join(TOP_DIR, "snowboy/resources/ding.wav")
|
||||
DETECT_DONG = os.path.join(TOP_DIR, "snowboy/resources/dong.wav")
|
||||
DETECT_PY = os.path.join(TOP_DIR, "BitLit_main.py") ## ADDED
|
||||
|
||||
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
# This file was automatically generated by SWIG (http://www.swig.org).
|
||||
# Version 3.0.7
|
||||
#
|
||||
# Do not make changes to this file unless you know what you are doing--modify
|
||||
# the SWIG interface file instead.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
from sys import version_info
|
||||
if version_info >= (2, 6, 0):
|
||||
def swig_import_helper():
|
||||
from os.path import dirname
|
||||
import imp
|
||||
fp = None
|
||||
try:
|
||||
fp, pathname, description = imp.find_module('_snowboydetect', [dirname(__file__)])
|
||||
except ImportError:
|
||||
import _snowboydetect
|
||||
return _snowboydetect
|
||||
if fp is not None:
|
||||
try:
|
||||
_mod = imp.load_module('_snowboydetect', fp, pathname, description)
|
||||
finally:
|
||||
fp.close()
|
||||
return _mod
|
||||
_snowboydetect = swig_import_helper()
|
||||
del swig_import_helper
|
||||
else:
|
||||
import _snowboydetect
|
||||
del version_info
|
||||
try:
|
||||
_swig_property = property
|
||||
except NameError:
|
||||
pass # Python < 2.2 doesn't have 'property'.
|
||||
|
||||
|
||||
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
|
||||
if (name == "thisown"):
|
||||
return self.this.own(value)
|
||||
if (name == "this"):
|
||||
if type(value).__name__ == 'SwigPyObject':
|
||||
self.__dict__[name] = value
|
||||
return
|
||||
method = class_type.__swig_setmethods__.get(name, None)
|
||||
if method:
|
||||
return method(self, value)
|
||||
if (not static):
|
||||
if _newclass:
|
||||
object.__setattr__(self, name, value)
|
||||
else:
|
||||
self.__dict__[name] = value
|
||||
else:
|
||||
raise AttributeError("You cannot add attributes to %s" % self)
|
||||
|
||||
|
||||
def _swig_setattr(self, class_type, name, value):
|
||||
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
|
||||
|
||||
|
||||
def _swig_getattr_nondynamic(self, class_type, name, static=1):
|
||||
if (name == "thisown"):
|
||||
return self.this.own()
|
||||
method = class_type.__swig_getmethods__.get(name, None)
|
||||
if method:
|
||||
return method(self)
|
||||
if (not static):
|
||||
return object.__getattr__(self, name)
|
||||
else:
|
||||
raise AttributeError(name)
|
||||
|
||||
def _swig_getattr(self, class_type, name):
|
||||
return _swig_getattr_nondynamic(self, class_type, name, 0)
|
||||
|
||||
|
||||
def _swig_repr(self):
|
||||
try:
|
||||
strthis = "proxy of " + self.this.__repr__()
|
||||
except:
|
||||
strthis = ""
|
||||
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
|
||||
|
||||
try:
|
||||
_object = object
|
||||
_newclass = 1
|
||||
except AttributeError:
|
||||
class _object:
|
||||
pass
|
||||
_newclass = 0
|
||||
|
||||
|
||||
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, resource_filename, model_str):
|
||||
this = _snowboydetect.new_SnowboyDetect(resource_filename, model_str)
|
||||
try:
|
||||
self.this.append(this)
|
||||
except:
|
||||
self.this = this
|
||||
|
||||
def Reset(self):
|
||||
return _snowboydetect.SnowboyDetect_Reset(self)
|
||||
|
||||
def RunDetection(self, *args):
|
||||
return _snowboydetect.SnowboyDetect_RunDetection(self, *args)
|
||||
|
||||
def SetSensitivity(self, sensitivity_str):
|
||||
return _snowboydetect.SnowboyDetect_SetSensitivity(self, sensitivity_str)
|
||||
|
||||
def GetSensitivity(self):
|
||||
return _snowboydetect.SnowboyDetect_GetSensitivity(self)
|
||||
|
||||
def SetAudioGain(self, audio_gain):
|
||||
return _snowboydetect.SnowboyDetect_SetAudioGain(self, audio_gain)
|
||||
|
||||
def UpdateModel(self):
|
||||
return _snowboydetect.SnowboyDetect_UpdateModel(self)
|
||||
|
||||
def NumHotwords(self):
|
||||
return _snowboydetect.SnowboyDetect_NumHotwords(self)
|
||||
|
||||
def SampleRate(self):
|
||||
return _snowboydetect.SnowboyDetect_SampleRate(self)
|
||||
|
||||
def NumChannels(self):
|
||||
return _snowboydetect.SnowboyDetect_NumChannels(self)
|
||||
|
||||
def BitsPerSample(self):
|
||||
return _snowboydetect.SnowboyDetect_BitsPerSample(self)
|
||||
__swig_destroy__ = _snowboydetect.delete_SnowboyDetect
|
||||
__del__ = lambda self: None
|
||||
SnowboyDetect_swigregister = _snowboydetect.SnowboyDetect_swigregister
|
||||
SnowboyDetect_swigregister(SnowboyDetect)
|
||||
|
||||
# This file is compatible with both classic and new-style classes.
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user