pocketsphinx.h
Go to the documentation of this file.
/* -*- c-basic-offset:4; indent-tabs-mode: nil -*- */
/* ====================================================================
* Copyright (c) 1999-2008 Carnegie Mellon University. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
* ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
*
*/
#ifndef __POCKETSPHINX_H__
#define __POCKETSPHINX_H__
/* System headers we need. */
#include <stdio.h>
/* SphinxBase headers we need. */
#include <sphinxbase/cmd_ln.h>
#include <sphinxbase/logmath.h>
#include <sphinxbase/fe.h>
#include <sphinxbase/feat.h>
/* PocketSphinx headers (not many of them!) */
#include <pocketsphinx_export.h>
#include <cmdln_macro.h>
#include <ps_lattice.h>
#include <ps_mllr.h>
#ifdef __cplusplus
extern "C" {
#endif
#if 0
}
#endif
typedef struct ps_decoder_s ps_decoder_t;
#include <ps_search.h>
typedef struct ps_astar_s ps_nbest_t;
typedef struct ps_seg_s ps_seg_t;
POCKETSPHINX_EXPORT void
ps_default_search_args(cmd_ln_t *);
POCKETSPHINX_EXPORT
ps_decoder_t *ps_init(cmd_ln_t *config);
POCKETSPHINX_EXPORT
int ps_reinit(ps_decoder_t *ps, cmd_ln_t *config);
POCKETSPHINX_EXPORT
arg_t const *ps_args(void);
POCKETSPHINX_EXPORT
ps_decoder_t *ps_retain(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
int ps_free(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
cmd_ln_t *ps_get_config(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
logmath_t *ps_get_logmath(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
fe_t *ps_get_fe(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
feat_t *ps_get_feat(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
ps_mllr_t *ps_update_mllr(ps_decoder_t *ps, ps_mllr_t *mllr);
POCKETSPHINX_EXPORT
int ps_load_dict(ps_decoder_t *ps, char const *dictfile,
char const *fdictfile, char const *format);
POCKETSPHINX_EXPORT
int ps_save_dict(ps_decoder_t *ps, char const *dictfile, char const *format);
POCKETSPHINX_EXPORT
int ps_add_word(ps_decoder_t *ps,
char const *word,
char const *phones,
int update);
POCKETSPHINX_EXPORT
char *ps_lookup_word(ps_decoder_t *ps,
const char *word);
POCKETSPHINX_EXPORT
long ps_decode_raw(ps_decoder_t *ps, FILE *rawfh,
long maxsamps);
POCKETSPHINX_EXPORT
int ps_decode_senscr(ps_decoder_t *ps, FILE *senfh);
POCKETSPHINX_EXPORT
int ps_start_stream(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
int ps_start_utt(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
int ps_process_raw(ps_decoder_t *ps,
int16 const *data,
size_t n_samples,
int no_search,
int full_utt);
POCKETSPHINX_EXPORT
int ps_process_cep(ps_decoder_t *ps,
mfcc_t **data,
int n_frames,
int no_search,
int full_utt);
POCKETSPHINX_EXPORT
int ps_get_n_frames(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
int ps_end_utt(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
char const *ps_get_hyp(ps_decoder_t *ps, int32 *out_best_score);
POCKETSPHINX_EXPORT
int32 ps_get_prob(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
ps_lattice_t *ps_get_lattice(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
ps_seg_t *ps_seg_iter(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
ps_seg_t *ps_seg_next(ps_seg_t *seg);
POCKETSPHINX_EXPORT
char const *ps_seg_word(ps_seg_t *seg);
POCKETSPHINX_EXPORT
void ps_seg_frames(ps_seg_t *seg, int *out_sf, int *out_ef);
POCKETSPHINX_EXPORT
int32 ps_seg_prob(ps_seg_t *seg, int32 *out_ascr, int32 *out_lscr, int32 *out_lback);
POCKETSPHINX_EXPORT
void ps_seg_free(ps_seg_t *seg);
POCKETSPHINX_EXPORT
ps_nbest_t *ps_nbest(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
ps_nbest_t *ps_nbest_next(ps_nbest_t *nbest);
POCKETSPHINX_EXPORT
char const *ps_nbest_hyp(ps_nbest_t *nbest, int32 *out_score);
POCKETSPHINX_EXPORT
ps_seg_t *ps_nbest_seg(ps_nbest_t *nbest);
POCKETSPHINX_EXPORT
void ps_nbest_free(ps_nbest_t *nbest);
POCKETSPHINX_EXPORT
void ps_get_utt_time(ps_decoder_t *ps, double *out_nspeech,
double *out_ncpu, double *out_nwall);
POCKETSPHINX_EXPORT
void ps_get_all_time(ps_decoder_t *ps, double *out_nspeech,
double *out_ncpu, double *out_nwall);
POCKETSPHINX_EXPORT
uint8 ps_get_in_speech(ps_decoder_t *ps);
POCKETSPHINX_EXPORT
void ps_set_rawdata_size(ps_decoder_t *ps, int32 size);
POCKETSPHINX_EXPORT
void ps_get_rawdata(ps_decoder_t *ps, int16 **buffer, int32 *size);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __POCKETSPHINX_H__ */
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.
Definition: pocketsphinx.c:1235
ps_nbest_next
POCKETSPHINX_EXPORT ps_nbest_t * ps_nbest_next(ps_nbest_t *nbest)
Move an N-best list iterator forward.
Definition: pocketsphinx.c:1302
ps_get_feat
POCKETSPHINX_EXPORT feat_t * ps_get_feat(ps_decoder_t *ps)
Get the dynamic feature computation object for this decoder.
Definition: pocketsphinx.c:455
ps_get_rawdata
POCKETSPHINX_EXPORT void ps_get_rawdata(ps_decoder_t *ps, int16 **buffer, int32 *size)
Retrieves the raw data collected during utterance decoding.
Definition: pocketsphinx.c:1446
ps_get_logmath
POCKETSPHINX_EXPORT logmath_t * ps_get_logmath(ps_decoder_t *ps)
Get the log-math computation object for this decoder.
Definition: pocketsphinx.c:443
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.
Definition: pocketsphinx.c:1315
ps_get_in_speech
POCKETSPHINX_EXPORT uint8 ps_get_in_speech(ps_decoder_t *ps)
Checks if the last feed audio buffer contained speech.
Definition: pocketsphinx.c:1365
ps_reinit
POCKETSPHINX_EXPORT int ps_reinit(ps_decoder_t *ps, cmd_ln_t *config)
Reinitialize the decoder with updated configuration.
Definition: pocketsphinx.c:218
ps_decode_raw
POCKETSPHINX_EXPORT long ps_decode_raw(ps_decoder_t *ps, FILE *rawfh, long maxsamps)
Decode a raw audio stream.
Definition: pocketsphinx.c:883
ps_decode_senscr
POCKETSPHINX_EXPORT int ps_decode_senscr(ps_decoder_t *ps, FILE *senfh)
Decode a senone score dump file.
Definition: pocketsphinx.c:1036
ps_set_rawdata_size
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.
Definition: pocketsphinx.c:1440
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.
Definition: pocketsphinx.c:1057
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.
Definition: pocketsphinx.c:785
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.
Definition: pocketsphinx.c:792
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.
Definition: pocketsphinx.c:1353
ps_get_fe
POCKETSPHINX_EXPORT fe_t * ps_get_fe(ps_decoder_t *ps)
Get the feature extraction object for this decoder.
Definition: pocketsphinx.c:449
ps_seg_iter
POCKETSPHINX_EXPORT ps_seg_t * ps_seg_iter(ps_decoder_t *ps)
Get an iterator over the word segmentation for the best hypothesis.
Definition: pocketsphinx.c:1212
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.
Definition: pocketsphinx.c:732
ps_nbest_free
POCKETSPHINX_EXPORT void ps_nbest_free(ps_nbest_t *nbest)
Finish N-best search early, releasing resources.
Definition: pocketsphinx.c:1296
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.
Definition: pocketsphinx.c:461
ps_default_search_args
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...
Definition: pocketsphinx.c:188
ps_start_stream
POCKETSPHINX_EXPORT int ps_start_stream(ps_decoder_t *ps)
Start processing of the stream of speech.
Definition: pocketsphinx.c:926
ps_seg_word
POCKETSPHINX_EXPORT char const * ps_seg_word(ps_seg_t *seg)
Get word string from a segmentation iterator.
Definition: pocketsphinx.c:1229
ps_retain
POCKETSPHINX_EXPORT ps_decoder_t * ps_retain(ps_decoder_t *ps)
Retain a pointer to the decoder.
Definition: pocketsphinx.c:413
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.
Definition: pocketsphinx.c:1341
ps_lookup_word
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.
Definition: pocketsphinx.c:860
ps_end_utt
POCKETSPHINX_EXPORT int ps_end_utt(ps_decoder_t *ps)
End utterance processing.
Definition: pocketsphinx.c:1124
ps_get_n_frames
POCKETSPHINX_EXPORT int ps_get_n_frames(ps_decoder_t *ps)
Get the number of frames of data searched.
Definition: pocketsphinx.c:1335
ps_get_config
POCKETSPHINX_EXPORT cmd_ln_t * ps_get_config(ps_decoder_t *ps)
Get the configuration object for this decoder.
Definition: pocketsphinx.c:437
ps_seg_free
POCKETSPHINX_EXPORT void ps_seg_free(ps_seg_t *seg)
Finish iterating over a word segmentation early, freeing resources.
Definition: pocketsphinx.c:1253
ps_get_lattice
POCKETSPHINX_EXPORT ps_lattice_t * ps_get_lattice(ps_decoder_t *ps)
Get word lattice.
Definition: pocketsphinx.c:1259
ps_get_prob
POCKETSPHINX_EXPORT int32 ps_get_prob(ps_decoder_t *ps)
Get posterior probability.
Definition: pocketsphinx.c:1201
ps_nbest_seg
POCKETSPHINX_EXPORT ps_seg_t * ps_nbest_seg(ps_nbest_t *nbest)
Get the word segmentation from an N-best list iterator.
Definition: pocketsphinx.c:1326
ps_init
POCKETSPHINX_EXPORT ps_decoder_t * ps_init(cmd_ln_t *config)
Initialize the decoder from a configuration object.
Definition: pocketsphinx.c:388
ps_args
POCKETSPHINX_EXPORT arg_t const * ps_args(void)
Returns the argument definitions used in ps_init().
Definition: pocketsphinx.c:407
ps_free
POCKETSPHINX_EXPORT int ps_free(ps_decoder_t *ps)
Finalize the decoder.
Definition: pocketsphinx.c:420
ps_get_hyp
POCKETSPHINX_EXPORT char const * ps_get_hyp(ps_decoder_t *ps, int32 *out_best_score)
Get hypothesis string and path score.
Definition: pocketsphinx.c:1190
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.
ps_start_utt
POCKETSPHINX_EXPORT int ps_start_utt(ps_decoder_t *ps)
Start utterance processing.
Definition: pocketsphinx.c:933
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.
Definition: pocketsphinx.c:1244
ps_seg_next
POCKETSPHINX_EXPORT ps_seg_t * ps_seg_next(ps_seg_t *seg)
Get the next segment in a word segmentation.
Definition: pocketsphinx.c:1223
ps_nbest
POCKETSPHINX_EXPORT ps_nbest_t * ps_nbest(ps_decoder_t *ps)
Get an iterator over the best hypotheses.
Definition: pocketsphinx.c:1265
ps_lattice.h
Word graph search.
ps_mllr.h
Model-space linear transforms for speaker adaptation.
ps_search.h
User can configure several "search" objects with different grammars and langauge models and switch th...
ps_astar_s
A* search structure.
Definition: ps_lattice_internal.h:163
ps_decoder_s
Decoder object.
Definition: pocketsphinx_internal.h:201
ps_lattice_s
Word graph structure used in bestpath/nbest search.
Definition: ps_lattice_internal.h:61
ps_mllr_s
Feature space linear transform structure.
Definition: acmod.h:82
ps_seg_s
Base structure for hypothesis segmentation iterator.
Definition: pocketsphinx_internal.h:178
ps_seg_s::word
char const * word
Word string (pointer into dictionary hash)
Definition: pocketsphinx_internal.h:181