Code

Matlab code

readnist.m is a function that reads a sound file in TIMIT, NTIMIT, CTIMIT or Switchboard. These are all files with NIST SPHERE headers. Example usage:

  [ts,sr] = readnist ('/blah/blah1/ntimit/dr1/fcjf0/SA1');

It returns ts, a Nx1 vector of integers, and sr, the sample rate of the file. (16000 for N/TIMIT, 8000 for C/TIMIT and Switchboard). The number of seconds the sound file lasts for is N/sr; N is the number of samples. The readnist.m file takes care of annoying details like file extensions and byte order.

If Matlab likes your sound card, then you can play the sound in the soundfile with

  soundsc (ts,sr);

If Matlab doesnt like your sound card, a QnD (Quick and Dirty) check to see if your ts vector is reasonable is to say

hist (ts,1000);

A real speech sound file has a high kurtosis, very peaked near 0. A more flat distribution suggests it was read with a wrong byte order.

Note that the integers in ts are not in the same range for all corpora. For instance, values of ts for a TIMIT file are between (about) -3200 and 3200 while those for Switchboard are between (about) -32000 and 32000. soundsc normalizes this so you don't notice, but the other code you're using may not.

multitaper.m gets a multitaper spectrum. If you have ts and sr from READNIST above, and you want to use 20ms windows moved every 5 ms, type

  [S,Tms] = multitaper (ts,sr,20,5);

There are other configurable options, see the code for details. Meanwhile, log(S) gives you a spectrogram, and Tms gives you the index labels in milliseconds.


Home