PocketSphinx  0.6
pocketsphinx.h File Reference

Main header file for the PocketSphinx decoder. More...

#include <stdio.h>
#include <sphinxbase/cmd_ln.h>
#include <sphinxbase/logmath.h>
#include <sphinxbase/fe.h>
#include <sphinxbase/feat.h>
#include <sphinxbase/ngram_model.h>
#include <pocketsphinx_export.h>
#include <cmdln_macro.h>
#include <ps_lattice.h>
#include <ps_mllr.h>
#include <fsg_set.h>

Go to the source code of this file.

Typedefs

typedef struct ps_decoder_s ps_decoder_t
 PocketSphinx speech recognizer object.
 
typedef struct ps_astar_s ps_nbest_t
 PocketSphinx N-best hypothesis iterator object.
 
typedef struct ps_seg_s ps_seg_t
 PocketSphinx segmentation iterator object.
 

Functions

POCKETSPHINX_EXPORT ps_decoder_tps_init (cmd_ln_t *config)
 Initialize the decoder from a configuration object. More...
 
POCKETSPHINX_EXPORT int ps_reinit (ps_decoder_t *ps, cmd_ln_t *config)
 Reinitialize the decoder with updated configuration. More...
 
POCKETSPHINX_EXPORT arg_t const * ps_args (void)
 Returns the argument definitions used in ps_init(). More...
 
POCKETSPHINX_EXPORT ps_decoder_tps_retain (ps_decoder_t *ps)
 Retain a pointer to the decoder. More...
 
POCKETSPHINX_EXPORT int ps_free (ps_decoder_t *ps)
 Finalize the decoder. More...
 
POCKETSPHINX_EXPORT cmd_ln_t * ps_get_config (ps_decoder_t *ps)
 Get the configuration object for this decoder. More...
 
POCKETSPHINX_EXPORT logmath_t * ps_get_logmath (ps_decoder_t *ps)
 Get the log-math computation object for this decoder. More...
 
POCKETSPHINX_EXPORT fe_t * ps_get_fe (ps_decoder_t *ps)
 Get the feature extraction object for this decoder. More...
 
POCKETSPHINX_EXPORT feat_t * ps_get_feat (ps_decoder_t *ps)
 Get the dynamic feature computation object for this decoder. More...
 
POCKETSPHINX_EXPORT ps_mllr_tps_update_mllr (ps_decoder_t *ps, ps_mllr_t *mllr)
 Adapt current acoustic model using a linear transform. More...
 
POCKETSPHINX_EXPORT ngram_model_t * ps_get_lmset (ps_decoder_t *ps)
 Get the language model set object for this decoder. More...
 
POCKETSPHINX_EXPORT ngram_model_t * ps_update_lmset (ps_decoder_t *ps, ngram_model_t *lmset)
 Update the language model set object for this decoder. More...
 
POCKETSPHINX_EXPORT fsg_set_tps_get_fsgset (ps_decoder_t *ps)
 Get the finite-state grammar set object for this decoder. More...
 
POCKETSPHINX_EXPORT fsg_set_tps_update_fsgset (ps_decoder_t *ps)
 Update the finite-state grammar set object for this decoder. More...
 
POCKETSPHINX_EXPORT int ps_load_dict (ps_decoder_t *ps, char const *dictfile, char const *fdictfile, char const *format)
 Reload the pronunciation dictionary from a file. More...
 
POCKETSPHINX_EXPORT int ps_save_dict (ps_decoder_t *ps, char const *dictfile, char const *format)
 Dump the current pronunciation dictionary to a file. More...
 
POCKETSPHINX_EXPORT int ps_add_word (ps_decoder_t *ps, char const *word, char const *phones, int update)
 Add a word to the pronunciation dictionary. More...
 
POCKETSPHINX_EXPORT int ps_decode_raw (ps_decoder_t *ps, FILE *rawfh, char const *uttid, long maxsamps)
 Decode a raw audio stream. More...
 
POCKETSPHINX_EXPORT int ps_decode_senscr (ps_decoder_t *ps, FILE *senfh, char const *uttid)
 Decode a senone score dump file. More...
 
POCKETSPHINX_EXPORT int ps_start_utt (ps_decoder_t *ps, char const *uttid)
 Start utterance processing. More...
 
POCKETSPHINX_EXPORT char const * ps_get_uttid (ps_decoder_t *ps)
 Get current utterance ID. More...
 
POCKETSPHINX_EXPORT int ps_process_raw (ps_decoder_t *ps, int16 const *data, size_t n_samples, int no_search, int full_utt)
 Decode raw audio data. More...
 
POCKETSPHINX_EXPORT int ps_process_cep (ps_decoder_t *ps, mfcc_t **data, int n_frames, int no_search, int full_utt)
 Decode acoustic feature data. More...
 
POCKETSPHINX_EXPORT int ps_get_n_frames (ps_decoder_t *ps)
 Get the number of frames of data searched. More...
 
POCKETSPHINX_EXPORT int ps_end_utt (ps_decoder_t *ps)
 End utterance processing. More...
 
POCKETSPHINX_EXPORT char const * ps_get_hyp (ps_decoder_t *ps, int32 *out_best_score, char const **out_uttid)
 Get hypothesis string and path score. More...
 
POCKETSPHINX_EXPORT char const * ps_get_hyp_final (ps_decoder_t *ps, int32 *out_is_final)
 Get hypothesis string and final flag. More...
 
POCKETSPHINX_EXPORT int32 ps_get_prob (ps_decoder_t *ps, char const **out_uttid)
 Get posterior probability. More...
 
POCKETSPHINX_EXPORT ps_lattice_tps_get_lattice (ps_decoder_t *ps)
 Get word lattice. More...
 
POCKETSPHINX_EXPORT ps_seg_tps_seg_iter (ps_decoder_t *ps, int32 *out_best_score)
 Get an iterator over the word segmentation for the best hypothesis. More...
 
POCKETSPHINX_EXPORT ps_seg_tps_seg_next (ps_seg_t *seg)
 Get the next segment in a word segmentation. More...
 
POCKETSPHINX_EXPORT char const * ps_seg_word (ps_seg_t *seg)
 Get word string from a segmentation iterator. More...
 
POCKETSPHINX_EXPORT void ps_seg_frames (ps_seg_t *seg, int *out_sf, int *out_ef)
 Get inclusive start and end frames from a segmentation iterator. More...
 
POCKETSPHINX_EXPORT int32 ps_seg_prob (ps_seg_t *seg, int32 *out_ascr, int32 *out_lscr, int32 *out_lback)
 Get language, acoustic, and posterior probabilities from a segmentation iterator. More...
 
POCKETSPHINX_EXPORT void ps_seg_free (ps_seg_t *seg)
 Finish iterating over a word segmentation early, freeing resources.
 
POCKETSPHINX_EXPORT ps_nbest_tps_nbest (ps_decoder_t *ps, int sf, int ef, char const *ctx1, char const *ctx2)
 Get an iterator over the best hypotheses, optionally within a selected region of the utterance. More...
 
POCKETSPHINX_EXPORT ps_nbest_tps_nbest_next (ps_nbest_t *nbest)
 Move an N-best list iterator forward. More...
 
POCKETSPHINX_EXPORT char const * ps_nbest_hyp (ps_nbest_t *nbest, int32 *out_score)
 Get the hypothesis string from an N-best list iterator. More...
 
POCKETSPHINX_EXPORT ps_seg_tps_nbest_seg (ps_nbest_t *nbest, int32 *out_score)
 Get the word segmentation from an N-best list iterator. More...
 
POCKETSPHINX_EXPORT void ps_nbest_free (ps_nbest_t *nbest)
 Finish N-best search early, releasing resources. More...
 
POCKETSPHINX_EXPORT void ps_get_utt_time (ps_decoder_t *ps, double *out_nspeech, double *out_ncpu, double *out_nwall)
 Get performance information for the current utterance. More...
 
POCKETSPHINX_EXPORT void ps_get_all_time (ps_decoder_t *ps, double *out_nspeech, double *out_ncpu, double *out_nwall)
 Get overall performance information. More...
 

Detailed Description

Main header file for the PocketSphinx decoder.

Definition in file pocketsphinx.h.

Function Documentation

◆ ps_add_word()

POCKETSPHINX_EXPORT int ps_add_word ( ps_decoder_t ps,
char const *  word,
char const *  phones,
int  update 
)

Add a word to the pronunciation dictionary.

This function adds a word to the pronunciation dictionary and the current language model (but, obviously, not to the current FSG if FSG mode is enabled). If the word is already present in one or the other, it does whatever is necessary to ensure that the word can be recognized.

Parameters
wordWord string to add.
phonesWhitespace-separated list of phoneme strings describing pronunciation of word.
updateIf TRUE, update the search module (whichever one is currently active) to recognize the newly added word. If adding multiple words, it is more efficient to pass FALSE here in all but the last word.
Returns
The internal ID (>= 0) of the newly added word, or <0 on failure.

Definition at line 519 of file pocketsphinx.c.

References ps_decoder_s::acmod, bin_mdef_ciphone_id(), ps_decoder_s::d2p, ps_decoder_s::dict, dict2pid_add_word(), dict_add_word(), acmod_s::mdef, and ps_get_lmset().

◆ ps_args()

POCKETSPHINX_EXPORT arg_t const* ps_args ( void  )

Returns the argument definitions used in ps_init().

This is here to avoid exporting global data, which is problematic on Win32 and Symbian (and possibly other platforms).

Definition at line 313 of file pocketsphinx.c.

Referenced by ps_load_dict().

◆ ps_decode_raw()

POCKETSPHINX_EXPORT int ps_decode_raw ( ps_decoder_t ps,
FILE *  rawfh,
char const *  uttid,
long  maxsamps 
)

Decode a raw audio stream.

No headers are recognized in this files. The configuration parameters -samprate and -input_endian are used to determine the sampling rate and endianness of the stream, respectively. Audio is always assumed to be 16-bit signed PCM.

Parameters
psDecoder.
rawfhPreviously opened file stream.
uttidUtterance ID (or NULL to generate automatically).
maxsampsMaximum number of samples to read from rawfh, or -1 to read until end-of-file.
Returns
Number of samples of audio.

Definition at line 580 of file pocketsphinx.c.

References ps_process_raw(), and ps_start_utt().

◆ ps_decode_senscr()

POCKETSPHINX_EXPORT int ps_decode_senscr ( ps_decoder_t ps,
FILE *  senfh,
char const *  uttid 
)

Decode a senone score dump file.

Parameters
psDecoder
senfhPreviously opened file handle positioned at start of file.
uttidUtterance ID (or NULL to generate automatically).
Returns
Number of frames read.

Definition at line 727 of file pocketsphinx.c.

References ps_decoder_s::acmod, acmod_read_scores(), acmod_set_insenfh(), ps_end_utt(), and ps_start_utt().

◆ ps_end_utt()

POCKETSPHINX_EXPORT int ps_end_utt ( ps_decoder_t ps)

End utterance processing.

Parameters
psDecoder.
Returns
0 for success, <0 on error

Definition at line 816 of file pocketsphinx.c.

References ps_decoder_s::acmod, acmod_end_utt(), ps_decoder_s::perf, and ps_decoder_s::phone_loop.

Referenced by ps_decode_senscr().

◆ ps_free()

POCKETSPHINX_EXPORT int ps_free ( ps_decoder_t ps)

Finalize the decoder.

This releases all resources associated with the decoder, including any language models or grammars which have been added to it, and the initial configuration object passed to ps_init().

Parameters
psDecoder to be freed.
Returns
New reference count (0 if freed).

Definition at line 326 of file pocketsphinx.c.

References ps_decoder_s::acmod, acmod_free(), ps_decoder_s::config, ps_decoder_s::d2p, ps_decoder_s::dict, dict2pid_free(), dict_free(), ps_decoder_s::lmath, ps_decoder_s::refcount, and ps_decoder_s::uttid.

Referenced by ps_init().

◆ ps_get_all_time()

POCKETSPHINX_EXPORT void ps_get_all_time ( ps_decoder_t ps,
double *  out_nspeech,
double *  out_ncpu,
double *  out_nwall 
)

Get overall performance information.

Parameters
psDecoder.
out_nspeechOutput: Number of seconds of speech.
out_ncpuOutput: Number of seconds of CPU time used.
out_nwallOutput: Number of seconds of wall time used.

Definition at line 1052 of file pocketsphinx.c.

References ps_decoder_s::config, ps_decoder_s::n_frame, and ps_decoder_s::perf.

◆ ps_get_config()

POCKETSPHINX_EXPORT cmd_ln_t* ps_get_config ( ps_decoder_t ps)

Get the configuration object for this decoder.

Returns
The configuration object for this decoder. The decoder retains ownership of this pointer, so you should not attempt to free it manually. Use cmd_ln_retain() if you wish to reuse it elsewhere.

Definition at line 350 of file pocketsphinx.c.

References ps_decoder_s::config.

◆ ps_get_fe()

POCKETSPHINX_EXPORT fe_t* ps_get_fe ( ps_decoder_t ps)

Get the feature extraction object for this decoder.

Returns
The feature extraction object for this decoder. The decoder retains ownership of this pointer, so you should not attempt to free it manually. Use fe_retain() if you wish to reuse it elsewhere.

Definition at line 362 of file pocketsphinx.c.

References ps_decoder_s::acmod, and acmod_s::fe.

◆ ps_get_feat()

POCKETSPHINX_EXPORT feat_t* ps_get_feat ( ps_decoder_t ps)

Get the dynamic feature computation object for this decoder.

Returns
The dynamic feature computation object for this decoder. The decoder retains ownership of this pointer, so you should not attempt to free it manually. Use feat_retain() if you wish to reuse it elsewhere.

Definition at line 368 of file pocketsphinx.c.

References ps_decoder_s::acmod, and acmod_s::fcb.

◆ ps_get_fsgset()

POCKETSPHINX_EXPORT fsg_set_t* ps_get_fsgset ( ps_decoder_t ps)

Get the finite-state grammar set object for this decoder.

If FSG decoding is not enabled, this returns NULL. Call ps_update_fsgset() to enable it.

Returns
The current FSG set object for this decoder, or NULL if none is available.

Definition at line 423 of file pocketsphinx.c.

References ps_decoder_s::search.

◆ ps_get_hyp()

POCKETSPHINX_EXPORT char const* ps_get_hyp ( ps_decoder_t ps,
int32 *  out_best_score,
char const **  out_uttid 
)

Get hypothesis string and path score.

Parameters
psDecoder.
out_best_scoreOutput: path score corresponding to returned string.
out_uttidOutput: utterance ID for this utterance.
Returns
String containing best hypothesis at this point in decoding. NULL if no hypothesis is available.

Definition at line 872 of file pocketsphinx.c.

References ps_decoder_s::perf.

◆ ps_get_hyp_final()

POCKETSPHINX_EXPORT char const* ps_get_hyp_final ( ps_decoder_t ps,
int32 *  out_is_final 
)

Get hypothesis string and final flag.

Parameters
psDecoder.
out_is_finalOutput: if hypothesis is reached final state in the grammar.
Returns
String containing best hypothesis at this point in decoding. NULL if no hypothesis is available.

Definition at line 885 of file pocketsphinx.c.

References ps_decoder_s::perf.

◆ ps_get_lattice()

POCKETSPHINX_EXPORT ps_lattice_t* ps_get_lattice ( ps_decoder_t ps)

Get word lattice.

There isn't much you can do with this so far, a public API will appear in the future.

Parameters
psDecoder.
Returns
Word lattice object containing all hypotheses so far. NULL if no hypotheses are available. This pointer is owned by the decoder and you should not attempt to free it manually. It is only valid until the next utterance, unless you use ps_lattice_retain() to retain it.

Definition at line 955 of file pocketsphinx.c.

Referenced by ps_nbest().

◆ ps_get_lmset()

POCKETSPHINX_EXPORT ngram_model_t* ps_get_lmset ( ps_decoder_t ps)

Get the language model set object for this decoder.

If N-Gram decoding is not enabled, this will return NULL. You will need to enable it using ps_update_lmset().

Returns
The language model set object for this decoder. The decoder retains ownership of this pointer, so you should not attempt to free it manually. Use ngram_model_retain() if you wish to reuse it elsewhere.

Definition at line 380 of file pocketsphinx.c.

References ps_decoder_s::search.

Referenced by ps_add_word().

◆ ps_get_logmath()

POCKETSPHINX_EXPORT logmath_t* ps_get_logmath ( ps_decoder_t ps)

Get the log-math computation object for this decoder.

Returns
The log-math object for this decoder. The decoder retains ownership of this pointer, so you should not attempt to free it manually. Use logmath_retain() if you wish to reuse it elsewhere.

Definition at line 356 of file pocketsphinx.c.

References ps_decoder_s::lmath.

◆ ps_get_n_frames()

POCKETSPHINX_EXPORT int ps_get_n_frames ( ps_decoder_t ps)

Get the number of frames of data searched.

Note that there is a delay between this and the number of frames of audio which have been input to the system. This is due to the fact that acoustic features are computed using a sliding window of audio, and dynamic features are computed over a sliding window of acoustic features.

Parameters
psDecoder.
Returns
Number of frames of speech data which have been recognized so far.

Definition at line 1034 of file pocketsphinx.c.

References ps_decoder_s::acmod, and acmod_s::output_frame.

◆ ps_get_prob()

POCKETSPHINX_EXPORT int32 ps_get_prob ( ps_decoder_t ps,
char const **  out_uttid 
)

Get posterior probability.

Note
Unless the -bestpath option is enabled, this function will always return zero (corresponding to a posterior probability of 1.0). Even if -bestpath is enabled, it will also return zero when called on a partial result. Ongoing research into effective confidence annotation for partial hypotheses may result in these restrictions being lifted in future versions.
Parameters
psDecoder.
out_uttidOutput: utterance ID for this utterance.
Returns
Posterior probability of the best hypothesis.

Definition at line 897 of file pocketsphinx.c.

References ps_decoder_s::perf.

◆ ps_get_utt_time()

POCKETSPHINX_EXPORT void ps_get_utt_time ( ps_decoder_t ps,
double *  out_nspeech,
double *  out_ncpu,
double *  out_nwall 
)

Get performance information for the current utterance.

Parameters
psDecoder.
out_nspeechOutput: Number of seconds of speech.
out_ncpuOutput: Number of seconds of CPU time used.
out_nwallOutput: Number of seconds of wall time used.

Definition at line 1040 of file pocketsphinx.c.

References ps_decoder_s::acmod, ps_decoder_s::config, acmod_s::output_frame, and ps_decoder_s::perf.

◆ ps_get_uttid()

POCKETSPHINX_EXPORT char const* ps_get_uttid ( ps_decoder_t ps)

Get current utterance ID.

Parameters
psDecoder to query.
Returns
Read-only string of the current utterance ID. This is valid only until the beginning of the next utterance.

Definition at line 344 of file pocketsphinx.c.

References ps_decoder_s::uttid.

◆ ps_init()

POCKETSPHINX_EXPORT ps_decoder_t* ps_init ( cmd_ln_t *  config)

Initialize the decoder from a configuration object.

Note
The decoder retains ownership of the pointer config, so you must not attempt to free it manually. If you wish to reuse it elsewhere, call cmd_ln_retain() on it.
Parameters
configa command-line structure, as created by cmd_ln_parse_r() or cmd_ln_parse_file_r().

Definition at line 299 of file pocketsphinx.c.

References ps_free(), ps_reinit(), and ps_decoder_s::refcount.

◆ ps_load_dict()

POCKETSPHINX_EXPORT int ps_load_dict ( ps_decoder_t ps,
char const *  dictfile,
char const *  fdictfile,
char const *  format 
)

Reload the pronunciation dictionary from a file.

This function replaces the current pronunciation dictionary with the one stored in dictfile. This also causes the active search module(s) to be reinitialized, in the same manner as calling ps_add_word() with update=TRUE.

Parameters
dictfilePath to dictionary file to load.
fdictfilePath to filler dictionary to load, or NULL to keep the existing filler dictionary.
formatFormat of the dictionary file, or NULL to determine automatically (currently unused,should be NULL)

Definition at line 457 of file pocketsphinx.c.

References ps_args().

◆ ps_nbest()

POCKETSPHINX_EXPORT ps_nbest_t* ps_nbest ( ps_decoder_t ps,
int  sf,
int  ef,
char const *  ctx1,
char const *  ctx2 
)

Get an iterator over the best hypotheses, optionally within a selected region of the utterance.

Iterator is empty now, it must be advanced with ps_nbest_next first. The function may also return a NULL which means that there is nohypothesis available for this utterance.

Parameters
psDecoder.
sfStart frame for N-best search (0 for whole utterance)
efEnd frame for N-best search (-1 for whole utterance)
ctx1First word of trigram context (NULL for whole utterance)
ctx2First word of trigram context (NULL for whole utterance)
Returns
Iterator over N-best hypotheses or NULL if no hypothesis is available

Definition at line 961 of file pocketsphinx.c.

References ps_get_lattice(), and ps_decoder_s::search.

◆ ps_nbest_free()

POCKETSPHINX_EXPORT void ps_nbest_free ( ps_nbest_t nbest)

Finish N-best search early, releasing resources.

Parameters
nbestN-best iterator.

Definition at line 995 of file pocketsphinx.c.

References ps_astar_finish().

Referenced by ps_nbest_next().

◆ ps_nbest_hyp()

POCKETSPHINX_EXPORT char const* ps_nbest_hyp ( ps_nbest_t nbest,
int32 *  out_score 
)

Get the hypothesis string from an N-best list iterator.

Parameters
nbestN-best iterator.
out_scoreOutput: Path score for this hypothesis.
Returns
String containing next best hypothesis.

Definition at line 1014 of file pocketsphinx.c.

References ps_astar_hyp(), and ps_latpath_s::score.

◆ ps_nbest_next()

POCKETSPHINX_EXPORT ps_nbest_t* ps_nbest_next ( ps_nbest_t nbest)

Move an N-best list iterator forward.

Parameters
nbestN-best iterator.
Returns
Updated N-best iterator, or NULL if no more hypotheses are available (iterator is freed ni this case).

Definition at line 1001 of file pocketsphinx.c.

References ps_astar_next(), and ps_nbest_free().

◆ ps_nbest_seg()

POCKETSPHINX_EXPORT ps_seg_t* ps_nbest_seg ( ps_nbest_t nbest,
int32 *  out_score 
)

Get the word segmentation from an N-best list iterator.

Parameters
nbestN-best iterator.
out_scoreOutput: Path score for this hypothesis.
Returns
Iterator over the next best hypothesis.

Definition at line 1025 of file pocketsphinx.c.

References ps_astar_seg_iter(), and ps_latpath_s::score.

◆ ps_process_cep()

POCKETSPHINX_EXPORT int ps_process_cep ( ps_decoder_t ps,
mfcc_t **  data,
int  n_frames,
int  no_search,
int  full_utt 
)

Decode acoustic feature data.

Parameters
psDecoder.
no_searchIf non-zero, perform feature extraction but don't do any recognition yet. This may be necessary if your processor has trouble doing recognition in real-time.
full_uttIf non-zero, this block of data is a full utterance worth of data. This may allow the recognizer to produce more accurate results.
Returns
Number of frames of data searched, or <0 for error.

◆ ps_process_raw()

POCKETSPHINX_EXPORT int ps_process_raw ( ps_decoder_t ps,
int16 const *  data,
size_t  n_samples,
int  no_search,
int  full_utt 
)

Decode raw audio data.

Parameters
psDecoder.
no_searchIf non-zero, perform feature extraction but don't do any recognition yet. This may be necessary if your processor has trouble doing recognition in real-time.
full_uttIf non-zero, this block of data is a full utterance worth of data. This may allow the recognizer to produce more accurate results.
Returns
Number of frames of data searched, or <0 for error.

Definition at line 749 of file pocketsphinx.c.

References ps_decoder_s::acmod, ACMOD_IDLE, acmod_set_grow(), and acmod_s::state.

Referenced by ps_decode_raw().

◆ ps_reinit()

POCKETSPHINX_EXPORT int ps_reinit ( ps_decoder_t ps,
cmd_ln_t *  config 
)

Reinitialize the decoder with updated configuration.

This function allows you to switch the acoustic model, dictionary, or other configuration without creating an entirely new decoding object.

Note
The decoder retains ownership of the pointer config, so you must not attempt to free it manually. If you wish to reuse it elsewhere, call cmd_ln_retain() on it.
Parameters
psDecoder.
configAn optional new configuration to use. If this is NULL, the previous configuration will be reloaded, with any changes applied.
Returns
0 for success, <0 for failure.

Definition at line 193 of file pocketsphinx.c.

References ps_decoder_s::acmod, acmod_free(), acmod_init(), ps_decoder_s::config, ps_decoder_s::d2p, ps_decoder_s::dict, dict2pid_free(), dict_free(), ps_decoder_s::lmath, ps_decoder_s::mfclogdir, ps_decoder_s::phone_loop, ps_decoder_s::pl_window, ps_decoder_s::rawlogdir, and ps_decoder_s::senlogdir.

Referenced by ps_init().

◆ ps_retain()

POCKETSPHINX_EXPORT ps_decoder_t* ps_retain ( ps_decoder_t ps)

Retain a pointer to the decoder.

This increments the reference count on the decoder, allowing it to be shared between multiple parent objects. In general you will not need to use this function, ever. It is mainly here for the convenience of scripting language bindings.

Returns
pointer to retained decoder.

Definition at line 319 of file pocketsphinx.c.

References ps_decoder_s::refcount.

◆ ps_save_dict()

POCKETSPHINX_EXPORT int ps_save_dict ( ps_decoder_t ps,
char const *  dictfile,
char const *  format 
)

Dump the current pronunciation dictionary to a file.

This function dumps the current pronunciation dictionary to a tex

Parameters
dictfilePath to file where dictionary will be written.
formatFormat of the dictionary file, or NULL for the default (text) format (currently unused, should be NULL)

Definition at line 512 of file pocketsphinx.c.

References ps_decoder_s::dict, and dict_write().

◆ ps_seg_frames()

POCKETSPHINX_EXPORT void ps_seg_frames ( ps_seg_t seg,
int *  out_sf,
int *  out_ef 
)

Get inclusive start and end frames from a segmentation iterator.

Note
These frame numbers are inclusive, i.e. the end frame refers to the last frame in which the given word or other segment was active. Therefore, the actual duration is *out_ef - *out_sf + 1.
Parameters
segSegment iterator.
out_sfOutput: First frame index in segment.
out_sfOutput: Last frame index in segment.

Definition at line 933 of file pocketsphinx.c.

References ps_seg_s::ef, and ps_seg_s::sf.

◆ ps_seg_iter()

POCKETSPHINX_EXPORT ps_seg_t* ps_seg_iter ( ps_decoder_t ps,
int32 *  out_best_score 
)

Get an iterator over the word segmentation for the best hypothesis.

Parameters
psDecoder.
out_best_scoreOutput: path score corresponding to hypothesis.
Returns
Iterator over the best hypothesis at this point in decoding. NULL if no hypothesis is available.

Definition at line 910 of file pocketsphinx.c.

References ps_decoder_s::perf.

◆ ps_seg_next()

POCKETSPHINX_EXPORT ps_seg_t* ps_seg_next ( ps_seg_t seg)

Get the next segment in a word segmentation.

Parameters
segSegment iterator.
Returns
Updated iterator with the next segment. NULL at end of utterance (the iterator will be freed in this case).

Definition at line 921 of file pocketsphinx.c.

◆ ps_seg_prob()

POCKETSPHINX_EXPORT int32 ps_seg_prob ( ps_seg_t seg,
int32 *  out_ascr,
int32 *  out_lscr,
int32 *  out_lback 
)

Get language, acoustic, and posterior probabilities from a segmentation iterator.

Note
Unless the -bestpath option is enabled, this function will always return zero (corresponding to a posterior probability of 1.0). Even if -bestpath is enabled, it will also return zero when called on a partial result. Ongoing research into effective confidence annotation for partial hypotheses may result in these restrictions being lifted in future versions.
Parameters
out_ascrOutput: acoustic model score for this segment.
out_lscrOutput: language model score for this segment.
out_lbackOutput: language model backoff mode for this segment (i.e. the number of words used in calculating lscr). This field is, of course, only meaningful for N-Gram models.
Returns
Log posterior probability of current segment. Log is expressed in the log-base used in the decoder. To convert to linear floating-point, use logmath_exp(ps_get_logmath(), pprob).

Definition at line 940 of file pocketsphinx.c.

References ps_seg_s::ascr, ps_seg_s::lback, ps_seg_s::lscr, and ps_seg_s::prob.

◆ ps_seg_word()

POCKETSPHINX_EXPORT char const* ps_seg_word ( ps_seg_t seg)

Get word string from a segmentation iterator.

Parameters
segSegment iterator.
Returns
Read-only string giving string name of this segment. This is only valid until the next call to ps_seg_next().

Definition at line 927 of file pocketsphinx.c.

References ps_seg_s::word.

◆ ps_start_utt()

POCKETSPHINX_EXPORT int ps_start_utt ( ps_decoder_t ps,
char const *  uttid 
)

Start utterance processing.

This function should be called before any utterance data is passed to the decoder. It marks the start of a new utterance and reinitializes internal data structures.

Parameters
psDecoder to be started.
uttidString uniquely identifying this utterance. If NULL, one will be created.
Returns
0 for success, <0 on error.

Definition at line 621 of file pocketsphinx.c.

References ps_decoder_s::acmod, acmod_set_mfcfh(), acmod_set_rawfh(), acmod_set_senfh(), acmod_start_utt(), ps_search_s::dag, ps_search_s::hyp_str, ps_search_s::last_link, ps_decoder_s::mfclogdir, ps_decoder_s::perf, ps_decoder_s::phone_loop, ps_search_s::post, ps_lattice_free(), ps_decoder_s::rawlogdir, ps_decoder_s::search, ps_decoder_s::senlogdir, ps_decoder_s::uttid, and ps_decoder_s::uttno.

Referenced by ps_decode_raw(), and ps_decode_senscr().

◆ ps_update_fsgset()

POCKETSPHINX_EXPORT fsg_set_t* ps_update_fsgset ( ps_decoder_t ps)

Update the finite-state grammar set object for this decoder.

This function does several things. Most importantly, it enables FSG decoding if not currently enabled. It also updates internal data structures to reflect any changes made to the FSG set.

Returns
The current FSG set object for this decoder, or NULL on failure.

Definition at line 432 of file pocketsphinx.c.

References ps_decoder_s::acmod, ps_decoder_s::config, ps_decoder_s::d2p, ps_decoder_s::dict, ps_decoder_s::phone_loop, ps_search_s::pls, and ps_decoder_s::searches.

◆ ps_update_lmset()

POCKETSPHINX_EXPORT ngram_model_t* ps_update_lmset ( ps_decoder_t ps,
ngram_model_t *  lmset 
)

Update the language model set object for this decoder.

This function does several things. Most importantly, it enables N-Gram decoding if not currently enabled. It also updates internal data structures to reflect any changes made to the language model set (e.g. switching language models, adding words, etc).

Parameters
lmsetThe new lmset to use, or NULL to update the existing lmset. The decoder retains ownership of this pointer, so you should not attempt to free it manually. Use ngram_model_retain() if you wish to reuse it elsewhere.
Returns
The updated language model set object for this decoder, or NULL on failure.

Definition at line 389 of file pocketsphinx.c.

References ps_decoder_s::acmod, ps_decoder_s::config, ps_decoder_s::d2p, ps_decoder_s::dict, ngram_search_s::lmset, ngram_search_init(), ps_decoder_s::phone_loop, ps_search_s::pls, and ps_decoder_s::searches.

◆ ps_update_mllr()

POCKETSPHINX_EXPORT ps_mllr_t* ps_update_mllr ( ps_decoder_t ps,
ps_mllr_t mllr 
)

Adapt current acoustic model using a linear transform.

Parameters
mllrThe new transform to use, or NULL to update the existing transform. The decoder retains ownership of this pointer, so you should not attempt to free it manually. Use ps_mllr_retain() if you wish to reuse it elsewhere.
Returns
The updated transform object for this decoder, or NULL on failure.

Definition at line 374 of file pocketsphinx.c.

References ps_decoder_s::acmod, and acmod_update_mllr().