Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

init_phmm.c

Go to the documentation of this file.
00001 
00017 /*
00018  * Copyright (c) 1991-2006 Kawahara Lab., Kyoto University
00019  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00020  * Copyright (c) 2005-2006 Julius project team, Nagoya Institute of Technology, Nagoya Institute of Technology
00021  * All rights reserved
00022  */
00023 
00024 #include <sent/stddefs.h>
00025 #include <sent/htk_hmm.h>
00026 
00027 /* initialize phoneme HMM structure */
00033 HTK_HMM_INFO *
00034 hmminfo_new()
00035 {
00036   HTK_HMM_INFO *new;
00037 
00038   new = (HTK_HMM_INFO *)mymalloc(sizeof(HTK_HMM_INFO));
00039 
00040   return(new);
00041 }
00042 
00052 void
00053 init_hmminfo(HTK_HMM_INFO *hmminfo, char *hmmfilename, char *namemapfile)
00054 {
00055   FILE *fp;
00056   boolean ok_p;
00057 
00058   ok_p = FALSE;
00059 
00060   /* read hmmdef file */
00061   j_printerr("Reading in HMM definition...");
00062   /* first, try ascii format */
00063   if ((fp = fopen_readfile(hmmfilename)) == NULL) {
00064     j_error("failed to open %s\n",hmmfilename);
00065   }
00066   if (rdhmmdef(fp, hmminfo) == TRUE) {
00067     ok_p = TRUE;
00068   }
00069   if (fclose_readfile(fp) < 0) {
00070     j_error("failed to close %s\n", hmmfilename);
00071   }
00072   if (ok_p == FALSE) {
00073     /* second, try binary format */
00074     if ((fp = fopen_readfile(hmmfilename)) == NULL) {
00075       j_error("failed to open %s\n",hmmfilename);
00076     }
00077     if (read_binhmm(fp, hmminfo) == TRUE) {
00078       ok_p = TRUE;
00079     }
00080     if (fclose_readfile(fp) < 0) {
00081       j_error("failed to close %s\n", hmmfilename);
00082     }
00083   }
00084   if (ok_p == FALSE) {
00085     j_error("failed to read %s\n", hmmfilename);
00086   }
00087 
00088   j_printerr("   defined HMMs: %5d\n", hmminfo->totalhmmnum);
00089 
00090   /* make mapping from logically named HMM to real defined HMM name */
00091   if (namemapfile != NULL) {
00092     /* use HMMList map file */
00093     if ((fp = fopen_readfile(namemapfile)) == NULL) {
00094       j_error("failed to open %s\n",namemapfile);
00095     }
00096     if (rdhmmlist(fp, hmminfo) == FALSE) {
00097       j_error("HMMList \"%s\" read error\n",namemapfile);
00098     }
00099     if (fclose_readfile(fp) < 0) {
00100       j_error("failed to close %s\n", namemapfile);
00101     }
00102     j_printerr("  logical names: %5d in HMMList\n", hmminfo->totallogicalnum);
00103   } else {
00104     /* add all names of physical HMMs as logical names */
00105     hmm_add_physical_to_logical(hmminfo);
00106     j_printerr("  logical names: %5d\n", hmminfo->totallogicalnum);
00107   }
00108 
00109   /* extract basephone */
00110   make_hmm_basephone_list(hmminfo);
00111   j_printerr("    base phones: %5d used in logical\n", hmminfo->basephone.num);
00112 
00113   /* Guess we need to handle context dependency */
00114   /* (word-internal CD is done statically, cross-word CD dynamically */
00115   if (guess_if_cd_hmm(hmminfo)) {
00116     hmminfo->is_triphone = TRUE;
00117   } else {
00118     hmminfo->is_triphone = FALSE;
00119   }
00120 
00121   hmminfo->sp = NULL;
00122 
00123   j_printerr("done\n");
00124 }
00125 
00132 void
00133 htk_hmm_set_pause_model(HTK_HMM_INFO *hmminfo, char *spmodel_name)
00134 {
00135   HMM_Logical *l;
00136 
00137   l = htk_hmmdata_lookup_logical(hmminfo, spmodel_name);
00138   if (l == NULL) {
00139     j_printerr("Warning: no model named as \"%s\"\n", spmodel_name);
00140   }
00141   hmminfo->sp = l;
00142 }

Generated on Tue Mar 28 16:01:39 2006 for Julius by  doxygen 1.4.2