PocketSphinx  5.0.0rc5
A small speech recognizer
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 /* System headers */
42 #include <stdio.h>
43 
44 /* PocketSphinx utility headers */
45 #include <pocketsphinx/sphinx_config.h>
46 #include <pocketsphinx/prim_type.h>
47 #include <pocketsphinx/logmath.h>
48 #include <pocketsphinx/err.h>
49 
50 /* PocketSphinx API headers */
51 #include <pocketsphinx/vad.h>
53 #include <pocketsphinx/model.h>
54 #include <pocketsphinx/search.h>
55 #include <pocketsphinx/export.h>
56 #include <pocketsphinx/lattice.h>
57 #include <pocketsphinx/alignment.h>
58 #include <pocketsphinx/mllr.h>
59 
60 /* Namum manglium ii domum */
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 #if 0
65 }
66 #endif
67 
68 /* Transparent structures */
73 typedef enum ps_type_e {
74  ARG_REQUIRED = (1<<0), /*<< Bit indicating required argument. */
75  ARG_INTEGER = (1<<1), /*<< Integer up to 64 bits. */
76  ARG_FLOATING = (1<<2), /*<< Double-precision floating point. */
77  ARG_STRING = (1<<3), /*<< String. */
78  ARG_BOOLEAN = (1<<4), /*<< Boolean (true/false). */
79  REQARG_INTEGER = (ARG_INTEGER | ARG_REQUIRED),
80  REQARG_FLOATING = (ARG_FLOATING | ARG_REQUIRED),
81  REQARG_STRING = (ARG_STRING | ARG_REQUIRED),
82  REQARG_BOOLEAN = (ARG_BOOLEAN | ARG_REQUIRED)
83 } ps_type_t;
84 
89 typedef struct arg_s {
90  char const *name;
91  int type;
92  char const *deflt;
93  char const *doc;
94 } arg_t;
95 
96 /* Opaque structures */
97 
102 typedef struct cmd_ln_s ps_config_t;
103 
108 typedef struct ps_decoder_s ps_decoder_t;
109 
114 typedef struct ps_astar_s ps_nbest_t;
115 
120 typedef struct ps_seg_s ps_seg_t;
121 
132 POCKETSPHINX_EXPORT
133 ps_config_t *ps_config_init(const arg_t *defn);
134 
138 POCKETSPHINX_EXPORT
140 
144 POCKETSPHINX_EXPORT
145 int ps_config_free(ps_config_t *config);
146 
155 int ps_config_validate(ps_config_t *config);
156 
180 POCKETSPHINX_EXPORT
181 ps_config_t *ps_config_parse_json(ps_config_t *config, const char *json);
182 
194 POCKETSPHINX_EXPORT
195 const char *ps_config_serialize_json(ps_config_t *config);
196 
205 POCKETSPHINX_EXPORT
206 ps_type_t ps_config_typeof(ps_config_t *config, char const *name);
207 
223 POCKETSPHINX_EXPORT
224 const anytype_t *ps_config_get(ps_config_t *config, const char *name);
225 
247 POCKETSPHINX_EXPORT
248 const anytype_t *ps_config_set(ps_config_t *config, const char *name,
249  const anytype_t *val, ps_type_t t);
250 
257 POCKETSPHINX_EXPORT
258 long ps_config_int(ps_config_t *config, const char *name);
259 
268 POCKETSPHINX_EXPORT
269 int ps_config_bool(ps_config_t *config, const char *name);
270 
277 POCKETSPHINX_EXPORT
278 double ps_config_float(ps_config_t *config, const char *name);
279 
288 POCKETSPHINX_EXPORT
289 const char *ps_config_str(ps_config_t *config, const char *name);
290 
297 POCKETSPHINX_EXPORT
298 const anytype_t *ps_config_set_int(ps_config_t *config, const char *name, long val);
299 
306 POCKETSPHINX_EXPORT
307 const anytype_t *ps_config_set_bool(ps_config_t *config, const char *name, int val);
308 
315 POCKETSPHINX_EXPORT
316 const anytype_t *ps_config_set_float(ps_config_t *config, const char *name, double val);
317 
329 POCKETSPHINX_EXPORT
330 const anytype_t *ps_config_set_str(ps_config_t *config, const char *name, const char *val);
331 
336 POCKETSPHINX_EXPORT
337 void ps_default_search_args(ps_config_t *config);
338 
342 POCKETSPHINX_EXPORT
343 void ps_expand_model_config(ps_config_t *config);
344 
352 POCKETSPHINX_EXPORT
353 const char *ps_default_modeldir(void);
354 
365 POCKETSPHINX_EXPORT
367 
390 POCKETSPHINX_EXPORT
391 int ps_reinit(ps_decoder_t *ps, ps_config_t *config);
392 
415 POCKETSPHINX_EXPORT
416 int ps_reinit_feat(ps_decoder_t *ps, ps_config_t *config);
417 
433 POCKETSPHINX_EXPORT
434 const char *ps_get_cmn(ps_decoder_t *ps, int update);
435 
449 POCKETSPHINX_EXPORT
450 int ps_set_cmn(ps_decoder_t *ps, const char *cmn);
451 
458 POCKETSPHINX_EXPORT
459 arg_t const *ps_args(void);
460 
471 POCKETSPHINX_EXPORT
473 
482 POCKETSPHINX_EXPORT
483 int ps_free(ps_decoder_t *ps);
484 
493 POCKETSPHINX_EXPORT
495 
504 POCKETSPHINX_EXPORT
506 
517 POCKETSPHINX_EXPORT
519 
534 POCKETSPHINX_EXPORT
535 int ps_load_dict(ps_decoder_t *ps, char const *dictfile,
536  char const *fdictfile, char const *format);
537 
547 POCKETSPHINX_EXPORT
548 int ps_save_dict(ps_decoder_t *ps, char const *dictfile, char const *format);
549 
569 POCKETSPHINX_EXPORT
570 int ps_add_word(ps_decoder_t *ps,
571  char const *word,
572  char const *phones,
573  int update);
574 
586 POCKETSPHINX_EXPORT
587 char *ps_lookup_word(ps_decoder_t *ps,
588  const char *word);
589 
604 POCKETSPHINX_EXPORT
605 long ps_decode_raw(ps_decoder_t *ps, FILE *rawfh,
606  long maxsamps);
607 
615 POCKETSPHINX_EXPORT
616 int ps_decode_senscr(ps_decoder_t *ps, FILE *senfh);
617 
627 POCKETSPHINX_EXPORT
629 
642 POCKETSPHINX_EXPORT
644 
655 POCKETSPHINX_EXPORT
656 int ps_start_utt(ps_decoder_t *ps);
657 
671 POCKETSPHINX_EXPORT
673  int16 const *data,
674  size_t n_samples,
675  int no_search,
676  int full_utt);
677 
692 POCKETSPHINX_EXPORT
694  float32 **data,
695  int n_frames,
696  int no_search,
697  int full_utt);
698 
712 POCKETSPHINX_EXPORT
714 
721 POCKETSPHINX_EXPORT
722 int ps_end_utt(ps_decoder_t *ps);
723 
734 POCKETSPHINX_EXPORT
735 char const *ps_get_hyp(ps_decoder_t *ps, int32 *out_best_score);
736 
750 POCKETSPHINX_EXPORT
751 int32 ps_get_prob(ps_decoder_t *ps);
752 
766 POCKETSPHINX_EXPORT
768 
776 POCKETSPHINX_EXPORT
778 
786 POCKETSPHINX_EXPORT
788 
796 POCKETSPHINX_EXPORT
797 char const *ps_seg_word(ps_seg_t *seg);
798 
810 POCKETSPHINX_EXPORT
811 void ps_seg_frames(ps_seg_t *seg, int *out_sf, int *out_ef);
812 
835 POCKETSPHINX_EXPORT
836 int32 ps_seg_prob(ps_seg_t *seg, int32 *out_ascr, int32 *out_lscr, int32 *out_lback);
837 
841 POCKETSPHINX_EXPORT
842 void ps_seg_free(ps_seg_t *seg);
843 
852 POCKETSPHINX_EXPORT
853 ps_nbest_t *ps_nbest(ps_decoder_t *ps);
854 
862 POCKETSPHINX_EXPORT
863 ps_nbest_t *ps_nbest_next(ps_nbest_t *nbest);
864 
873 POCKETSPHINX_EXPORT
874 char const *ps_nbest_hyp(ps_nbest_t *nbest, int32 *out_score);
875 
882 POCKETSPHINX_EXPORT
883 ps_seg_t *ps_nbest_seg(ps_nbest_t *nbest);
884 
890 POCKETSPHINX_EXPORT
891 void ps_nbest_free(ps_nbest_t *nbest);
892 
901 POCKETSPHINX_EXPORT
902 void ps_get_utt_time(ps_decoder_t *ps, double *out_nspeech,
903  double *out_ncpu, double *out_nwall);
904 
913 POCKETSPHINX_EXPORT
914 void ps_get_all_time(ps_decoder_t *ps, double *out_nspeech,
915  double *out_ncpu, double *out_nwall);
916 
1055 #ifdef __cplusplus
1056 } /* extern "C" */
1057 #endif
1058 
1059 #endif /* __POCKETSPHINX_H__ */
ps_config_get
const POCKETSPHINX_EXPORT anytype_t * ps_config_get(ps_config_t *config, const char *name)
ps_start_stream
POCKETSPHINX_EXPORT int ps_start_stream(ps_decoder_t *ps)
ps_init
POCKETSPHINX_EXPORT ps_decoder_t * ps_init(ps_config_t *config)
ps_nbest
POCKETSPHINX_EXPORT ps_nbest_t * ps_nbest(ps_decoder_t *ps)
ps_config_str
const POCKETSPHINX_EXPORT char * ps_config_str(ps_config_t *config, const char *name)
logmath_t
struct logmath_s logmath_t
Definition: logmath.h:106
ps_nbest_next
POCKETSPHINX_EXPORT ps_nbest_t * ps_nbest_next(ps_nbest_t *nbest)
ps_get_in_speech
POCKETSPHINX_EXPORT int ps_get_in_speech(ps_decoder_t *ps)
ps_seg_frames
POCKETSPHINX_EXPORT void ps_seg_frames(ps_seg_t *seg, int *out_sf, int *out_ef)
prim_type.h
Basic type definitions used in Sphinx.
ps_seg_prob
POCKETSPHINX_EXPORT int32 ps_seg_prob(ps_seg_t *seg, int32 *out_ascr, int32 *out_lscr, int32 *out_lback)
model.h
Public API for language models.
ps_get_utt_time
POCKETSPHINX_EXPORT void ps_get_utt_time(ps_decoder_t *ps, double *out_nspeech, double *out_ncpu, double *out_nwall)
ps_get_lattice
POCKETSPHINX_EXPORT ps_lattice_t * ps_get_lattice(ps_decoder_t *ps)
ps_config_serialize_json
const POCKETSPHINX_EXPORT char * ps_config_serialize_json(ps_config_t *config)
ps_decode_raw
POCKETSPHINX_EXPORT long ps_decode_raw(ps_decoder_t *ps, FILE *rawfh, long maxsamps)
ps_add_word
POCKETSPHINX_EXPORT int ps_add_word(ps_decoder_t *ps, char const *word, char const *phones, int update)
ps_decode_senscr
POCKETSPHINX_EXPORT int ps_decode_senscr(ps_decoder_t *ps, FILE *senfh)
ps_config_int
POCKETSPHINX_EXPORT long ps_config_int(ps_config_t *config, const char *name)
ps_config_bool
POCKETSPHINX_EXPORT int ps_config_bool(ps_config_t *config, const char *name)
ps_get_cmn
const POCKETSPHINX_EXPORT char * ps_get_cmn(ps_decoder_t *ps, int update)
arg_s
Definition: pocketsphinx.h:89
ps_get_prob
POCKETSPHINX_EXPORT int32 ps_get_prob(ps_decoder_t *ps)
ps_get_hyp
POCKETSPHINX_EXPORT const char * ps_get_hyp(ps_decoder_t *ps, int32 *out_best_score)
ps_load_dict
POCKETSPHINX_EXPORT int ps_load_dict(ps_decoder_t *ps, char const *dictfile, char const *fdictfile, char const *format)
ps_save_dict
POCKETSPHINX_EXPORT int ps_save_dict(ps_decoder_t *ps, char const *dictfile, char const *format)
ps_seg_free
POCKETSPHINX_EXPORT void ps_seg_free(ps_seg_t *seg)
logmath.h
Fast integer logarithmic addition operations.
ps_config_parse_json
POCKETSPHINX_EXPORT ps_config_t * ps_config_parse_json(ps_config_t *config, const char *json)
ps_config_float
POCKETSPHINX_EXPORT double ps_config_float(ps_config_t *config, const char *name)
ps_update_mllr
POCKETSPHINX_EXPORT ps_mllr_t * ps_update_mllr(ps_decoder_t *ps, ps_mllr_t *mllr)
vad.h
Simple voice activity detection.
ps_config_set_str
const POCKETSPHINX_EXPORT anytype_t * ps_config_set_str(ps_config_t *config, const char *name, const char *val)
ps_config_set
const POCKETSPHINX_EXPORT anytype_t * ps_config_set(ps_config_t *config, const char *name, const anytype_t *val, ps_type_t t)
ps_free
POCKETSPHINX_EXPORT int ps_free(ps_decoder_t *ps)
anytype_s
Definition: prim_type.h:107
endpointer.h
VAD-based endpointer for PocketSphinx.
ps_seg_t
ps_set_cmn
POCKETSPHINX_EXPORT int ps_set_cmn(ps_decoder_t *ps, const char *cmn)
mllr.h
Model-space linear transforms for speaker adaptation.
ps_config_init
POCKETSPHINX_EXPORT ps_config_t * ps_config_init(const arg_t *defn)
ps_seg_next
POCKETSPHINX_EXPORT ps_seg_t * ps_seg_next(ps_seg_t *seg)
ps_nbest_hyp
POCKETSPHINX_EXPORT const char * ps_nbest_hyp(ps_nbest_t *nbest, int32 *out_score)
ps_default_search_args
POCKETSPHINX_EXPORT void ps_default_search_args(ps_config_t *config)
lattice.h
Word lattices.
ps_end_utt
POCKETSPHINX_EXPORT int ps_end_utt(ps_decoder_t *ps)
ps_config_t
ps_config_typeof
POCKETSPHINX_EXPORT ps_type_t ps_config_typeof(ps_config_t *config, char const *name)
ps_retain
POCKETSPHINX_EXPORT ps_decoder_t * ps_retain(ps_decoder_t *ps)
err.h
Implementation of logging routines.
ps_lattice_t
Word graph structure used in bestpath/nbest search.
ps_config_set_bool
const POCKETSPHINX_EXPORT anytype_t * ps_config_set_bool(ps_config_t *config, const char *name, int val)
ps_get_logmath
POCKETSPHINX_EXPORT logmath_t * ps_get_logmath(ps_decoder_t *ps)
arg_s::type
int type
Definition: pocketsphinx.h:91
ps_process_cep
POCKETSPHINX_EXPORT int ps_process_cep(ps_decoder_t *ps, float32 **data, int n_frames, int no_search, int full_utt)
ps_args
POCKETSPHINX_EXPORT const arg_t * ps_args(void)
ps_seg_word
POCKETSPHINX_EXPORT const char * ps_seg_word(ps_seg_t *seg)
ps_mllr_t
struct ps_mllr_s ps_mllr_t
Definition: mllr.h:59
arg_s::doc
const char * doc
Definition: pocketsphinx.h:93
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)
ps_config_set_float
const POCKETSPHINX_EXPORT anytype_t * ps_config_set_float(ps_config_t *config, const char *name, double val)
ps_config_retain
POCKETSPHINX_EXPORT ps_config_t * ps_config_retain(ps_config_t *config)
ps_nbest_free
POCKETSPHINX_EXPORT void ps_nbest_free(ps_nbest_t *nbest)
ps_config_set_int
const POCKETSPHINX_EXPORT anytype_t * ps_config_set_int(ps_config_t *config, const char *name, long val)
ps_start_utt
POCKETSPHINX_EXPORT int ps_start_utt(ps_decoder_t *ps)
ps_config_free
POCKETSPHINX_EXPORT int ps_config_free(ps_config_t *config)
ps_reinit_feat
POCKETSPHINX_EXPORT int ps_reinit_feat(ps_decoder_t *ps, ps_config_t *config)
ps_nbest_seg
POCKETSPHINX_EXPORT ps_seg_t * ps_nbest_seg(ps_nbest_t *nbest)
arg_s::name
const char * name
Definition: pocketsphinx.h:90
ps_default_modeldir
const POCKETSPHINX_EXPORT char * ps_default_modeldir(void)
ps_seg_iter
POCKETSPHINX_EXPORT ps_seg_t * ps_seg_iter(ps_decoder_t *ps)
ps_expand_model_config
POCKETSPHINX_EXPORT void ps_expand_model_config(ps_config_t *config)
ps_reinit
POCKETSPHINX_EXPORT int ps_reinit(ps_decoder_t *ps, ps_config_t *config)
ps_decoder_t
ps_get_all_time
POCKETSPHINX_EXPORT void ps_get_all_time(ps_decoder_t *ps, double *out_nspeech, double *out_ncpu, double *out_nwall)
ps_config_validate
int ps_config_validate(ps_config_t *config)
ps_lookup_word
POCKETSPHINX_EXPORT char * ps_lookup_word(ps_decoder_t *ps, const char *word)
ps_get_config
POCKETSPHINX_EXPORT ps_config_t * ps_get_config(ps_decoder_t *ps)
search.h
Search modules.
arg_s::deflt
const char * deflt
Definition: pocketsphinx.h:92
ps_get_n_frames
POCKETSPHINX_EXPORT int ps_get_n_frames(ps_decoder_t *ps)