Beispiel #1
0
/** 
 * Write hmmlist (logical-to-physical mapping table) and
 * cdset (pseudo phone set) to file.
 * 
 * @param fp [in] file pointer to write
 * @param hmminfo [in] HMM definition data
 * 
 * @return TRUE on success, FALSE on failure.
 */
boolean
save_hmmlist_bin(FILE *fp, HTK_HMM_INFO *hmminfo)
{
  /* write 4 byte as NULL to auto detect file format at read time */
  /* this mark will be read in init_hmminfo() */
  int x = 0;
  if (myfwrite(&x, sizeof(int), 1, fp) < 1) {
    jlog("Error: save_hmmlist_bin: failed to write hmmlist to binary file\n");
    return FALSE;
  }
  /* write hmmlist */
  if (aptree_write(fp, hmminfo->logical_root, save_hmmlist_callback) == FALSE) {
    jlog("Error: save_hmmlist_bin: failed to write hmmlist to binary file\n");
    return FALSE;
  }
  /* write cdset */
  if (aptree_write(fp, hmminfo->cdset_info.cdtree, save_cdset_callback) == FALSE) {
    jlog("Error: save_hmmlist_bin: failed to write cdset to binary file\n");
    return FALSE;
  }
  return TRUE;
}
boolean
save_hmmlist_bin(FILE *fp, HTK_HMM_INFO *hmminfo)
{
  /* set mark */
  int x = 0;
  if (myfwrite(&x, sizeof(int), 1, fp) < 1) {
    jlog("Error: save_hmmlist_bin: failed to write hmmlist to binary file\n");
    return FALSE;
  }
  if (aptree_write(fp, hmminfo->logical_root, save_hmmlist_callback) == FALSE) {
    jlog("Error: save_hmmlist_bin: failed to write hmmlist to binary file\n");
    return FALSE;
  }
  return TRUE;
}