45 #ifndef __BIN_MDEF_H__ 46 #define __BIN_MDEF_H__ 53 #include <sphinxbase/mmio.h> 54 #include <sphinxbase/cmd_ln.h> 55 #include <pocketsphinx_export.h> 59 #define BIN_MDEF_FORMAT_VERSION 1 61 #define BIN_MDEF_NATIVE_ENDIAN 0x46444d42 62 #define BIN_MDEF_OTHER_ENDIAN 0x424d4446 64 #define __ATTRIBUTE_PACKED __attribute__((packed)) 66 #define __ATTRIBUTE_PACKED 94 #define BAD_SSID 0xffff 98 #define BAD_SENID 0xffff 142 enum { BIN_MDEF_FROM_TEXT, BIN_MDEF_IN_MEMORY, BIN_MDEF_ON_DISK } alloc_mode;
145 #define bin_mdef_is_fillerphone(m,p) (((p) < (m)->n_ciphone) \ 146 ? (m)->phone[p].info.ci.filler \ 147 : (m)->phone[(m)->phone[p].info.cd.ctx[0]].info.ci.filler) 148 #define bin_mdef_is_ciphone(m,p) ((p) < (m)->n_ciphone) 149 #define bin_mdef_n_ciphone(m) ((m)->n_ciphone) 150 #define bin_mdef_n_phone(m) ((m)->n_phone) 151 #define bin_mdef_n_sseq(m) ((m)->n_sseq) 152 #define bin_mdef_n_emit_state(m) ((m)->n_emit_state) 153 #define bin_mdef_n_emit_state_phone(m,p) ((m)->n_emit_state ? (m)->n_emit_state \ 154 : (m)->sseq_len[(m)->phone[p].ssid]) 155 #define bin_mdef_n_sen(m) ((m)->n_sen) 156 #define bin_mdef_n_tmat(m) ((m)->n_tmat) 157 #define bin_mdef_pid2ssid(m,p) ((m)->phone[p].ssid) 158 #define bin_mdef_pid2tmatid(m,p) ((m)->phone[p].tmat) 159 #define bin_mdef_silphone(m) ((m)->sil) 160 #define bin_mdef_sen2cimap(m,s) ((m)->sen2cimap[s]) 161 #define bin_mdef_sseq2sen(m,ss,pos) ((m)->sseq[ss][pos]) 162 #define bin_mdef_pid2ci(m,p) (((p) < (m)->n_ciphone) ? (p) \ 163 : (m)->phone[p].info.cd.ctx[0]) 199 const char *ciphone);
206 const char *ciphone);
220 int bin_mdef_phone_id_nearest(
bin_mdef_t * m, int32 b,
221 int32 l, int32 r, int32 pos);
int16 ctx
Context (word position or CI phone)
int16 n_down
Number of children (0 for leafnode)
POCKETSPHINX_EXPORT int bin_mdef_write(bin_mdef_t *m, const char *filename)
Write a binary mdef to a file.
const char * bin_mdef_ciphone_str(bin_mdef_t *m, int32 ci)
In: ciphone id for which name wanted.
int32 n_tmat
Number of transition matrices.
int32 n_sen
Number of senones (CI+CD)
int32 ssid
Senone sequence ID.
int bin_mdef_ciphone_id(bin_mdef_t *m, const char *ciphone)
Context-independent phone lookup.
int32 n_cd_tree
Number of nodes in cd_tree (below)
uint16 ** sseq
Unique senone sequences (2D array built at load time)
int32 tmat
Transition matrix ID.
cd_tree_t * cd_tree
Tree mapping CD phones to phone IDs.
uint8 ctx[3]
quintphones will require hacking
mmio_file_t * filemap
File map for this file (if any)
int32 n_phone
Number of base (CI) phones + (CD) triphones.
uint8 * sseq_len
Number of states in each sseq (NULL for homogeneous)
struct mdef_entry_s::@0::@1 ci
< CI phone information - attributes (just "filler" for now)
int32 n_sseq
Number of unique senone sequences.
char ** ciname
CI phone names.
POCKETSPHINX_EXPORT bin_mdef_t * bin_mdef_read(cmd_ln_t *config, const char *filename)
Read a binary mdef from a file.
int32 n_ctx
Number of phones of context.
int32 n_ci_sen
Number of CI senones; these are the first.
int bin_mdef_phone_id(bin_mdef_t *m, int32 b, int32 l, int32 r, int32 pos)
In: Word position.
int16 sil
CI phone ID for silence.
int16 * cd2cisen
Parent CI-senone id for each senone.
int32 n_emit_state
Number of emitting states per phone (0 for heterogeneous)
int32 down
Next level of the tree (offset from start of cd_trees)
int bin_mdef_ciphone_id_nocase(bin_mdef_t *m, const char *ciphone)
Case-insensitive context-independent phone lookup.
int16 * sen2cimap
Parent CI-phone for each senone (CI or CD)
int bin_mdef_free(bin_mdef_t *m)
Release a pointer to a binary mdef.
POCKETSPHINX_EXPORT bin_mdef_t * bin_mdef_read_text(cmd_ln_t *config, const char *filename)
Read a text mdef from a file (creating an in-memory binary mdef).
bin_mdef_t * bin_mdef_retain(bin_mdef_t *m)
Retain a pointer to a bin_mdef_t.
int32 pid
Phone ID (leafnode)
int bin_mdef_phone_str(bin_mdef_t *m, int pid, char *buf)
Create a phone string for the given phone (base or triphone) id in the given buf. ...
mdef_entry_t * phone
All phone structures.
POCKETSPHINX_EXPORT int bin_mdef_write_text(bin_mdef_t *m, const char *filename)
Write a binary mdef to a text file.
int32 n_ciphone
Number of base (CI) phones.