PocketSphinx 5prealpha
pocketsphinx.h
Go to the documentation of this file.
1/* -*- c-basic-offset:4; indent-tabs-mode: nil -*- */
2/* ====================================================================
3 * Copyright (c) 1999-2008 Carnegie Mellon University. All rights
4 * reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 *
19 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
20 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
23 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 * ====================================================================
32 *
33 */
38#ifndef __POCKETSPHINX_H__
39#define __POCKETSPHINX_H__
40
41
42/* System headers we need. */
43#include <stdio.h>
44
45/* SphinxBase headers we need. */
46#include <sphinxbase/cmd_ln.h>
47#include <sphinxbase/logmath.h>
48#include <sphinxbase/fe.h>
49#include <sphinxbase/feat.h>
50
51/* PocketSphinx headers (not many of them!) */
52#include <pocketsphinx_export.h>
53#include <cmdln_macro.h>
54#include <ps_lattice.h>
55#include <ps_mllr.h>
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60#if 0
61}
62#endif
63
68
69#include <ps_search.h>
70
74typedef struct ps_astar_s ps_nbest_t;
75
79typedef struct ps_seg_s ps_seg_t;
80
85POCKETSPHINX_EXPORT void
86ps_default_search_args(cmd_ln_t *);
87
98POCKETSPHINX_EXPORT
99ps_decoder_t *ps_init(cmd_ln_t *config);
100
118POCKETSPHINX_EXPORT
119int ps_reinit(ps_decoder_t *ps, cmd_ln_t *config);
120
127POCKETSPHINX_EXPORT
128arg_t const *ps_args(void);
129
140POCKETSPHINX_EXPORT
142
153POCKETSPHINX_EXPORT
154int ps_free(ps_decoder_t *ps);
155
164POCKETSPHINX_EXPORT
165cmd_ln_t *ps_get_config(ps_decoder_t *ps);
166
175POCKETSPHINX_EXPORT
176logmath_t *ps_get_logmath(ps_decoder_t *ps);
177
186POCKETSPHINX_EXPORT
187fe_t *ps_get_fe(ps_decoder_t *ps);
188
197POCKETSPHINX_EXPORT
198feat_t *ps_get_feat(ps_decoder_t *ps);
199
211POCKETSPHINX_EXPORT
213
228POCKETSPHINX_EXPORT
229int ps_load_dict(ps_decoder_t *ps, char const *dictfile,
230 char const *fdictfile, char const *format);
231
241POCKETSPHINX_EXPORT
242int ps_save_dict(ps_decoder_t *ps, char const *dictfile, char const *format);
243
263POCKETSPHINX_EXPORT
265 char const *word,
266 char const *phones,
267 int update);
268
280POCKETSPHINX_EXPORT
282 const char *word);
283
298POCKETSPHINX_EXPORT
299long ps_decode_raw(ps_decoder_t *ps, FILE *rawfh,
300 long maxsamps);
301
309POCKETSPHINX_EXPORT
310int ps_decode_senscr(ps_decoder_t *ps, FILE *senfh);
311
319POCKETSPHINX_EXPORT
321
332POCKETSPHINX_EXPORT
334
348POCKETSPHINX_EXPORT
350 int16 const *data,
351 size_t n_samples,
352 int no_search,
353 int full_utt);
354
368POCKETSPHINX_EXPORT
370 mfcc_t **data,
371 int n_frames,
372 int no_search,
373 int full_utt);
374
388POCKETSPHINX_EXPORT
390
397POCKETSPHINX_EXPORT
398int ps_end_utt(ps_decoder_t *ps);
399
408POCKETSPHINX_EXPORT
409char const *ps_get_hyp(ps_decoder_t *ps, int32 *out_best_score);
410
424POCKETSPHINX_EXPORT
425int32 ps_get_prob(ps_decoder_t *ps);
426
440POCKETSPHINX_EXPORT
442
450POCKETSPHINX_EXPORT
452
460POCKETSPHINX_EXPORT
462
470POCKETSPHINX_EXPORT
471char const *ps_seg_word(ps_seg_t *seg);
472
484POCKETSPHINX_EXPORT
485void ps_seg_frames(ps_seg_t *seg, int *out_sf, int *out_ef);
486
509POCKETSPHINX_EXPORT
510int32 ps_seg_prob(ps_seg_t *seg, int32 *out_ascr, int32 *out_lscr, int32 *out_lback);
511
515POCKETSPHINX_EXPORT
516void ps_seg_free(ps_seg_t *seg);
517
526POCKETSPHINX_EXPORT
528
536POCKETSPHINX_EXPORT
538
546POCKETSPHINX_EXPORT
547char const *ps_nbest_hyp(ps_nbest_t *nbest, int32 *out_score);
548
556POCKETSPHINX_EXPORT
558
564POCKETSPHINX_EXPORT
565void ps_nbest_free(ps_nbest_t *nbest);
566
575POCKETSPHINX_EXPORT
576void ps_get_utt_time(ps_decoder_t *ps, double *out_nspeech,
577 double *out_ncpu, double *out_nwall);
578
587POCKETSPHINX_EXPORT
588void ps_get_all_time(ps_decoder_t *ps, double *out_nspeech,
589 double *out_ncpu, double *out_nwall);
590
597POCKETSPHINX_EXPORT
599
600
608POCKETSPHINX_EXPORT
609void ps_set_rawdata_size(ps_decoder_t *ps, int32 size);
610
611
620POCKETSPHINX_EXPORT
621void ps_get_rawdata(ps_decoder_t *ps, int16 **buffer, int32 *size);
622
637#ifdef __cplusplus
638} /* extern "C" */
639#endif
640
641#endif /* __POCKETSPHINX_H__ */
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.
POCKETSPHINX_EXPORT ps_seg_t * ps_seg_next(ps_seg_t *seg)
Get the next segment in a word segmentation.
POCKETSPHINX_EXPORT void ps_get_rawdata(ps_decoder_t *ps, int16 **buffer, int32 *size)
Retrieves the raw data collected during utterance decoding.
POCKETSPHINX_EXPORT cmd_ln_t * ps_get_config(ps_decoder_t *ps)
Get the configuration object for this decoder.
Definition: pocketsphinx.c:437
POCKETSPHINX_EXPORT uint8 ps_get_in_speech(ps_decoder_t *ps)
Checks if the last feed audio buffer contained speech.
POCKETSPHINX_EXPORT char const * ps_seg_word(ps_seg_t *seg)
Get word string from a segmentation iterator.
POCKETSPHINX_EXPORT logmath_t * ps_get_logmath(ps_decoder_t *ps)
Get the log-math computation object for this decoder.
Definition: pocketsphinx.c:443
POCKETSPHINX_EXPORT char const * ps_get_hyp(ps_decoder_t *ps, int32 *out_best_score)
Get hypothesis string and path score.
POCKETSPHINX_EXPORT feat_t * ps_get_feat(ps_decoder_t *ps)
Get the dynamic feature computation object for this decoder.
Definition: pocketsphinx.c:455
POCKETSPHINX_EXPORT int ps_reinit(ps_decoder_t *ps, cmd_ln_t *config)
Reinitialize the decoder with updated configuration.
Definition: pocketsphinx.c:218
POCKETSPHINX_EXPORT long ps_decode_raw(ps_decoder_t *ps, FILE *rawfh, long maxsamps)
Decode a raw audio stream.
Definition: pocketsphinx.c:883
POCKETSPHINX_EXPORT int ps_decode_senscr(ps_decoder_t *ps, FILE *senfh)
Decode a senone score dump file.
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.
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.
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
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
POCKETSPHINX_EXPORT void ps_get_all_time(ps_decoder_t *ps, double *out_nspeech, double *out_ncpu, double *out_nwall)
Get overall performance information.
POCKETSPHINX_EXPORT ps_seg_t * ps_nbest_seg(ps_nbest_t *nbest)
Get the word segmentation from an N-best list iterator.
POCKETSPHINX_EXPORT arg_t const * ps_args(void)
Returns the argument definitions used in ps_init().
Definition: pocketsphinx.c:407
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
POCKETSPHINX_EXPORT void ps_nbest_free(ps_nbest_t *nbest)
Finish N-best search early, releasing resources.
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
POCKETSPHINX_EXPORT int ps_start_stream(ps_decoder_t *ps)
Start processing of the stream of speech.
Definition: pocketsphinx.c:926
POCKETSPHINX_EXPORT fe_t * ps_get_fe(ps_decoder_t *ps)
Get the feature extraction object for this decoder.
Definition: pocketsphinx.c:449
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.
POCKETSPHINX_EXPORT ps_seg_t * ps_seg_iter(ps_decoder_t *ps)
Get an iterator over the word segmentation for the best hypothesis.
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
POCKETSPHINX_EXPORT ps_decoder_t * ps_retain(ps_decoder_t *ps)
Retain a pointer to the decoder.
Definition: pocketsphinx.c:413
POCKETSPHINX_EXPORT int ps_end_utt(ps_decoder_t *ps)
End utterance processing.
POCKETSPHINX_EXPORT ps_nbest_t * ps_nbest(ps_decoder_t *ps)
Get an iterator over the best hypotheses.
POCKETSPHINX_EXPORT int ps_get_n_frames(ps_decoder_t *ps)
Get the number of frames of data searched.
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
POCKETSPHINX_EXPORT void ps_seg_free(ps_seg_t *seg)
Finish iterating over a word segmentation early, freeing resources.
POCKETSPHINX_EXPORT int32 ps_get_prob(ps_decoder_t *ps)
Get posterior probability.
POCKETSPHINX_EXPORT int ps_free(ps_decoder_t *ps)
Finalize the decoder.
Definition: pocketsphinx.c:420
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.
POCKETSPHINX_EXPORT int ps_start_utt(ps_decoder_t *ps)
Start utterance processing.
Definition: pocketsphinx.c:933
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.
POCKETSPHINX_EXPORT ps_nbest_t * ps_nbest_next(ps_nbest_t *nbest)
Move an N-best list iterator forward.
POCKETSPHINX_EXPORT char const * ps_nbest_hyp(ps_nbest_t *nbest, int32 *out_score)
Get the hypothesis string from an N-best list iterator.
POCKETSPHINX_EXPORT ps_decoder_t * ps_init(cmd_ln_t *config)
Initialize the decoder from a configuration object.
Definition: pocketsphinx.c:388
POCKETSPHINX_EXPORT ps_lattice_t * ps_get_lattice(ps_decoder_t *ps)
Get word lattice.
Word graph search.
Model-space linear transforms for speaker adaptation.
User can configure several "search" objects with different grammars and langauge models and switch th...
A* search structure.
Decoder object.
Word graph structure used in bestpath/nbest search.
Feature space linear transform structure.
Definition: acmod.h:82
Base structure for hypothesis segmentation iterator.
char const * word
Word string (pointer into dictionary hash)