jasperproject/jasper-client — pull request #181 by Holzhaus (2014-09-17 17:07:34+00:00)
Title: Rewrite of vocabcompiler

- Separated generic code from pocketsphinx logic
- Using OOP so that code can be reused for other STT engines, too
- The pocketsphinx part of vocabcompiler now uses the `cmuclmtk` wrapper libary for compilation of the languagemodel/dictionary.
- A revision check has been implemented, so that vocabulary won't get recompiled if there's no need.
- Proper integration into jasper.py, client/stt.py and client/test.py is still missing due to pending pull requests that change these modules.

Please have a look and execute this module directly:
```
$ JASPER_HOME=~/Projekte python2 client/vocabcompiler.py --base-dir=/tmp
Module phrases: ['BIRTHDAY', 'EMAIL', 'FACEBOOK', 'FIRST', 'HACKER', 'INBOX', 'JOKE', 'KNOCK KNOCK', 'LIFE', 'MEANING', 'MUSIC', 'NEWS', 'NO', 'NOTIFICATION', 'OF', 'SECOND', 'SPOTIFY', 'THIRD', 'TIME', 'TODAY', 'TOMORROW', 'WEATHER', 'YES']
Vocabulary in: /tmp/pocketsphinx-vocabulary/default
Revision file: /tmp/pocketsphinx-vocabulary/default/revision
Compiled revision: None
Is compiled: False
Matches phrases: False
Compiling...

idngram2lm : Done.

Vocabulary in: /tmp/pocketsphinx-vocabulary/default
Revision file: /tmp/pocketsphinx-vocabulary/default/revision
Compiled revision: 8c0e66f387b7177205726ecfcb3edd9df0d23653
Is compiled: True
Matches phrases: True

$ JASPER_HOME=~/Projekte python2 client/vocabcompiler.py --base-dir=/tmp
Module phrases: ['BIRTHDAY', 'EMAIL', 'FACEBOOK', 'FIRST', 'HACKER', 'INBOX', 'JOKE', 'KNOCK KNOCK', 'LIFE', 'MEANING', 'MUSIC', 'NEWS', 'NO', 'NOTIFICATION', 'OF', 'SECOND', 'SPOTIFY', 'THIRD', 'TIME', 'TODAY', 'TOMORROW', 'WEATHER', 'YES']
Vocabulary in: /tmp/pocketsphinx-vocabulary/default
Revision file: /tmp/pocketsphinx-vocabulary/default/revision
Compiled revision: 8c0e66f387b7177205726ecfcb3edd9df0d23653
Is compiled: True
Matches phrases: True
```

As you can see, the instance detects that has already been compiled and that it's still up-to-date, so that recompilation is not neccessary and therefore skipped.