| 1 |
PocketSphinx Examples |
| 2 |
===================== |
| 3 |
|
| 4 |
This directory contains some examples of basic PocketSphinx library |
| 5 |
usage in C and Python. To compile the C examples, you can build the |
| 6 |
target `examples`. If you want to see how it works manually, either |
| 7 |
use the library directly in-place, for example, with `simple.c`: |
| 8 |
|
| 9 |
cmake -DBUILD_SHARED_LIBS=OFF .. && make |
| 10 |
cc -o simple simple.c -I../include -Iinclude -L. -lpocketsphinx -lm |
| 11 |
|
| 12 |
Or if PocketSphinx is installed: |
| 13 |
|
| 14 |
cc -o simple simple.c $(pkg-config --static --libs --cflags pocketsphinx) |
| 15 |
|
| 16 |
If PocketSphinx has not been installed, you will need to set the |
| 17 |
`POCKETSPHINX_PATH` environment variable to run the examples: |
| 18 |
|
| 19 |
POCKETSPHINX_PATH=../model ./simple |
| 20 |
|
| 21 |
The Python scripts, assuming you have installed the `pocketsphinx` |
| 22 |
module (see [the top-leve README](../README.md) for instructions), can |
| 23 |
just be run as-is: |
| 24 |
|
| 25 |
python simple.py spam.wav |
| 26 |
|
| 27 |
Simplest possible example |
| 28 |
------------------------- |
| 29 |
|
| 30 |
The examples `simple.c` and `simple.py` read an entire audio file |
| 31 |
(only WAV files are supported) and recognize it as a single, possibly |
| 32 |
long, utterance. |
| 33 |
|
| 34 |
Segmentation |
| 35 |
------------ |
| 36 |
|
| 37 |
The example `segment.py` uses voice activity detection to *segment* |
| 38 |
the input stream into speech-like regions. |
| 39 |
|
| 40 |
Live recognition |
| 41 |
---------------- |
| 42 |
|
| 43 |
Finally, the examples `live.c` and `live.py` do online segmentation |
| 44 |
and recognition. |