PocketSphinx
0.6
|
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 00002 /* ==================================================================== 00003 * Copyright (c) 2010 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 00042 #ifndef __PS_ALIGNMENT_H__ 00043 #define __PS_ALIGNMENT_H__ 00044 00045 /* System headers. */ 00046 00047 /* SphinxBase headers. */ 00048 #include <sphinxbase/prim_type.h> 00049 00050 /* Local headers. */ 00051 #include "dict2pid.h" 00052 #include "hmm.h" 00053 00054 #define PS_ALIGNMENT_NONE ((uint16)0xffff) 00055 00056 struct ps_alignment_entry_s { 00057 union { 00058 int32 wid; 00059 struct { 00060 uint16 ssid; 00061 uint16 cipid; 00062 uint16 tmatid; 00063 } pid; 00064 uint16 senid; 00065 } id; 00066 int16 start; 00067 int16 duration; 00068 uint16 parent; 00069 uint16 child; 00070 }; 00071 typedef struct ps_alignment_entry_s ps_alignment_entry_t; 00072 00073 struct ps_alignment_vector_s { 00074 ps_alignment_entry_t *seq; 00075 uint16 n_ent, n_alloc; 00076 }; 00077 typedef struct ps_alignment_vector_s ps_alignment_vector_t; 00078 00079 struct ps_alignment_s { 00080 dict2pid_t *d2p; 00081 ps_alignment_vector_t word; 00082 ps_alignment_vector_t sseq; 00083 ps_alignment_vector_t state; 00084 }; 00085 typedef struct ps_alignment_s ps_alignment_t; 00086 00087 struct ps_alignment_iter_s { 00088 ps_alignment_t *al; 00089 ps_alignment_vector_t *vec; 00090 int pos; 00091 }; 00092 typedef struct ps_alignment_iter_s ps_alignment_iter_t; 00093 00097 ps_alignment_t *ps_alignment_init(dict2pid_t *d2p); 00098 00102 int ps_alignment_free(ps_alignment_t *al); 00103 00107 int ps_alignment_add_word(ps_alignment_t *al, 00108 int32 wid, int duration); 00109 00113 int ps_alignment_populate(ps_alignment_t *al); 00114 00118 int ps_alignment_populate_ci(ps_alignment_t *al); 00119 00123 int ps_alignment_propagate(ps_alignment_t *al); 00124 00128 int ps_alignment_n_words(ps_alignment_t *al); 00129 00133 int ps_alignment_n_phones(ps_alignment_t *al); 00134 00138 int ps_alignment_n_states(ps_alignment_t *al); 00139 00143 ps_alignment_iter_t *ps_alignment_words(ps_alignment_t *al); 00144 00148 ps_alignment_iter_t *ps_alignment_phones(ps_alignment_t *al); 00149 00153 ps_alignment_iter_t *ps_alignment_states(ps_alignment_t *al); 00154 00158 ps_alignment_entry_t *ps_alignment_iter_get(ps_alignment_iter_t *itor); 00159 00163 ps_alignment_iter_t *ps_alignment_iter_goto(ps_alignment_iter_t *itor, int pos); 00164 00168 ps_alignment_iter_t *ps_alignment_iter_next(ps_alignment_iter_t *itor); 00169 00173 ps_alignment_iter_t *ps_alignment_iter_prev(ps_alignment_iter_t *itor); 00174 00178 ps_alignment_iter_t *ps_alignment_iter_up(ps_alignment_iter_t *itor); 00182 ps_alignment_iter_t *ps_alignment_iter_down(ps_alignment_iter_t *itor); 00183 00187 int ps_alignment_iter_free(ps_alignment_iter_t *itor); 00188 00189 #endif /* __PS_ALIGNMENT_H__ */