Files
Kevin Lenzo 69185976d2 Add external timestamp support to endpointer to prevent clock drift
- Added ps_endpointer_timestamp_cb_t callback type for external timestamps
- Added ps_endpointer_set_timestamp_func() to set external timestamp source
- Added ps_endpointer_timestamp() to get current timestamp
- Modified internal timestamp handling to use callback when available
- Maintains full backward compatibility - existing code works unchanged
- Added comprehensive test suite (test_endpointer_timestamp)
- Added example program demonstrating the new functionality

This addresses issue #352 by allowing applications to provide their own
timestamp source (e.g., system time, monotonic clock) to avoid drift
between audio clock and system clock. The implementation maintains the
audio-based timestamp tracking internally for queue management while
using the external source for speech start/end timestamps when provided.
2025-07-16 15:21:00 -04:00
..
2022-10-04 15:18:23 -04:00

PocketSphinx Examples

This directory contains some examples of basic PocketSphinx library usage in C and Python. To compile the C examples, you can build the target examples. If you want to see how it works manually, either use the library directly in-place, for example, with simple.c:

cmake -DBUILD_SHARED_LIBS=OFF .. && make
cc -o simple simple.c -I../include -Iinclude -L. -lpocketsphinx -lm

Or if PocketSphinx is installed:

cc -o simple simple.c $(pkg-config --static --libs --cflags pocketsphinx)

If PocketSphinx has not been installed, you will need to set the POCKETSPHINX_PATH environment variable to run the examples:

POCKETSPHINX_PATH=../model ./simple

The Python scripts, assuming you have installed the pocketsphinx module (see the top-leve README for instructions), can just be run as-is:

python simple.py spam.wav

Simplest possible example

The examples simple.c and simple.py read an entire audio file (only WAV files are supported) and recognize it as a single, possibly long, utterance.

Segmentation

The example segment.py uses voice activity detection to segment the input stream into speech-like regions.

Live recognition

Finally, the examples live.c and live.py do online segmentation and recognition.