libsent/src/voca/voca_load_htkdict.c File Reference

Read word dictionary from a file in HTK format. More...

#include <sent/stddefs.h>
#include <sent/vocabulary.h>
#include <sent/htk_hmm.h>

Go to the source code of this file.

Defines

#define PHONEMELEN_STEP   30
 Memory allocation step for phoneme sequence.

Functions

char * cycle_triphone (char *p)
 Return string of triphone name composed from last 3 call.
char * cycle_triphone_flush ()
 Flush the triphone buffer and return the last biphone.
static void add_to_error (WORD_INFO *winfo, char *name)
 Add a triphone name to the missing error list in WORD_INFO.
static void callback_list_error (void *x)
 Traverse callback function to output a error phone.
static void list_error (WORD_INFO *winfo)
 Output all error phones appeared while readin a word dictionary.
void voca_set_stats (WORD_INFO *winfo)
 Parse a word dictionary and set the maximum state length per word.
void voca_load_start (WORD_INFO *winfo, HTK_HMM_INFO *hmminfo, boolean ignore_tri_conv)
 Start loading a dictionary.
boolean voca_load_line (char *buf, WORD_INFO *winfo, HTK_HMM_INFO *hmminfo)
 Load a line from buffer and set parameters to the dictionary.
boolean voca_load_end (WORD_INFO *winfo)
 End loading dictionary entries.
boolean voca_load_htkdict (FILE *fp, WORD_INFO *winfo, HTK_HMM_INFO *hmminfo, boolean ignore_tri_conv)
 Top function to read word dictionary via file pointer.
boolean voca_load_htkdict_fd (int fd, WORD_INFO *winfo, HTK_HMM_INFO *hmminfo, boolean ignore_tri_conv)
 Top function to read word dictionary via file descriptor.
boolean voca_load_htkdict_sd (int sd, WORD_INFO *winfo, HTK_HMM_INFO *hmminfo, boolean ignore_tri_conv)
 Top function to read word dictionary via socket descriptor.
boolean voca_append_htkdict (char *entry, WORD_INFO *winfo, HTK_HMM_INFO *hmminfo, boolean ignore_tri_conv)
 Append a single entry to the existing word dictionary.
boolean voca_load_htkdict_line (char *buf, WORD_ID *vnum_p, int linenum, WORD_INFO *winfo, HTK_HMM_INFO *hmminfo, boolean do_conv, boolean *ok_flag)
 Sub function to Add a dictionary entry line to the word dictionary.
boolean voca_mono2tri (WORD_INFO *winfo, HTK_HMM_INFO *hmminfo)
 Convert whole words in word dictionary to word-internal triphone.
boolean voca_append (WORD_INFO *dstinfo, WORD_INFO *srcinfo, int coffset, int woffset)
 Append one word dictionary to other, for multiple grammar handling.

Variables

static char buf [MAXLINELEN]
 Local work area for input text processing.
static char bufbak [MAXLINELEN]
 Local work area for debug message.
static char trbuf [3][20]
 Local buffer for triphone convertion.
static char chbuf [30]
 Another local buffer for triphone convertion.
static char nophone [1]
 Local buffer to indicate 'no phone'.
static int trp_l
 Triphone cycle index.
static int trp
 Triphone cycle index.
static int trp_r
 Triphone cycle index.


Detailed Description

Read word dictionary from a file in HTK format.

When using triphone model, conversion from monophone expression in dictionary to triphone and the existence check of word-internal triphone will be done here.

Author:
Akinobu LEE
Date:
Fri Feb 18 19:43:06 2005
Revision
1.1.1.1

Definition in file voca_load_htkdict.c.


Function Documentation

char* cycle_triphone ( char *  p  ) 

Return string of triphone name composed from last 3 call.

Parameters:
p [in] next phone string
Returns:
the composed triphone name, or NULL on end.

Definition at line 80 of file voca_load_htkdict.c.

Referenced by cycle_triphone_flush(), new_str2phseq(), voca_load_htkdict_line(), and voca_load_wordlist_line().

char* cycle_triphone_flush (  ) 

Flush the triphone buffer and return the last biphone.

Returns:
the composed last bi-phone name.

Definition at line 126 of file voca_load_htkdict.c.

Referenced by new_str2phseq(), voca_load_htkdict_line(), and voca_load_wordlist_line().

static void add_to_error ( WORD_INFO winfo,
char *  name 
) [static]

Add a triphone name to the missing error list in WORD_INFO.

Parameters:
winfo [i/o] word dictionary to add the error phone to error list
name [in] phone name to be added

Definition at line 138 of file voca_load_htkdict.c.

static void callback_list_error ( void *  x  )  [static]

Traverse callback function to output a error phone.

Parameters:
x [in] error phone string of the node

Definition at line 161 of file voca_load_htkdict.c.

Referenced by list_error().

static void list_error ( WORD_INFO winfo  )  [static]

Output all error phones appeared while readin a word dictionary.

Parameters:
winfo [in] word dictionary data

Definition at line 173 of file voca_load_htkdict.c.

Referenced by voca_load_end().

void voca_set_stats ( WORD_INFO winfo  ) 

Parse a word dictionary and set the maximum state length per word.

Parameters:
winfo [i/o]

Definition at line 186 of file voca_load_htkdict.c.

Referenced by voca_load_end().

void voca_load_start ( WORD_INFO winfo,
HTK_HMM_INFO hmminfo,
boolean  ignore_tri_conv 
)

Start loading a dictionary.

See voca_load_htkdict() for an example of using this function.

Parameters:
winfo [i/o] dictionary data where the data will be loaded
hmminfo [in] phoneme HMM definition
ignore_tri_conv [in] if TRUE, skip triphone conversion while loading

Definition at line 228 of file voca_load_htkdict.c.

Referenced by voca_load_htkdict(), voca_load_htkdict_fd(), voca_load_htkdict_sd(), and voca_load_wordlist().

boolean voca_load_line ( char *  buf,
WORD_INFO winfo,
HTK_HMM_INFO hmminfo 
)

Load a line from buffer and set parameters to the dictionary.

See voca_load_htkdict() for an example of using this function.

Parameters:
buf [in] input buffer containing a word entry
winfo [i/o] word dictionary to append the entry
hmminfo [in] phoneme HMM definition
Returns:
TRUE when successfully read, or FALSE on encountered end of dictionary. When an error occurs, this function will set winfo->ok_flag to FALSE.

Definition at line 255 of file voca_load_htkdict.c.

Referenced by voca_append_htkdict(), voca_load_htkdict(), voca_load_htkdict_fd(), and voca_load_htkdict_sd().

boolean voca_load_end ( WORD_INFO winfo  ) 

End loading dictionary entries.

It calculates some statistics for the read entries, outputs errors if encountered while the last loading, and returns with status whether an error occured while loading.

Parameters:
winfo [i/o] word dictionary just read by voca_load_line() calls
Returns:
TRUE when no error has been occured during loading, or FALSE if an error occured.

Definition at line 284 of file voca_load_htkdict.c.

Referenced by voca_append_htkdict(), voca_load_htkdict(), voca_load_htkdict_fd(), voca_load_htkdict_sd(), and voca_load_wordlist().

boolean voca_load_htkdict ( FILE *  fp,
WORD_INFO winfo,
HTK_HMM_INFO hmminfo,
boolean  ignore_tri_conv 
)

Top function to read word dictionary via file pointer.

Parameters:
fp [in] file pointer
winfo [out] pointer to word dictionary to store the read data.
hmminfo [in] HTK HMM definition data. if NULL, phonemes are ignored.
ignore_tri_conv [in] TRUE if triphone conversion is ignored
Returns:
TRUE on success, FALSE on any error word.

Definition at line 305 of file voca_load_htkdict.c.

Referenced by init_voca().

boolean voca_load_htkdict_fd ( int  fd,
WORD_INFO winfo,
HTK_HMM_INFO hmminfo,
boolean  ignore_tri_conv 
)

Top function to read word dictionary via file descriptor.

Parameters:
fd [in] file descriptor
winfo [out] pointer to word dictionary to store the read data.
hmminfo [in] HTK HMM definition data. if NULL, phonemes are ignored.
ignore_tri_conv [in] TRUE if triphone conversion is ignored
Returns:
TRUE on success, FALSE on any error word.

Definition at line 330 of file voca_load_htkdict.c.

Referenced by read_grammar_from_socket().

boolean voca_load_htkdict_sd ( int  sd,
WORD_INFO winfo,
HTK_HMM_INFO hmminfo,
boolean  ignore_tri_conv 
)

Top function to read word dictionary via socket descriptor.

Parameters:
sd [in] socket descriptor
winfo [out] pointer to word dictionary to store the read data.
hmminfo [in] HTK HMM definition data. if NULL, phonemes are ignored.
ignore_tri_conv [in] TRUE if triphone conversion is ignored
Returns:
TRUE on success, FALSE on any error word.

Definition at line 354 of file voca_load_htkdict.c.

Referenced by read_grammar_from_socket().

boolean voca_append_htkdict ( char *  entry,
WORD_INFO winfo,
HTK_HMM_INFO hmminfo,
boolean  ignore_tri_conv 
)

Append a single entry to the existing word dictionary.

Parameters:
entry [in] dictionary entry string to be appended.
winfo [out] pointer to word dictionary to append the data.
hmminfo [in] HTK HMM definition data. if NULL, phonemes are ignored.
ignore_tri_conv [in] TRUE if triphone conversion is ignored
Returns:
TRUE on success, FALSE on any error word.

Definition at line 378 of file voca_load_htkdict.c.

Referenced by initialize_dict().

boolean voca_load_htkdict_line ( char *  buf,
WORD_ID vnum_p,
int  linenum,
WORD_INFO winfo,
HTK_HMM_INFO hmminfo,
boolean  do_conv,
boolean *  ok_flag 
)

Sub function to Add a dictionary entry line to the word dictionary.

Parameters:
buf [i/o] buffer to hold the input string, will be modified in this function
vnum_p [in] current number of words in winfo
linenum [in] current line number of the input
winfo [out] pointer to word dictionary to append the data.
hmminfo [in] HTK HMM definition data. if NULL, phonemes are ignored.
do_conv [in] TRUE if performing triphone conversion
ok_flag [out] will be set to FALSE if an error occured for this input.
Returns:
FALSE if buf == "DICEND", else TRUE will be returned.

Definition at line 398 of file voca_load_htkdict.c.

Referenced by voca_load_line().

boolean voca_mono2tri ( WORD_INFO winfo,
HTK_HMM_INFO hmminfo 
)

Convert whole words in word dictionary to word-internal triphone.

Normally triphone conversion will be performed directly when reading dictionary file. This function is for post conversion only.

Parameters:
winfo [i/o] word dictionary information
hmminfo [in] HTK HMM definition
Returns:
TRUE on success, FALSE on failure.

Definition at line 623 of file voca_load_htkdict.c.

boolean voca_append ( WORD_INFO dstinfo,
WORD_INFO srcinfo,
int  coffset,
int  woffset 
)

Append one word dictionary to other, for multiple grammar handling.

Assumes that the same HMM definition is used on both word dictionary.

Parameters:
dstinfo [i/o] word dictionary
srcinfo [in] word dictionary to be appended to dst
coffset [in] category id offset in dst where the new data should be stored
woffset [in] word id offset in dst where the new data should be stored

Definition at line 664 of file voca_load_htkdict.c.

Referenced by multigram_add_words_to_grammar(), multigram_append_to_global(), and multigram_update().


Generated on Tue Dec 18 16:01:41 2007 for Julius by  doxygen 1.5.4