Julius 4.1.5
|
00001 00018 /* 00019 * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University 00020 * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology 00021 * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology 00022 * All rights reserved 00023 */ 00024 00025 #include <sent/stddefs.h> 00026 #include <sent/htk_hmm.h> 00027 #include <sent/vocabulary.h> 00028 00040 boolean 00041 init_voca(WORD_INFO *winfo, char *filename, HTK_HMM_INFO *hmminfo, boolean not_conv_tri, boolean force_dict) 00042 { 00043 FILE *fd; 00044 00045 if ((fd = fopen_readfile(filename)) == NULL) { 00046 jlog("Error: init_voca: failed to open %s\n",filename); 00047 return(FALSE); 00048 } 00049 if (!voca_load_htkdict(fd, winfo, hmminfo, not_conv_tri)) { 00050 if (force_dict) { 00051 jlog("Warning: init_voca: the word errors are ignored\n"); 00052 } else { 00053 jlog("Error: init_voca: error in reading %s: %d words failed out of %d words\n",filename, winfo->errnum, winfo->num); 00054 fclose_readfile(fd); 00055 return(FALSE); 00056 } 00057 } 00058 if (fclose_readfile(fd) == -1) { 00059 jlog("Error: init_voca: failed to close\n"); 00060 return(FALSE); 00061 } 00062 00063 jlog("Stat: init_voca: read %d words\n", winfo->num); 00064 return(TRUE); 00065 } 00066 00080 boolean 00081 init_wordlist(WORD_INFO *winfo, char *filename, HTK_HMM_INFO *hmminfo, char *headphone, char *tailphone, char *contextphone, boolean force_dict) 00082 { 00083 FILE *fd; 00084 00085 jlog("Stat: init_wordlist: reading in word list\n"); 00086 if ((fd = fopen_readfile(filename)) == NULL) { 00087 jlog("Error: init_wordlist: failed to open %s\n",filename); 00088 return(FALSE); 00089 } 00090 if (!voca_load_wordlist(fd, winfo, hmminfo, headphone, tailphone, contextphone)) { 00091 if (force_dict) { 00092 jlog("Warning: init_wordlist: the word errors are ignored\n"); 00093 } else { 00094 jlog("Error: init_wordlist: error in reading %s: %d words failed out of %d words\n",filename, winfo->errnum, winfo->num); 00095 fclose_readfile(fd); 00096 return(FALSE); 00097 } 00098 } 00099 if (fclose_readfile(fd) == -1) { 00100 jlog("Error: init_wordlist: failed to close\n"); 00101 return(FALSE); 00102 } 00103 00104 jlog("Stat: init_wordlist: read %d words\n", winfo->num); 00105 return(TRUE); 00106 }