Classes | Macros | Typedefs | Enumerations | Functions
mdef.h File Reference

Model definition. More...

#include <stdio.h>
#include <hash_table.h>
#include "s3types.h"

Go to the source code of this file.

Classes

struct  ciphone_t
 CI phone information. More...
 
struct  phone_t
 Triphone information, including base phones as a subset. For the latter, lc, rc and wpos are non-existent. More...
 
struct  ph_rc_s
 
struct  ph_lc_s
 
struct  mdef_t
 strcture for storing the model definition. More...
 

Macros

#define N_WORD_POSN   4
 
#define WPOS_NAME   "ibesu"
 
#define S3_SILENCE_CIPHONE   "SIL"
 
#define mdef_is_fillerphone(m, p)   ((m)->ciphone[p].filler)
 
#define mdef_n_ciphone(m)   ((m)->n_ciphone)
 
#define mdef_n_phone(m)   ((m)->n_phone)
 
#define mdef_n_sseq(m)   ((m)->n_sseq)
 
#define mdef_n_emit_state(m)   ((m)->n_emit_state)
 
#define mdef_n_sen(m)   ((m)->n_sen)
 
#define mdef_n_tmat(m)   ((m)->n_tmat)
 
#define mdef_pid2ssid(m, p)   ((m)->phone[p].ssid)
 
#define mdef_pid2tmatid(m, p)   ((m)->phone[p].tmat)
 
#define mdef_silphone(m)   ((m)->sil)
 
#define mdef_sen2cimap(m)   ((m)->sen2cimap)
 
#define mdef_sseq2sen(m, ss, pos)   ((m)->sseq[ss][pos])
 
#define mdef_pid2ci(m, p)   ((m)->phone[p].ci)
 
#define mdef_cd2cisen(m)   ((m)->cd2cisen)
 

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

S3DECODER_EXPORT mdef_tmdef_init (const char *mdeffile, int32 breport)
 
s3cipid_t mdef_ciphone_id (mdef_t *m, const char *ciphone)
 
S3DECODER_EXPORT const char * mdef_ciphone_str (mdef_t *m, s3cipid_t ci)
 
int32 mdef_is_ciphone (mdef_t *m, s3pid_t p)
 
int32 mdef_is_cisenone (mdef_t *m, s3senid_t s)
 
S3DECODER_EXPORT s3pid_t mdef_phone_id (mdef_t *m, s3cipid_t b, s3cipid_t l, s3cipid_t r, word_posn_t pos)
 
S3DECODER_EXPORT s3pid_t mdef_phone_id_nearest (mdef_t *m, s3cipid_t b, s3cipid_t l, s3cipid_t r, word_posn_t pos)
 
S3DECODER_EXPORT int32 mdef_phone_str (mdef_t *m, s3pid_t pid, char *buf)
 
S3DECODER_EXPORT int32 mdef_phone_components (mdef_t *m, s3pid_t p, s3cipid_t *b, s3cipid_t *l, s3cipid_t *r, word_posn_t *pos)
 
int32 mdef_hmm_cmp (mdef_t *m, s3pid_t p1, s3pid_t p2)
 
void mdef_sseq2sen_active (mdef_t *mdef, uint8 *sseq, uint8 *sen)
 
void mdef_dump (FILE *fp, mdef_t *m)
 
void mdef_report (mdef_t *m)
 
void mdef_free_recursive_lc (ph_lc_t *lc)
 
void mdef_free_recursive_rc (ph_rc_t *rc)
 
S3DECODER_EXPORT void mdef_free (mdef_t *mdef)
 

Detailed Description

Model definition.

Macro Definition Documentation

◆ mdef_cd2cisen

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

◆ mdef_is_fillerphone

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

Access macros; not meant for arbitrary use

◆ mdef_n_ciphone

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

◆ mdef_n_emit_state

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

◆ mdef_n_phone

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

◆ mdef_n_sen

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

◆ mdef_n_sseq

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

◆ mdef_n_tmat

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

◆ mdef_pid2ci

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

◆ mdef_pid2ssid

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

◆ mdef_pid2tmatid

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

◆ mdef_sen2cimap

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

◆ mdef_silphone

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

◆ mdef_sseq2sen

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

◆ N_WORD_POSN

#define N_WORD_POSN   4

total # of word positions (excluding undefined)

◆ S3_SILENCE_CIPHONE

#define S3_SILENCE_CIPHONE   "SIL"

Hard-coded silence CI phone name

◆ WPOS_NAME

#define WPOS_NAME   "ibesu"

Printable code for each word position above

Typedef Documentation

◆ ph_lc_t

typedef struct ph_lc_s ph_lc_t

◆ ph_rc_t

typedef struct ph_rc_s ph_rc_t

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

Function Documentation

◆ mdef_ciphone_id()

s3cipid_t mdef_ciphone_id ( mdef_t m,
const 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

◆ mdef_ciphone_str()

S3DECODER_EXPORT const char* mdef_ciphone_str ( mdef_t m,
s3cipid_t  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

◆ mdef_dump()

void mdef_dump ( FILE *  fp,
mdef_t m 
)

For debugging: dump the mdef_t structure out.

Parameters
fpIn: a file pointer
mIn: a model definition structure

◆ mdef_free()

S3DECODER_EXPORT void mdef_free ( mdef_t mdef)

Free an mdef_t

Parameters
mdefIn : The model definition

◆ mdef_free_recursive_lc()

void mdef_free_recursive_lc ( ph_lc_t lc)

RAH, For freeing memory

Parameters
lcIn: A list of left context

◆ mdef_free_recursive_rc()

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

◆ mdef_hmm_cmp()

int32 mdef_hmm_cmp ( mdef_t m,
s3pid_t  p1,
s3pid_t  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()

S3DECODER_EXPORT mdef_t* mdef_init ( const char *  mdeffile,
int32  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()

int32 mdef_is_ciphone ( mdef_t m,
s3pid_t  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

◆ mdef_is_cisenone()

int32 mdef_is_cisenone ( mdef_t m,
s3senid_t  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

◆ mdef_phone_components()

S3DECODER_EXPORT int32 mdef_phone_components ( mdef_t m,
s3pid_t  p,
s3cipid_t b,
s3cipid_t l,
s3cipid_t r,
word_posn_t pos 
)

Obtain phone components: inverse of mdef_phone_id().

Returns
0 if successful, -1 otherwise.
Parameters
mIn: Model structure being queried
pIn: triphone id being queried
bOut: base ciphone id
lOut: left context ciphone id
rOut: right context ciphone id
posOut: Word position

◆ mdef_phone_id()

S3DECODER_EXPORT s3pid_t mdef_phone_id ( mdef_t m,
s3cipid_t  b,
s3cipid_t  l,
s3cipid_t  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

◆ mdef_phone_id_nearest()

S3DECODER_EXPORT s3pid_t mdef_phone_id_nearest ( mdef_t m,
s3cipid_t  b,
s3cipid_t  l,
s3cipid_t  r,
word_posn_t  pos 
)

Like phone_id, but backs off to other word positions if exact triphone not found. Also, non-SILENCE_PHONE filler phones back off to SILENCE_PHONE. Ultimately, backs off to base phone id. Thus, it should never return 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

◆ mdef_phone_str()

S3DECODER_EXPORT int32 mdef_phone_str ( mdef_t m,
s3pid_t  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

◆ mdef_report()

void mdef_report ( mdef_t m)

Report the model definition's parameters

Parameters
mIn: model definition structure

◆ mdef_sseq2sen_active()

void mdef_sseq2sen_active ( mdef_t mdef,
uint8 *  sseq,
uint8 *  sen 
)

From the given array of active senone-sequence flags, mark the corresponding senones that are active. Caller responsible for allocating sen[], and for clearing it, if necessary.

Parameters
mdefIn: The model definition
sseqIn: sseq[ss] is != 0 iff senone-sequence ID ss is active
senIn/Out: Set sen[s] to non-0 if so indicated by any active senone sequence