dict2pid.h
Go to the documentation of this file.
/* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* ====================================================================
* Copyright (c) 1999-2014 Carnegie Mellon University. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* This work was supported in part by funding from the Defense Advanced
* Research Projects Agency and the National Science Foundation of the
* United States of America, and the CMU Sphinx Speech Consortium.
*
* THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
* ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
* NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ====================================================================
*
*/
#ifndef _S3_DICT2PID_H_
#define _S3_DICT2PID_H_
/* System headers. */
#include <stdio.h>
/* SphinxBase headers. */
#include <sphinxbase/logmath.h>
#include <sphinxbase/bitvec.h>
/* Local headers. */
#include "s3types.h"
#include "bin_mdef.h"
#include "dict.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
s3ssid_t *ssid;
s3cipid_t *cimap;
int32 n_ssid;
} xwdssid_t;
typedef struct {
int refcount;
bin_mdef_t *mdef;
dict_t *dict;
/*Notice the order of the arguments */
/* FIXME: This is crying out for compression - in Mandarin we have
* 180 context independent phones, which makes this an 11MB
* array. */
s3ssid_t ***ldiph_lc;
xwdssid_t **rssid;
s3ssid_t ***lrdiph_rc;
xwdssid_t **lrssid;
} dict2pid_t;
#define dict2pid_rssid(d,ci,lc) (&(d)->rssid[ci][lc])
#define dict2pid_ldiph_lc(d,b,r,l) ((d)->ldiph_lc[b][r][l])
#define dict2pid_lrdiph_rc(d,b,l,r) ((d)->lrdiph_rc[b][l][r])
dict2pid_t *dict2pid_build(bin_mdef_t *mdef,
dict_t *dict
);
dict2pid_t *dict2pid_retain(dict2pid_t *d2p);
int dict2pid_free(dict2pid_t *d2p
);
s3ssid_t dict2pid_internal(dict2pid_t *d2p,
int32 wid,
int pos);
int dict2pid_add_word(dict2pid_t *d2p,
int32 wid);
void dict2pid_dump(FILE *fp,
dict2pid_t *d2p
);
void dict2pid_report(dict2pid_t *d2p
);
int32 get_rc_nssid(dict2pid_t *d2p,
s3wid_t w
);
s3cipid_t* dict2pid_get_rcmap(dict2pid_t *d2p,
s3wid_t w
);
#ifdef __cplusplus
}
#endif
#endif
bin_mdef.h
Binary format model definition files, with support for heterogeneous topologies and variable-size N-p...
dict2pid_retain
dict2pid_t * dict2pid_retain(dict2pid_t *d2p)
Retain a pointer to dict2pid.
Definition dict2pid.c:500
dict2pid_build
dict2pid_t * dict2pid_build(bin_mdef_t *mdef, dict_t *dict)
Build the dict2pid structure for the given model/dictionary.
Definition dict2pid.c:388
dict2pid_free
int dict2pid_free(dict2pid_t *d2p)
Free the memory dict2pid structure.
Definition dict2pid.c:507
dict2pid_dump
void dict2pid_dump(FILE *fp, dict2pid_t *d2p)
For debugging.
Definition dict2pid.c:538
dict2pid_report
void dict2pid_report(dict2pid_t *d2p)
Report a dict2pid data structure.
Definition dict2pid.c:533
dict2pid_internal
s3ssid_t dict2pid_internal(dict2pid_t *d2p, int32 wid, int pos)
Return the senone sequence ID for the given word position.
Definition dict2pid.c:367
get_rc_nssid
int32 get_rc_nssid(dict2pid_t *d2p, s3wid_t w)
Get number of rc.
Definition dict2pid.c:204
dict2pid_add_word
int dict2pid_add_word(dict2pid_t *d2p, int32 wid)
Add a word to the dict2pid structure (after adding it to dict).
Definition dict2pid.c:298
dict2pid_get_rcmap
s3cipid_t * dict2pid_get_rcmap(dict2pid_t *d2p, s3wid_t w)
Get RC map.
Definition dict2pid.c:229
dict.h
Operations on dictionary.
s3types.h
Size definition of semantically units.
s3cipid_t
int16 s3cipid_t
Size definitions for more semantially meaningful units.
Definition s3types.h:63
bin_mdef_s
Definition bin_mdef.h:117
dict2pid_t
Building composite triphone (as well as word internal triphones) with the dictionary.
Definition dict2pid.h:84
dict2pid_t::rssid
xwdssid_t ** rssid
Right context state sequence id table First dimension: base phone, Second dimension: left context.
Definition dict2pid.h:99
dict2pid_t::lrdiph_rc
s3ssid_t *** lrdiph_rc
For single-phone words, [base][lc][rc] -> ssid; filled out for single-phone base x lc combinations in...
Definition dict2pid.h:105
dict2pid_t::ldiph_lc
s3ssid_t *** ldiph_lc
For multi-phone words, [base][rc][lc] -> ssid; filled out for word-initial base x rc combinations in ...
Definition dict2pid.h:95
dict2pid_t::lrssid
xwdssid_t ** lrssid
Left-Right context state sequence id table First dimension: base phone, Second dimension: left contex...
Definition dict2pid.h:108
dict2pid_t::mdef
bin_mdef_t * mdef
Model definition, used to generate internal ssids on the fly.
Definition dict2pid.h:87
dict2pid_t::dict
dict_t * dict
Dictionary this table refers to.
Definition dict2pid.h:89
dict_t
a structure for a dictionary.
Definition dict.h:76
xwdssid_t
cross word triphone model structure
Definition dict2pid.h:73
xwdssid_t::cimap
s3cipid_t * cimap
Index into ssid[] above for each ci phone.
Definition dict2pid.h:75
xwdssid_t::n_ssid
int32 n_ssid
#Unique ssid in above, compressed ssid list
Definition dict2pid.h:76
xwdssid_t::ssid
s3ssid_t * ssid
Senone Sequence ID list for all context ciphones.
Definition dict2pid.h:74