PocketSphinx 5prealpha
mdef.h File Reference

Model definition. More...

#include <stdio.h>
#include <sphinxbase/hash_table.h>

Go to the source code of this file.

Data Structures

struct  ciphone_t
 CI phone information. More...
struct  phone_t
 Triphone information, including base phones as a subset. More...
struct  ph_rc_s
struct  ph_lc_s
struct  mdef_t
 The main model definition structure. More...

Macros

#define N_WORD_POSN   4
 total # of word positions (excluding undefined)
#define WPOS_NAME   "ibesu"
 Printable code for each word position above.
#define S3_SILENCE_CIPHONE   "SIL"
 Hard-coded silence CI phone name.
#define mdef_is_fillerphone(m, p)
 Access macros; not meant for arbitrary use.
#define mdef_n_ciphone(m)
#define mdef_n_phone(m)
#define mdef_n_sseq(m)
#define mdef_n_emit_state(m)
#define mdef_n_sen(m)
#define mdef_n_tmat(m)
#define mdef_pid2ssid(m, p)
#define mdef_pid2tmatid(m, p)
#define mdef_silphone(m)
#define mdef_sen2cimap(m)
#define mdef_sseq2sen(m, ss, pos)
#define mdef_pid2ci(m, p)
#define mdef_cd2cisen(m)

Typedefs

typedef struct ph_rc_s ph_rc_t
typedef struct ph_lc_s ph_lc_t

Enumerations

enum  word_posn_t {
  WORD_POSN_INTERNAL = 0 , WORD_POSN_BEGIN = 1 , WORD_POSN_END = 2 , WORD_POSN_SINGLE = 3 ,
  WORD_POSN_UNDEFINED = 4
}
 Union of different type of word position. More...

Functions

mdef_tmdef_init (char *mdeffile, int breport)
 Initialize the phone structure from the given model definition file.
int mdef_ciphone_id (mdef_t *m, char *ciphone)
 Get the ciphone id given a string name.
const char * mdef_ciphone_str (mdef_t *m, int ci)
 Get the phone string given the ci phone id.
int mdef_is_ciphone (mdef_t *m, int p)
 Decide whether the phone is ci phone.
int mdef_is_cisenone (mdef_t *m, int s)
 Decide whether the senone is a senone for a ci phone, or a ci senone.
int mdef_phone_id (mdef_t *m, int b, int l, int r, word_posn_t pos)
 Decide the phone id given the left, right and base phones.
int mdef_phone_str (mdef_t *m, int pid, char *buf)
 Create a phone string for the given phone (base or triphone) id in the given buf.
int mdef_hmm_cmp (mdef_t *m, int p1, int p2)
 Compare the underlying HMMs for two given phones (i.e., compare the two transition matrix IDs and the individual state(senone) IDs).
void mdef_report (mdef_t *m)
 Report the model definition's parameters.
void mdef_free_recursive_lc (ph_lc_t *lc)
 RAH, For freeing memory.
void mdef_free_recursive_rc (ph_rc_t *rc)
void mdef_free (mdef_t *mdef)
 Free an mdef_t.

Detailed Description

Model definition.

Definition in file mdef.h.

Macro Definition Documentation

◆ mdef_cd2cisen

#define mdef_cd2cisen ( m)
Value:
((m)->cd2cisen)

Definition at line 178 of file mdef.h.

◆ mdef_is_fillerphone

#define mdef_is_fillerphone ( m,
p )
Value:
((m)->ciphone[p].filler)

Access macros; not meant for arbitrary use.

Definition at line 165 of file mdef.h.

◆ mdef_n_ciphone

#define mdef_n_ciphone ( m)
Value:
((m)->n_ciphone)

Definition at line 166 of file mdef.h.

◆ mdef_n_emit_state

#define mdef_n_emit_state ( m)
Value:
((m)->n_emit_state)

Definition at line 169 of file mdef.h.

◆ mdef_n_phone

#define mdef_n_phone ( m)
Value:
((m)->n_phone)

Definition at line 167 of file mdef.h.

◆ mdef_n_sen

#define mdef_n_sen ( m)
Value:
((m)->n_sen)

Definition at line 170 of file mdef.h.

◆ mdef_n_sseq

#define mdef_n_sseq ( m)
Value:
((m)->n_sseq)

Definition at line 168 of file mdef.h.

◆ mdef_n_tmat

#define mdef_n_tmat ( m)
Value:
((m)->n_tmat)

Definition at line 171 of file mdef.h.

◆ mdef_pid2ci

#define mdef_pid2ci ( m,
p )
Value:
((m)->phone[p].ci)

Definition at line 177 of file mdef.h.

◆ mdef_pid2ssid

#define mdef_pid2ssid ( m,
p )
Value:
((m)->phone[p].ssid)

Definition at line 172 of file mdef.h.

◆ mdef_pid2tmatid

#define mdef_pid2tmatid ( m,
p )
Value:
((m)->phone[p].tmat)

Definition at line 173 of file mdef.h.

◆ mdef_sen2cimap

#define mdef_sen2cimap ( m)
Value:
((m)->sen2cimap)

Definition at line 175 of file mdef.h.

◆ mdef_silphone

#define mdef_silphone ( m)
Value:
((m)->sil)

Definition at line 174 of file mdef.h.

◆ mdef_sseq2sen

#define mdef_sseq2sen ( m,
ss,
pos )
Value:
((m)->sseq[ss][pos])

Definition at line 176 of file mdef.h.

◆ N_WORD_POSN

#define N_WORD_POSN   4

total # of word positions (excluding undefined)

Definition at line 79 of file mdef.h.

Referenced by bin_mdef_phone_id(), bin_mdef_read_text(), mdef_free(), and mdef_phone_id().

◆ S3_SILENCE_CIPHONE

#define S3_SILENCE_CIPHONE   "SIL"

Hard-coded silence CI phone name.

Definition at line 81 of file mdef.h.

Referenced by bin_mdef_read().

◆ WPOS_NAME

#define WPOS_NAME   "ibesu"

Printable code for each word position above.

Definition at line 80 of file mdef.h.

Referenced by bin_mdef_phone_str(), bin_mdef_read_text(), bin_mdef_write_text(), and mdef_phone_str().

Enumeration Type Documentation

◆ word_posn_t

Union of different type of word position.

Enumerator
WORD_POSN_INTERNAL 

Internal phone of word.

WORD_POSN_BEGIN 

Beginning phone of word.

WORD_POSN_END 

Ending phone of word.

WORD_POSN_SINGLE 

Single phone word (i.e.

begin & end)

WORD_POSN_UNDEFINED 

Undefined value, used for initial conditions, etc.

Definition at line 72 of file mdef.h.

Function Documentation

◆ mdef_ciphone_id()

int mdef_ciphone_id ( mdef_t * m,
char * ciphone )

Get the ciphone id given a string name.

Returns
ciphone id for the given ciphone string name
Parameters
mIn: Model structure being queried
ciphoneIn: ciphone for which id wanted

Definition at line 176 of file mdef.c.

References mdef_t::ciphone_ht.

◆ mdef_ciphone_str()

const char * mdef_ciphone_str ( mdef_t * m,
int ci )

Get the phone string given the ci phone id.

Returns
: READ-ONLY ciphone string name for the given ciphone id
Parameters
mIn: Model structure being queried
ciIn: ciphone id for which name wanted

Definition at line 186 of file mdef.c.

References mdef_t::ciphone, and ciphone_t::name.

◆ mdef_free()

void mdef_free ( mdef_t * mdef)

◆ mdef_free_recursive_lc()

void mdef_free_recursive_lc ( ph_lc_t * lc)

RAH, For freeing memory.

Parameters
lcIn: A list of left context

Definition at line 688 of file mdef.c.

◆ mdef_free_recursive_rc()

void mdef_free_recursive_rc ( ph_rc_t * rc)
Parameters
rcIn: A list of right context

Definition at line 703 of file mdef.c.

◆ mdef_hmm_cmp()

int mdef_hmm_cmp ( mdef_t * m,
int p1,
int p2 )

Compare the underlying HMMs for two given phones (i.e., compare the two transition matrix IDs and the individual state(senone) IDs).

Returns
0 iff the HMMs are identical, -1 otherwise.
Parameters
mIn: Model being queried
p1In: One of the two triphones being compared
p2In: One of the two triphones being compared

◆ mdef_init()

mdef_t * mdef_init ( char * mdeffile,
int breport )

Initialize the phone structure from the given model definition file.

It should be treated as a READ-ONLY structure.

Returns
pointer to the phone structure created.
Parameters
mdeffileIn: Model definition file
breportIn: whether to report the progress or not

◆ mdef_is_ciphone()

int mdef_is_ciphone ( mdef_t * m,
int p )

Decide whether the phone is ci phone.

Returns
1 if given triphone argument is a ciphone, 0 if not, -1 if error
Parameters
mIn: Model structure being queried
pIn: triphone id being queried

Definition at line 251 of file mdef.c.

◆ mdef_is_cisenone()

int mdef_is_cisenone ( mdef_t * m,
int s )

Decide whether the senone is a senone for a ci phone, or a ci senone.

Returns
1 if a given senone is a ci senone
Parameters
mIn: Model structure being queried
sIn: senone id being queried

Definition at line 260 of file mdef.c.

References mdef_t::cd2cisen, and mdef_t::n_sen.

◆ mdef_phone_id()

int mdef_phone_id ( mdef_t * m,
int b,
int l,
int r,
word_posn_t pos )

Decide the phone id given the left, right and base phones.

Returns
: phone id for the given constituents if found, else BAD_S3PID
Parameters
mIn: Model structure being queried
bIn: base ciphone id
lIn: left context ciphone id
rIn: right context ciphone id
posIn: Word position

Definition at line 219 of file mdef.c.

References mdef_t::ciphone, N_WORD_POSN, mdef_t::sil, and mdef_t::wpos_ci_lclist.

◆ mdef_phone_str()

int mdef_phone_str ( mdef_t * m,
int pid,
char * buf )

Create a phone string for the given phone (base or triphone) id in the given buf.

Returns
0 if successful, -1 if error.
Parameters
mIn: Model structure being queried
pidIn: phone id being queried
bufOut: On return, buf has the string

Definition at line 196 of file mdef.c.

References mdef_t::phone, phone_t::rc, phone_t::wpos, and WPOS_NAME.

◆ mdef_report()

void mdef_report ( mdef_t * m)

Report the model definition's parameters.

Parameters
mIn: model definition structure

Definition at line 665 of file mdef.c.

References mdef_t::n_ci_sen, mdef_t::n_ciphone, mdef_t::n_emit_state, mdef_t::n_phone, mdef_t::n_sen, and mdef_t::n_sseq.