PocketSphinx  0.6
include/pocketsphinx.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset:4; indent-tabs-mode: nil -*- */
00002 /* ====================================================================
00003  * Copyright (c) 1999-2008 Carnegie Mellon University.  All rights
00004  * reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer. 
00012  *
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in
00015  *    the documentation and/or other materials provided with the
00016  *    distribution.
00017  *
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
00020  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
00021  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00022  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
00023  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00024  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00025  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00026  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
00027  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00028  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00029  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  *
00031  * ====================================================================
00032  *
00033  */
00038 #ifndef __POCKETSPHINX_H__
00039 #define __POCKETSPHINX_H__
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 #if 0
00045 }
00046 #endif
00047 
00048 /* System headers we need. */
00049 #include <stdio.h>
00050 
00051 /* SphinxBase headers we need. */
00052 #include <sphinxbase/cmd_ln.h>
00053 #include <sphinxbase/logmath.h>
00054 #include <sphinxbase/fe.h>
00055 #include <sphinxbase/feat.h>
00056 #include <sphinxbase/ngram_model.h>
00057 
00058 /* PocketSphinx headers (not many of them!) */
00059 #include <pocketsphinx_export.h>
00060 #include <cmdln_macro.h>
00061 #include <ps_lattice.h>
00062 #include <ps_mllr.h>
00063 #include <fsg_set.h>
00064 
00068 typedef struct ps_decoder_s ps_decoder_t;
00069 
00073 typedef struct ps_astar_s ps_nbest_t;
00074 
00078 typedef struct ps_seg_s ps_seg_t;
00079 
00090 POCKETSPHINX_EXPORT
00091 ps_decoder_t *ps_init(cmd_ln_t *config);
00092 
00110 POCKETSPHINX_EXPORT
00111 int ps_reinit(ps_decoder_t *ps, cmd_ln_t *config);
00112 
00119 POCKETSPHINX_EXPORT
00120 arg_t const *ps_args(void);
00121 
00132 POCKETSPHINX_EXPORT
00133 ps_decoder_t *ps_retain(ps_decoder_t *ps);
00134 
00145 POCKETSPHINX_EXPORT
00146 int ps_free(ps_decoder_t *ps);
00147 
00156 POCKETSPHINX_EXPORT
00157 cmd_ln_t *ps_get_config(ps_decoder_t *ps);
00158 
00167 POCKETSPHINX_EXPORT
00168 logmath_t *ps_get_logmath(ps_decoder_t *ps);
00169 
00178 POCKETSPHINX_EXPORT
00179 fe_t *ps_get_fe(ps_decoder_t *ps);
00180 
00189 POCKETSPHINX_EXPORT
00190 feat_t *ps_get_feat(ps_decoder_t *ps);
00191 
00203 POCKETSPHINX_EXPORT
00204 ps_mllr_t *ps_update_mllr(ps_decoder_t *ps, ps_mllr_t *mllr);
00205 
00217 POCKETSPHINX_EXPORT
00218 ngram_model_t *ps_get_lmset(ps_decoder_t *ps);
00219 
00236 POCKETSPHINX_EXPORT
00237 ngram_model_t *ps_update_lmset(ps_decoder_t *ps, ngram_model_t *lmset);
00238 
00248 POCKETSPHINX_EXPORT
00249 fsg_set_t *ps_get_fsgset(ps_decoder_t *ps);
00250 
00261 POCKETSPHINX_EXPORT
00262 fsg_set_t *ps_update_fsgset(ps_decoder_t *ps);
00263 
00278 POCKETSPHINX_EXPORT
00279 int ps_load_dict(ps_decoder_t *ps, char const *dictfile,
00280                  char const *fdictfile, char const *format);
00281 
00291 POCKETSPHINX_EXPORT
00292 int ps_save_dict(ps_decoder_t *ps, char const *dictfile, char const *format);
00293 
00313 POCKETSPHINX_EXPORT
00314 int ps_add_word(ps_decoder_t *ps,
00315                 char const *word,
00316                 char const *phones,
00317                 int update);
00318 
00334 POCKETSPHINX_EXPORT
00335 int ps_decode_raw(ps_decoder_t *ps, FILE *rawfh,
00336                   char const *uttid, long maxsamps);
00337 
00346 POCKETSPHINX_EXPORT
00347 int ps_decode_senscr(ps_decoder_t *ps, FILE *senfh,
00348                      char const *uttid);
00349 
00362 POCKETSPHINX_EXPORT
00363 int ps_start_utt(ps_decoder_t *ps, char const *uttid);
00364 
00372 POCKETSPHINX_EXPORT
00373 char const *ps_get_uttid(ps_decoder_t *ps);
00387 POCKETSPHINX_EXPORT
00388 int ps_process_raw(ps_decoder_t *ps,
00389                    int16 const *data,
00390                    size_t n_samples,
00391                    int no_search,
00392                    int full_utt);
00393 
00407 POCKETSPHINX_EXPORT
00408 int ps_process_cep(ps_decoder_t *ps,
00409                    mfcc_t **data,
00410                    int n_frames,
00411                    int no_search,
00412                    int full_utt);
00413 
00427 POCKETSPHINX_EXPORT
00428 int ps_get_n_frames(ps_decoder_t *ps);
00429 
00436 POCKETSPHINX_EXPORT
00437 int ps_end_utt(ps_decoder_t *ps);
00438 
00448 POCKETSPHINX_EXPORT
00449 char const *ps_get_hyp(ps_decoder_t *ps, int32 *out_best_score,
00450                        char const **out_uttid);
00451 
00466 POCKETSPHINX_EXPORT
00467 int32 ps_get_prob(ps_decoder_t *ps, char const **out_uttid);
00468 
00482 POCKETSPHINX_EXPORT
00483 ps_lattice_t *ps_get_lattice(ps_decoder_t *ps);
00484 
00493 POCKETSPHINX_EXPORT
00494 ps_seg_t *ps_seg_iter(ps_decoder_t *ps, int32 *out_best_score);
00495 
00503 POCKETSPHINX_EXPORT
00504 ps_seg_t *ps_seg_next(ps_seg_t *seg);
00505 
00513 POCKETSPHINX_EXPORT
00514 char const *ps_seg_word(ps_seg_t *seg);
00515 
00527 POCKETSPHINX_EXPORT
00528 void ps_seg_frames(ps_seg_t *seg, int *out_sf, int *out_ef);
00529 
00552 POCKETSPHINX_EXPORT
00553 int32 ps_seg_prob(ps_seg_t *seg, int32 *out_ascr, int32 *out_lscr, int32 *out_lback);
00554 
00558 POCKETSPHINX_EXPORT
00559 void ps_seg_free(ps_seg_t *seg);
00560 
00572 POCKETSPHINX_EXPORT
00573 ps_nbest_t *ps_nbest(ps_decoder_t *ps, int sf, int ef,
00574                      char const *ctx1, char const *ctx2);
00575 
00583 POCKETSPHINX_EXPORT 
00584 ps_nbest_t *ps_nbest_next(ps_nbest_t *nbest);
00585 
00593 POCKETSPHINX_EXPORT
00594 char const *ps_nbest_hyp(ps_nbest_t *nbest, int32 *out_score);
00595 
00603 POCKETSPHINX_EXPORT
00604 ps_seg_t *ps_nbest_seg(ps_nbest_t *nbest, int32 *out_score);
00605 
00611 POCKETSPHINX_EXPORT
00612 void ps_nbest_free(ps_nbest_t *nbest);
00613 
00622 POCKETSPHINX_EXPORT
00623 void ps_get_utt_time(ps_decoder_t *ps, double *out_nspeech,
00624                      double *out_ncpu, double *out_nwall);
00625 
00634 POCKETSPHINX_EXPORT
00635 void ps_get_all_time(ps_decoder_t *ps, double *out_nspeech,
00636                      double *out_ncpu, double *out_nwall);
00637 
00651 #ifdef __cplusplus
00652 } /* extern "C" */
00653 #endif
00654 
00655 #endif /* __POCKETSPHINX_H__ */