Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate model in comand line #2

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
56 changes: 52 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,27 @@ git https://github.com/matrix-io/matrix-creator-pocketsphinx.git
cd matrix-creator-pocketsphinx
mkdir build && cd build && cmake .. && make
```
### Model File

### Install testing voice commands:
#### Option 1

#### Install testing voice commands:
Download sample language and dictionary from [here](https://drive.google.com/file/d/0B3lA7p7SjZu-YUJxYmIwcnh4Qlk/view?usp=sharing) or make new models (explanation below) then extract it:
```
cd demos
mkdir assets
tar xf TAR6706.tgz -C assets
```

### Run DEMO:
#### Run DEMO:
on build/demos:
```
./pocketsphinx_demo -keyphrase "MATRIX" -kws_threshold 1e-20 -dict assets/6706.dic -lm assets/6706.lm -inmic yes -adcdev mic_channel8
```
- *mic_channel8* (all microphones array)
- *mic_channelX* (only X microphone)

#### (optional) Custom lenguage and phrases for recognition
##### (optional) Custom lenguage and phrases for recognition

+ Make a text plane like this:
```
Expand Down Expand Up @@ -68,5 +71,50 @@ matrix ten minutes

+ Upload this file to [Sphinx Knowledge Base Tool](http://www.speech.cs.cmu.edu/tools/lmtool-new.html) and compile knowledge base.

+ Dowload *TARXXXXX.tgz* and upgrade assets:
+ Dowload *TARXXXXX.tgz* and upgrade assets:


### Option 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

markdown heading not match with "Option 1"

#### Generate the model

##### Install srilm in your computer
- Download in http://www.speech.sri.com/projects/srilm/download.html

- If your computer is linux or mac:

```
mkdir /usr/share/srilm
mv srilm.tgz /usr/share/srilm
cd /usr/share/srilm
tar xzf srilm.tgz
sudo apt-get install tcl tcl-dev csh gawk
```
- In Makefile, uncomment the SRILM= parameter and point it to /usr/share/srilm (or your equivalent path)
- Add the following to your .bashrc

```
SRILM=/usr/share/srilm
export PATH=$PATH:$SRILM/bin:$SRILM/bin/i686-ubuntu
export MANPATH=$SRILM/man:$MANPATH
```
- reference : http://www.spencegreen.com/2012/02/01/installing-srilm-on-ubuntu-11-10/

##### Generate the model with srilm

```
cd /folder/where/your/text/is
ngram-count -order 2 -interpolate -cdiscount1 0 -cdiscount2 0.5 -text train-text.txt -lm model.lm
```
- Your train-text should be like the train-text in the folder config
- Move the model.lm to /home/pi/matrix-creator-pocketsphinx/build/demos IN YOUR MATRIX

#### Run DEMO:
on build/demos:
```
./pocketsphinx_demo -keyphrase "MATRIX" -kws_threshold 1e-20 -lm assets/model.lm -inmic yes -adcdev mic_channel8
```
- *mic_channel8* (all microphones array)
- *mic_channelX* (only X microphone)



21 changes: 21 additions & 0 deletions config/train-text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<s> matrix </s>
<s> everloop </s>
<s> arc </s>
<s> clear </s>
<s> stop </s>
<s> shutdown </s>
<s> now </s>
<s> ipaddress </s>
<s> matrix everloop </s>
<s> matrix clear </s>
<s> matrix stop </s>
<s> matrix ipaddress </s>
<s> matrix game time </s>
<s> matrix one minute </s>
<s> matrix two minutes </s>
<s> matrix three minutes </s>
<s> matrix four minutes </s>
<s> matrix five minutes </s>
<s> matrix ten seconds </s>
<s> matrix ten minutes </s>
<s> matrix brazil </s>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a generated file or user file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the file that will used to generate the model

5 changes: 5 additions & 0 deletions demos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ set_property(TARGET uv_demo PROPERTY CXX_STANDARD 11)
target_link_libraries(uv_demo matrix_creator_hal)
target_link_libraries(uv_demo ${CMAKE_THREAD_LIBS_INIT})

add_executable(brazil_demo brazil_demo.cpp)
set_property(TARGET brazil_demo PROPERTY CXX_STANDARD 11)
target_link_libraries(brazil_demo matrix_creator_hal)
target_link_libraries(brazil_demo ${CMAKE_THREAD_LIBS_INIT})

add_executable(clear_demo clear_demo.cpp)
set_property(TARGET clear_demo PROPERTY CXX_STANDARD 11)
target_link_libraries(clear_demo matrix_creator_hal)
Expand Down
57 changes: 57 additions & 0 deletions demos/brazil_demo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2016 <Admobilize>
* MATRIX Labs [http://creator.matrix.one]
* This file is part of MATRIX Creator HAL
*
* MATRIX Creator HAL is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <unistd.h>
#include <iostream>

#include "matrix_hal/everloop_image.h"
#include "matrix_hal/everloop.h"
#include "matrix_hal/wishbone_bus.h"

namespace hal = matrix_hal;

int main() {
hal::WishboneBus bus;

bus.SpiInit();

hal::Everloop everloop;
hal::EverloopImage image1d;

everloop.Setup(&bus);

for (hal::LedValue& led : image1d.leds) {
led.red = 0;
led.green = 0;
led.blue = 0;
led.white = 0;
}

for (int i = 0; i < 12; ++i){
image1d.leds[i].green = 20;
}
for (int i = 12; i < 23; ++i){
image1d.leds[i].white = 20;
}
for (int i = 23; i < 35; ++i){
image1d.leds[i].blue = 20;
}

everloop.Write(&image1d);

return 0;
}
3 changes: 3 additions & 0 deletions demos/pocketsphinx_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ static cmd_ln_t *config_;

void process_rules(const char *hyp) {
const std::string cmd_ever = "./everloop_demo &";
const std::string cmd_br = "./brazil_demo &";
const std::string cmd_arc = "./arc_demo &";
const std::string cmd_ipaddr = "./ipaddress_demo &";
const std::string cmd_clear = "./clear_demo &";
Expand All @@ -92,6 +93,8 @@ void process_rules(const char *hyp) {
printf("match: %s\n", hyp);
if (std::strcmp(hyp, "MATRIX EVERLOOP") == 0)
system(cmd_ever.c_str());
if (std::strcmp(hyp, "MATRIX BRAZIL") == 0)
system(cmd_br.c_str());
if (std::strcmp(hyp, "MATRIX ARC") == 0)
system(cmd_arc.c_str());
if (std::strcmp(hyp, "MATRIX STOP") == 0)
Expand Down