Skip to content

Commit 6d40c25

Browse files
authored
Merge pull request #581 from eqiihuu/master
Update instructions and patch file for AVS-device-sdk Version 1.12.1
2 parents 657c8db + b1e0a08 commit 6d40c25

File tree

2 files changed

+123
-29
lines changed

2 files changed

+123
-29
lines changed

README.md

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,60 +14,83 @@ Version: 1.3.0 (2/19/2018)
1414

1515
## Alexa support
1616

17-
Snowboy now brings hands-free experience to the [Alexa AVS sample app](https://github.com/alexa/alexa-avs-sample-app) on Raspberry Pi! See more info below regarding the performance and how you can use other hotword models.
17+
Snowboy now brings hands-free experience to the [Alexa AVS sample app](https://github.com/alexa/avs-device-sdk/wiki/Raspberry-Pi-Quick-Start-Guide-with-Script) 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.
1818

1919
**Performance**
2020

2121
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](https://github.com/Kitt-AI/snowboy/raw/master/resources/alexa/SnowboyAlexaDemo.apk) (please uninstall any previous versions first if you have installed this app before).
2222

23+
**Kittai KWD Engine**
24+
25+
* Set up [Alexa AVS sample app](https://github.com/alexa/avs-device-sdk/wiki/Raspberry-Pi-Quick-Start-Guide-with-Script) following the official AVS instructions
26+
27+
* Apply patch to replace the Sensory KWD engine with Kittai engine
28+
```
29+
# 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
30+
# cloned the Alexa AVS sample app repository, and replace $SNOWBOY_ROOT_PATH with the actual path where you clone the Snowboy repository
31+
cd $ALEXA_AVS_SAMPLE_APP_PATH
32+
cp $SNOWBOY_PATH/resource/alexa/alexa-avs-sample-app/avs-kittai.patch ./
33+
34+
# Apply the patch, this will modify the scripts setup.sh and pi.sh
35+
patch < avs-kittai.patch
36+
```
37+
38+
* Re-compile the avs-device-sdk and sample app
39+
```
40+
sudo bash setup.sh config.json
41+
```
42+
43+
* Run the sample app
44+
```
45+
sudo bash startsample.sh
46+
```
47+
48+
Here is a [demo video](https://www.youtube.com/watch?v=wiLEr6TeE58) for how to use Snowboy hotword engine in Alexa Voice Service.
49+
2350
**Personal model**
2451

2552
* Create your personal hotword model through our [website](https://snowboy.kitt.ai) or [hotword API](https://snowboy.kitt.ai/api/v1/train/)
2653

27-
* Replace the hotword model in [Alexa AVS sample app](https://github.com/alexa/alexa-avs-sample-app) (after installation) with your personal model
2854

55+
* Put your personal model in [snowboy/resources](https://github.com/Kitt-AI/snowboy/tree/master/resources)
2956
```
30-
# Please replace YOUR_PERSONAL_MODEL.pmdl with the personal model you just
31-
# created, and $ALEXA_AVS_SAMPLE_APP_PATH with the actual path where you
32-
# cloned the Alexa AVS sample app repository.
33-
cp YOUR_PERSONAL_MODEL.pmdl $ALEXA_AVS_SAMPLE_APP_PATH/samples/wakeWordAgent/ext/resources/alexa.umdl
34-
```
57+
# Please put YOUR_PERSONAL_MODEL.pmdl in $ALEXA_AVS_SAMPLE_APP_PATH/third-party/snowboy/resources,
58+
# and $ALEXA_AVS_SAMPLE_APP_PATH with the actual path where you put the Alexa AVS sample app repository.
59+
60+
cp YOUR_PERSONAL_MODEL.pmdl $ALEXA_AVS_SAMPLE_APP_PATH/third-party/snowboy/resources/
3561
36-
* 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
62+
```
3763

64+
* 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](https://github.com/alexa/avs-device-sdk/blob/master/KWD/KWDProvider/src/KeywordDetectorProvider.cpp) and re-compile
3865
```
39-
# Please replace $ALEXA_AVS_SAMPLE_APP_PATH with the actual path where you
40-
# cloned the Alexa AVS sample app repository.
41-
cd $ALEXA_AVS_SAMPLE_APP_PATH/samples/wakeWordAgent/src/
42-
43-
# Modify KittAiSnowboyWakeWordEngine.cpp and update SENSITIVITY at line 28.
44-
# Modify KittAiSnowboyWakeWordEngine.cpp and set APPLY_FRONTEND to false at
45-
# line 30.
46-
make
66+
# Modify $ALEXA_AVS_SAMPLE_APP_PATH/avs-device-sdk/blob/master/KWD/KWDProvider/src/KeywordDetectorProvider.cpp:
67+
# Replace the model name 'alexa.umdl' with your personal model name 'YOUR_PERSONAL_MODEL.pmdl' at line 52
68+
# Update `KITT_AI_SENSITIVITY` at line 26
69+
# Set `KITT_AI_APPLY_FRONT_END_PROCESSING` to `false` at line 32
70+
sudo bash setup.sh config.json
4771
```
4872

4973
* Run the wake word agent with engine set to `kitt_ai`!
5074

51-
**Universal model**
75+
Here is a [demo video](https://www.youtube.com/watch?v=9Bj8kdfwG7I) for how to use a personal model in Alexa Voice Service.
5276

53-
* Replace the hotword model in [Alexa AVS sample app](https://github.com/alexa/alexa-avs-sample-app) (after installation) with your universal model
77+
**Universal model**
5478

79+
* Put your personal model in [snowboy/resources](https://github.com/Kitt-AI/snowboy/tree/master/resources)
5580
```
56-
# Please replace YOUR_UNIVERSAL_MODEL.umdl with the personal model you just
57-
# created, and $ALEXA_AVS_SAMPLE_APP_PATH with the actual path where you
58-
# cloned the Alexa AVS sample app repository.
59-
cp YOUR_UNIVERSAL_MODEL.umdl $ALEXA_AVS_SAMPLE_APP_PATH/samples/wakeWordAgent/ext/resources/alexa.umdl
60-
```
81+
# Please put YOUR_UNIVERSAL_MODEL.umdl in $ALEXA_AVS_SAMPLE_APP_PATH/third-party/snowboy/resources,
82+
# and $ALEXA_AVS_SAMPLE_APP_PATH with the actual path where you put the Alexa AVS sample app repository.
6183
62-
* 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
84+
cp YOUR_UNIVERSAL_MODEL.umdl $ALEXA_AVS_SAMPLE_APP_PATH/third-party/snowboy/resources/
6385
6486
```
65-
# Please replace $ALEXA_AVS_SAMPLE_APP_PATH with the actual path where you
66-
# cloned the Alexa AVS sample app repository.
67-
cd $ALEXA_AVS_SAMPLE_APP_PATH/samples/wakeWordAgent/src/
6887

69-
# Modify KittAiSnowboyWakeWordEngine.cpp and update SENSITIVITY at line 28.
70-
make
88+
* Replace the model name 'alexa.umdl' with your universal model name, update `KITT_AI_SENSITIVITY` in the [Alexa AVS sample app code](https://github.com/alexa/avs-device-sdk/blob/master/KWD/KWDProvider/src/KeywordDetectorProvider.cpp) and re-compile
89+
```
90+
# Modify $ALEXA_AVS_SAMPLE_APP_PATH/avs-device-sdk/blob/master/KWD/KWDProvider/src/KeywordDetectorProvider.cpp:
91+
# Replace the model name 'alexa.umdl' with your universal model name 'YOUR_UNIVERSAL_MODEL.umdl' at line 52
92+
# Update `KITT_AI_SENSITIVITY` at line 26
93+
sudo bash setup.sh config.json
7194
```
7295

7396
* Run the wake word agent with engine set to `kitt_ai`!
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
diff -Naur avs-sensory/pi.sh avs-kitt/pi.sh
2+
--- pi.sh 2019-05-03 18:09:18.063849909 -0700
3+
+++ pi.sh 2019-05-03 18:09:39.273744305 -0700
4+
@@ -20,18 +20,19 @@
5+
6+
SOUND_CONFIG="$HOME/.asoundrc"
7+
START_SCRIPT="$INSTALL_BASE/startsample.sh"
8+
-CMAKE_PLATFORM_SPECIFIC=(-DSENSORY_KEY_WORD_DETECTOR=ON \
9+
+CMAKE_PLATFORM_SPECIFIC=(-DKITTAI_KEY_WORD_DETECTOR=ON \
10+
-DGSTREAMER_MEDIA_PLAYER=ON -DPORTAUDIO=ON \
11+
-DPORTAUDIO_LIB_PATH="$THIRD_PARTY_PATH/portaudio/lib/.libs/libportaudio.$LIB_SUFFIX" \
12+
-DPORTAUDIO_INCLUDE_DIR="$THIRD_PARTY_PATH/portaudio/include" \
13+
- -DSENSORY_KEY_WORD_DETECTOR_LIB_PATH=$THIRD_PARTY_PATH/alexa-rpi/lib/libsnsr.a \
14+
- -DSENSORY_KEY_WORD_DETECTOR_INCLUDE_DIR=$THIRD_PARTY_PATH/alexa-rpi/include)
15+
+ -DKITTAI_KEY_WORD_DETECTOR_LIB_PATH=$THIRD_PARTY_PATH/snowboy/lib/rpi/libsnowboy-detect.a \
16+
+ -DKITTAI_KEY_WORD_DETECTOR_INCLUDE_DIR=$THIRD_PARTY_PATH/snowboy/include \
17+
+ -DCMAKE_BUILD_TYPE=MINSIZEREL)
18+
19+
GSTREAMER_AUDIO_SINK="alsasink"
20+
21+
install_dependencies() {
22+
sudo apt-get update
23+
- sudo apt-get -y install git gcc cmake build-essential libsqlite3-dev libcurl4-openssl-dev libssl1.0-dev libfaad-dev libsoup2.4-dev libgcrypt20-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-good libasound2-dev sox gedit vim python3-pip
24+
+ sudo apt-get -y install git gcc cmake build-essential libsqlite3-dev libcurl4-openssl-dev libssl1.0-dev libfaad-dev libsoup2.4-dev libgcrypt20-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-good libasound2-dev sox gedit vim python3-pip libatlas-base-dev
25+
pip install flask commentjson
26+
}
27+
28+
@@ -64,18 +65,18 @@
29+
build_kwd_engine() {
30+
#get sensory and build
31+
echo
32+
- echo "==============> CLONING AND BUILDING SENSORY =============="
33+
+ echo "==============> CLONING AND BUILDING KITTAI =============="
34+
echo
35+
36+
cd $THIRD_PARTY_PATH
37+
- git clone git://github.com/Sensory/alexa-rpi.git
38+
- bash ./alexa-rpi/bin/license.sh
39+
+ git clone https://github.com/Kitt-AI/snowboy.git
40+
+ cp snowboy/resources/alexa/alexa-avs-sample-app/alexa.umdl snowboy/resources/alexa.umdl
41+
}
42+
43+
generate_start_script() {
44+
cat << EOF > "$START_SCRIPT"
45+
cd "$BUILD_PATH/SampleApp/src"
46+
47+
- ./SampleApp "$OUTPUT_CONFIG_FILE" "$THIRD_PARTY_PATH/alexa-rpi/models" DEBUG9
48+
+ ./SampleApp "$OUTPUT_CONFIG_FILE" "$THIRD_PARTY_PATH/snowboy/resources" DEBUG9
49+
EOF
50+
}
51+
diff -Naur avs-sensory/setup.sh avs-kitt/setup.sh
52+
--- setup.sh 2019-05-03 18:09:24.383818365 -0700
53+
+++ setup.sh 2019-05-03 18:09:35.193764563 -0700
54+
@@ -50,6 +50,8 @@
55+
LIB_SUFFIX="a"
56+
ANDROID_CONFIG_FILE=""
57+
58+
+BUIDTYPE="MINSIZEREL"
59+
+
60+
# Default device serial number if nothing is specified
61+
DEVICE_SERIAL_NUMBER="123456"
62+
63+
@@ -242,7 +244,7 @@
64+
cmake "$SOURCE_PATH/avs-device-sdk" \
65+
-DCMAKE_BUILD_TYPE=DEBUG \
66+
"${CMAKE_PLATFORM_SPECIFIC[@]}"
67+
-
68+
+ sed -E -i "s:CXX_PLATFORM_DEPENDENT_FLAGS_"$BUILDTYPE"\s+\"(.*)\":CXX_PLATFORM_DEPENDENT_FLAGS_"$BUILDTYPE" \"\1 -D_GLIBCXX_USE_CXX11_ABI=0 -pg\":" ../avs-device-sdk/build/cmake/BuildOptions.cmake
69+
cd $BUILD_PATH
70+
make SampleApp -j1
71+

0 commit comments

Comments
 (0)