Newsgroups: comp.speech
Path: lyra.csx.cam.ac.uk!doc.ic.ac.uk!agate!ihnp4.ucsd.edu!usc!sol.ctr.columbia.edu!news.kei.com!MathWorks.Com!zombie.ncsc.mil!afterlife!jpcampb
From: jpcampb@afterlife.ncsc.mil (Joe Campbell)
Subject: Re: Speech file format?
Message-ID: <1994Apr9.195817.12471@afterlife.ncsc.mil>
Organization: The Great Beyond
References: <2n9qm2$2m0@saturn.haverford.edu>
Distribution: usa
Date: Sat, 9 Apr 1994 19:58:17 GMT
Lines: 53

In article <2n9qm2$2m0@saturn.haverford.edu>,
Wang Yi <ywang@cc.brynmawr.edu> wrote:
>Hi,
>	We are doing wavelet transforms on speech signals.  Recently we
>received some speech files from other sources which were in binary format.
>There files have headers of ILS type.  We don't know what that means and
>we would like to transform the files into ascii format.
>	 We would appreciate any help and info.  Please reply to
>	ywang@cc.brynmawr.edu

Believe it or not, ILS format doesn't appear to be covered in Guido's
massive 931226 Audio Formats FAQ!  I'll take a stab at it and hope
that others will jump in a correct me if I'm mistaken (and cc to Guido).

As I recall, the ILS header usually has a fixed 128 or 265 byte length,
although I believe that there is a popular ILS variation by BBN where the
header contains a field that specifies the header length, i.e., variable
length headers (if you're on a UNIX platform, you could use "od -c" to
view these headers to determine their format).  After skipping the ILS
header, the binary speech data is stored in 16-bit samples.  Each sample
is stored as a pair of unsigned bytes.  The order of these bytes (i.e.,
little-endian or big-endian byte order) depends upon the platform that
originated the files.  For example, on Sun worksations, the bytes occur
in upper-byte:lower-byte order (the lower byte contains the least
significant bits).  On VAXen (and PCs?), I'm pretty sure that the order
is reversed.

Here's a chunk of C code that will allow you to convert the speech samples
to whatever you want (Sun architecture byte order is assumed):

float sn;

 int s_int;
 unsigned char hi_byte, lo_byte;

	/* "*.spd" speech data file format: 16-bit, 2's comp, hi|lo bytes */

	hi_byte = getc(stdin);
	lo_byte = getc(stdin);

	s_int = (hi_byte<<8) + lo_byte;
	if (s_int > 32767) s_int -= 65536;

	sn = s_int/32768.0;                /* real [-1, +1) speech sample */


Back to taxes :-(,
Joe
-- 
.............................................................................
; Dr. Campbell  N3JBC  jpcampb@afterlife.ncsc.mil  74040.305@compuserve.com ;
; Speaking for myself     Happiness = Reality - Expectations, Click & Clack ;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
