00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 00002 /* ==================================================================== 00003 * Copyright (c) 1999-2004 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 * This work was supported in part by funding from the Defense Advanced 00019 * Research Projects Agency and the National Science Foundation of the 00020 * United States of America, and the CMU Sphinx Speech Consortium. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 00023 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00024 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00025 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 00026 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00028 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00029 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00030 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00032 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * ==================================================================== 00035 * 00036 */ 00037 /************************************************* 00038 * CMU ARPA Speech Project 00039 * 00040 * Copyright (c) 2000 Carnegie Mellon University. 00041 * ALL RIGHTS RESERVED. 00042 ************************************************* 00043 * 00044 * May 14, 2004 00045 * Created by Yitao Sun (yitao@cs.cmu.edu) based on the live.h created by 00046 * Rita Singh. The Live Decode API is the new top level API for Sphinx3. 00047 * The goal of the Live Decode API is to provide a well documented and 00048 * comprehensive API to control all aspects of the Sphinx3 speech decoder 00049 * engine. 00050 * 00051 * The return values, for example, hypothesis segments and string, unlike 00052 * the rest of Sphinx3, are read-only, maintained internally, and clobbered 00053 * by subsequent calls. 00054 */ 00055 00056 /* 00057 revision 1.9 00058 date: 2004/09/03 21:45:26; author: yitao; state: Exp; lines: +2 -2 00059 00060 cleaning up remote_decode API by moving list operations into a list API 00061 ---------------------------- 00062 revision 1.8 00063 date: 2004/09/03 16:50:56; author: yitao; state: Exp; lines: +108 -37 00064 00065 00066 modified comments to suit the use of doc++- 00067 ---------------------------- 00068 revision 1.7 00069 date: 2004/08/27 05:22:43; author: yitao; state: Exp; lines: +75 -105 00070 00071 00072 removed remote-decode API from the linux compile. added doc++ comments for live_decod 00073 e.h- 00074 ---------------------------- 00075 revision 1.6 00076 date: 2004/08/25 20:44:31; author: yitao; state: Exp; lines: +13 -15 00077 00078 00079 1. added code to record uttid in live-decode 00080 2. added more code to flesh out remote-decode. not compiling yet. 00081 ---------------------------- 00082 revision 1.5 00083 date: 2004/08/23 20:41:38; author: yitao; state: Exp; lines: +1 -11 00084 00085 basic implementation for remote-decode API. not compiling yet. 00086 ---------------------------- 00087 revision 1.4 00088 date: 2004/08/19 19:12:50; author: yitao; state: Exp; lines: +1 -1 00089 00090 incompleted files remote-decode API. 00091 ---------------------------- 00092 revision 1.3 00093 date: 2004/08/09 21:40:36; author: yitao; state: Exp; lines: +11 -20 00094 00095 1. fixed some bugs in Live-Decode API. changed kb.c, kb.h, utt.c, live_decode.c, liv 00096 e_decode.h. 00097 2. changed some filenames in src/programs/. now there are 2 sets of livedecode and l 00098 ivepretend: one that uses the old API (livedecode and livepretend), and one that uses 00099 the new API (livedecode2 and livepretend2). 00100 3. modified Makefile.am to reflect the filename changes above. 00101 ---------------------------- 00102 revision 1.2 00103 date: 2004/08/08 23:34:50; author: arthchan2003; state: Exp; lines: +1 -1 00104 temporary fixes of live_decode.c and live_decode.h 00105 ---------------------------- 00106 revision 1.1 00107 date: 2004/08/06 15:07:38; author: yitao; state: Exp; 00108 *** empty log message *** 00109 ============================================================================= 00110 00111 */ 00112 00113 #include <cmd_ln.h> 00114 #include <fe.h> 00115 #include "s3types.h" 00116 #include "sphinx3_export.h" 00117 #include "kb.h" 00118 #include "kbcore.h" 00119 #include "dag.h" 00120 #include "search.h" 00121 00122 #ifndef __S3_DECODE_H 00123 #define __S3_DECODE_H 00124 00128 #ifdef __cplusplus 00129 extern "C" { 00130 #endif 00131 #if 0 00132 } /* Fool Emacs into not indenting things. */ 00133 #endif 00134 00135 S3DECODER_EXPORT 00136 extern arg_t S3_DECODE_ARG_DEFS[]; 00137 00138 #define S3_DECODE_SUCCESS 0 00139 #define S3_DECODE_ERROR_OUT_OF_MEMORY -0x01 00140 #define S3_DECODE_ERROR_NULL_POINTER -0x02 00141 #define S3_DECODE_ERROR_INVALID_STATE -0x04 00142 #define S3_DECODE_ERROR_INTERNAL -0x08 00143 00144 #define S3_DECODE_STATE_IDLE 0 00145 #define S3_DECODE_STATE_DECODING 1 00146 #define S3_DECODE_STATE_FINISHED 2 00147 00150 S3DECODER_EXPORT 00151 typedef struct 00152 { 00156 kb_t kb; 00157 00161 kbcore_t *kbcore; 00162 00166 int32 phones_skip; 00167 00171 int32 num_frames_decoded; 00172 00176 int32 num_frames_entered; 00177 00181 int32 state; 00182 00186 char *uttid; 00187 00191 int32 hyp_frame_num; 00192 00197 char *hyp_str; 00198 00203 hyp_t **hyp_segs; 00204 00208 int32 swap; 00209 00213 int32 phypdump; 00214 00218 const char* rawext; 00219 00220 } s3_decode_t; 00221 00222 00238 S3DECODER_EXPORT 00239 int s3_decode_init(s3_decode_t *_decode, cmd_ln_t *_config); 00240 00249 S3DECODER_EXPORT 00250 void s3_decode_close(s3_decode_t *_decode); 00251 00273 S3DECODER_EXPORT 00274 int s3_decode_begin_utt(s3_decode_t *_decode, char *_uttid); 00275 00288 S3DECODER_EXPORT 00289 void s3_decode_end_utt(s3_decode_t *_decode); 00290 00309 S3DECODER_EXPORT 00310 int s3_decode_process(s3_decode_t *_decode, 00311 float32 **_frames, 00312 int32 _num_frames); 00313 00349 S3DECODER_EXPORT 00350 int s3_decode_hypothesis(s3_decode_t *_decode, char **_uttid, 00351 char **_hyp_str, hyp_t ***_hyp_segs); 00352 00361 S3DECODER_EXPORT 00362 dag_t *s3_decode_word_graph(s3_decode_t *_decode); 00363 00369 S3DECODER_EXPORT 00370 void s3_decode_set_lm(s3_decode_t *_decode, const char *lmname); 00371 00377 S3DECODER_EXPORT 00378 void s3_decode_delete_lm(s3_decode_t *_decode, const char *lmname); 00379 00380 00387 S3DECODER_EXPORT 00388 void s3_decode_read_lm(s3_decode_t *_decode, 00389 const char *lmfile, 00390 const char *lmname); 00391 00392 #if 0 00393 { /* Stop indent from complaining */ 00394 #endif 00395 #ifdef __cplusplus 00396 } 00397 #endif 00398 00399 #endif 00400 00401 00402 00403