[Subject Prev][Subject Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hts-users:01302] Re: Endianism problems


Hi,

Nicholas Volk wrote (2008/04/01 3:46):

I'm trying to build run the HTS 2.1 RC1 demo script using Cygwin/Windows.

However, it fails in "hts_engine (synthesizing waveforms using
hts_engine)", mpre specifically when loading gv[0] (GV for spectrum) (see
hts_engine.c) fails
with a failed memory allocation:

"Error: HTS_calloc: Cannot allocate memory 1065992344/4."

The exact line which fails is

         model->pdf[j] =
             (double **) HTS_calloc(model->npdf[j], sizeof(double *));

in HTS_model.c.

The huge number implies an endianism issue.
Am I correct, when I presume that your native architectures are
high-endian ones? (I've had similar problems in the past but there it was
easy enough for me to find the appropriate line and change the read
endianism. The latest version seems far more complex at the first sight as
the same code is used with success earlier on. Will look at this more
later.)

hts_engine uses big endian for all binary files.
In HTS-demo_CMU-ARCTIC-SLT/data/Makefile, you can find the following lines:

       # GV pdfs in big endian (for hts_engine)
       if [ $(BYTESWAP) -eq 1 ]; then \
               cp gv/gv-mgc.pdf gv/gv-mgc.pdf.big; \
               cp gv/gv-lf0.pdf gv/gv-lf0.pdf.big; \
       else \
               $(SWAB) +f gv/gv-mgc.pdf > gv/gv-mgc.pdf.big; \
               $(SWAB) +f gv/gv-lf0.pdf > gv/gv-lf0.pdf.big; \
       fi; \

       rm -f gvdata_mgc gvdata_lf0; \

BYTESWAP is 0 on little endian environments and 1 on big endian.
So the above codes stores gv/gv-*.pdf.big in big endian.
These files are copied to voices directory by scripts/Training.pl as
  # gv pdfs
  foreach $type (@cmp) {
     shell("cp $gvpdf{$type}.big $voice/gv-${type}.pdf");
  }

They are loaded by hts_engine using hts_engine_API/src/lib/HTS_misc.c:HTS_fread() as

/* HTS_fread: fread with byteswap */
int HTS_fread_big_endian(void *p, const int size, const int num, FILE * fp)
{
  const int block = fread(p, size, num, fp);

#ifdef WORDS_LITTLEENDIAN
  HTS_byte_swap(p, size, block);
#endif                          /* WORDS_LITTLEENDIAN */

  return block;
}

If you want to use little endian, please modify these parts.

Regards,

Heiga ZEN (Byung Ha CHUN)

--
------------------------------------------------
Heiga ZEN     (in Japanese pronunciation)
Byung Ha CHUN (in Korean pronunciation)

Department of Computer Science and Engineering
Nagoya Institute of Technology
Gokiso-cho, Showa-ku, Nagoya 466-8555 Japan

http://www.sp.nitech.ac.jp/~zen
------------------------------------------------

Follow-Ups
[hts-users:01303] Re: Endianism problems, Ore, Brian M CTR USAF AFMC AFRL/RHCP
References
[hts-users:01300] Endianism problems, Nicholas Volk