PocketSphinx  5prealpha
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 <pocketsphinx_export.h>
#include <cmdln_macro.h>
#include <ps_lattice.h>
#include <ps_mllr.h>
#include <ps_search.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 void ps_default_search_args (cmd_ln_t *)
 Sets default grammar and language model if they are not set explicitly and are present in the default search path.
 
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 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 char * ps_lookup_word (ps_decoder_t *ps, const char *word)
 Lookup for the word in the dictionary and return phone transcription for it. More...
 
POCKETSPHINX_EXPORT long ps_decode_raw (ps_decoder_t *ps, FILE *rawfh, long maxsamps)
 Decode a raw audio stream. More...
 
POCKETSPHINX_EXPORT int ps_decode_senscr (ps_decoder_t *ps, FILE *senfh)
 Decode a senone score dump file. More...
 
POCKETSPHINX_EXPORT int ps_start_stream (ps_decoder_t *ps)
 Start processing of the stream of speech. More...
 
POCKETSPHINX_EXPORT int ps_start_utt (ps_decoder_t *ps)
 Start utterance processing. 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)
 Get hypothesis string and path score. More...
 
POCKETSPHINX_EXPORT int32 ps_get_prob (ps_decoder_t *ps)
 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)
 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)
 Get an iterator over the best hypotheses. 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)
 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...
 
POCKETSPHINX_EXPORT uint8 ps_get_in_speech (ps_decoder_t *ps)
 Checks if the last feed audio buffer contained speech. More...
 
POCKETSPHINX_EXPORT void ps_set_rawdata_size (ps_decoder_t *ps, int32 size)
 Sets the limit of the raw audio data to store in decoder to retrieve it later on ps_get_rawdata. More...
 
POCKETSPHINX_EXPORT void ps_get_rawdata (ps_decoder_t *ps, int16 **buffer, int32 *size)
 Retrieves the raw data collected during utterance decoding. More...
 

Detailed Description

Main header file for the PocketSphinx decoder.

Definition in file pocketsphinx.h.

Function Documentation

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 792 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_decoder_s::searches.

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 407 of file pocketsphinx.c.

Referenced by ps_load_dict().

POCKETSPHINX_EXPORT long ps_decode_raw ( ps_decoder_t ps,
FILE *  rawfh,
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.
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 883 of file pocketsphinx.c.

References ps_end_utt(), ps_process_raw(), ps_start_stream(), and ps_start_utt().

POCKETSPHINX_EXPORT int ps_decode_senscr ( ps_decoder_t ps,
FILE *  senfh 
)

Decode a senone score dump file.

Parameters
psDecoder
fhPreviously opened file handle positioned at start of file.
Returns
Number of frames read.

Definition at line 1036 of file pocketsphinx.c.

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

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 420 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, and ps_decoder_s::refcount.

Referenced by ps_init().

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 1353 of file pocketsphinx.c.

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

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 437 of file pocketsphinx.c.

References ps_decoder_s::config.

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 449 of file pocketsphinx.c.

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

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 455 of file pocketsphinx.c.

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

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

Get hypothesis string and path score.

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

Definition at line 1190 of file pocketsphinx.c.

References ps_decoder_s::perf, and ps_decoder_s::search.

Referenced by ps_end_utt().

POCKETSPHINX_EXPORT uint8 ps_get_in_speech ( ps_decoder_t ps)

Checks if the last feed audio buffer contained speech.

Parameters
psDecoder.
Returns
1 if last buffer contained speech, 0 - otherwise

Definition at line 1365 of file pocketsphinx.c.

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

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 1259 of file pocketsphinx.c.

References ps_decoder_s::search.

Referenced by ps_nbest().

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 443 of file pocketsphinx.c.

References ps_decoder_s::lmath.

Referenced by ps_end_utt().

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 1335 of file pocketsphinx.c.

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

POCKETSPHINX_EXPORT int32 ps_get_prob ( ps_decoder_t ps)

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.
Returns
Posterior probability of the best hypothesis.

Definition at line 1201 of file pocketsphinx.c.

References ps_decoder_s::perf, and ps_decoder_s::search.

POCKETSPHINX_EXPORT void ps_get_rawdata ( ps_decoder_t ps,
int16 **  buffer,
int32 *  size 
)

Retrieves the raw data collected during utterance decoding.

Parameters
psDecoder
bufferpreallocated buffer to store the data, must be within the limit set before
sizesize of the data collected in samples (not bytes).

Definition at line 1446 of file pocketsphinx.c.

References ps_decoder_s::acmod, and acmod_get_rawdata().

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 1341 of file pocketsphinx.c.

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

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 if you are not going to use it elsewere, you can free it.
Parameters
configa command-line structure, as created by cmd_ln_parse_r() or cmd_ln_parse_file_r().

Definition at line 388 of file pocketsphinx.c.

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

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 732 of file pocketsphinx.c.

References ps_decoder_s::acmod, ps_decoder_s::config, ps_decoder_s::d2p, ps_decoder_s::dict, dict2pid_build(), dict2pid_free(), dict_free(), dict_init(), acmod_s::mdef, ps_args(), and ps_decoder_s::searches.

POCKETSPHINX_EXPORT char* ps_lookup_word ( ps_decoder_t ps,
const char *  word 
)

Lookup for the word in the dictionary and return phone transcription for it.

Parameters
psPocketsphinx decoder
wordWord to look for
Returns
Whitespace-spearated phone string describing the pronunciation of the word or NULL if word is not present in the dictionary. The string is allocated and must be freed by the user.

Definition at line 860 of file pocketsphinx.c.

References BAD_S3WID, ps_decoder_s::dict, dict_ciphone_str(), and dict_wordid().

POCKETSPHINX_EXPORT ps_nbest_t* ps_nbest ( ps_decoder_t ps)

Get an iterator over the best hypotheses.

The function may also return a NULL which means that there is no hypothesis available for this utterance.

Parameters
psDecoder.
Returns
Iterator over N-best hypotheses or NULL if no hypothesis is available

Definition at line 1265 of file pocketsphinx.c.

References ps_astar_start(), ps_get_lattice(), ps_nbest_next(), and ps_decoder_s::search.

POCKETSPHINX_EXPORT void ps_nbest_free ( ps_nbest_t nbest)

Finish N-best search early, releasing resources.

Parameters
nbestN-best iterator.

Definition at line 1296 of file pocketsphinx.c.

References ps_astar_finish().

Referenced by ps_nbest_next().

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 1315 of file pocketsphinx.c.

References ps_astar_hyp(), and ps_latpath_s::score.

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 1302 of file pocketsphinx.c.

References ps_astar_next(), and ps_nbest_free().

Referenced by ps_nbest().

POCKETSPHINX_EXPORT ps_seg_t* ps_nbest_seg ( ps_nbest_t nbest)

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 1326 of file pocketsphinx.c.

References ps_astar_seg_iter().

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.
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 1057 of file pocketsphinx.c.

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

Referenced by ps_decode_raw().

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 218 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_build(), dict2pid_free(), dict_free(), dict_init(), ps_decoder_s::lmath, acmod_s::mdef, ps_decoder_s::mfclogdir, ps_decoder_s::perf, ps_decoder_s::phone_loop, ps_set_allphone_file(), ps_set_fsg(), ps_set_jsgf_file(), ps_set_keyphrase(), ps_set_kws(), ps_set_lm(), ps_set_lm_file(), ps_set_search(), ps_decoder_s::rawlogdir, ps_decoder_s::searches, and ps_decoder_s::senlogdir.

Referenced by ps_init().

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 413 of file pocketsphinx.c.

References ps_decoder_s::refcount.

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 785 of file pocketsphinx.c.

References ps_decoder_s::dict, and dict_write().

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 1235 of file pocketsphinx.c.

References ps_search_s::acmod, acmod_stream_offset(), ps_seg_s::ef, ps_seg_s::search, and ps_seg_s::sf.

Referenced by ps_end_utt().

POCKETSPHINX_EXPORT ps_seg_t* ps_seg_iter ( ps_decoder_t ps)

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

Parameters
psDecoder.
Returns
Iterator over the best hypothesis at this point in decoding. NULL if no hypothesis is available.

Definition at line 1212 of file pocketsphinx.c.

References ps_decoder_s::perf, and ps_decoder_s::search.

Referenced by ps_end_utt().

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 1223 of file pocketsphinx.c.

Referenced by ps_end_utt().

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 1244 of file pocketsphinx.c.

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

Referenced by ps_end_utt().

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 1229 of file pocketsphinx.c.

References ps_seg_s::word.

Referenced by ps_end_utt().

POCKETSPHINX_EXPORT void ps_set_rawdata_size ( ps_decoder_t ps,
int32  size 
)

Sets the limit of the raw audio data to store in decoder to retrieve it later on ps_get_rawdata.

Parameters
psDecoder
sizebytes of the utterance to store

Definition at line 1440 of file pocketsphinx.c.

References ps_decoder_s::acmod, and acmod_set_rawdata_size().

POCKETSPHINX_EXPORT int ps_start_stream ( ps_decoder_t ps)

Start processing of the stream of speech.

Channel parameters like noise-level are maintained for the stream and reused among utterances. Times returned in segment iterators are also stream-wide.

Returns
0 for success, <0 on error.

Definition at line 926 of file pocketsphinx.c.

References ps_decoder_s::acmod, and acmod_start_stream().

Referenced by ps_decode_raw().

POCKETSPHINX_EXPORT int ps_start_utt ( ps_decoder_t ps)

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.
Returns
0 for success, <0 on error.

Definition at line 933 of file pocketsphinx.c.

References ps_decoder_s::acmod, ACMOD_PROCESSING, acmod_set_mfcfh(), acmod_set_rawfh(), acmod_set_senfh(), acmod_start_utt(), ACMOD_STARTED, 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, acmod_s::state, and ps_decoder_s::uttno.

Referenced by ps_decode_raw(), and ps_decode_senscr().

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 461 of file pocketsphinx.c.

References ps_decoder_s::acmod, and acmod_update_mllr().