Package nltk_lite :: Package corpora :: Module timit
[hide private]
[frames] | no frames]

Module timit

source code


Read tokens, phonemes and audio data from the NLTK TIMIT Corpus.

This corpus contains selected portion of the TIMIT corpus.

* 16 speakers from 8 dialect regions
* 1 male and 1 female from each dialect region
* total 130 sentences (10 sentences per speaker.  Note that some
  sentences are shared among other speakers, especially sa1 and sa2
  are spoken by all speakers.)
* total 160 recording of sentences (10 recordings per speaker)
* audio format: NIST Sphere, single channel, 16kHz sampling,
  16 bit sample, PCM encoding


Module contents
---------------

The timit module provides 4 functions and 4 data items.

* items

  List of items in the corpus.  There are total 160 items, each of which
  corresponds to a unique utterance of a speaker.  Here's an example of an
  item in the list:

      dr1-fvmh0:sx206
        - _----  _---
        | |  |   | |
        | |  |   | |
        | |  |   | `--- sentence number
        | |  |   `----- sentence type (a:all, i:shared, x:exclusive)
        | |  `--------- speaker ID
        | `------------ sex (m:male, f:female)
        `-------------- dialect region (1..8)

* speakers

  List of speaker IDs.  An example of speaker ID:

      dr1-fvmh0

  Note that if you split an item ID with colon and take the first element of
  the result, you will get a speaker ID.

      >>> itemid = dr1-fvmh0:sx206
      >>> spkrid,sentid = itemid.split(':')
      >>> spkrid
      'dr1-fvmh0'
      
  The second element of the result is a sentence ID.
  
* dictionary

  Phonetic dictionary of words contained in this corpus.  This is a Python
  dictionary from words to phoneme lists.
  
* spkrinfo

  Speaker information table.  It's a Python dictionary from speaker IDs to
  records of 10 fields.  Speaker IDs the same as the ones in timie.speakers.
  Each record is a dictionary from field names to values, and the fields are
  as follows:

    id         speaker ID as defined in the original TIMIT speaker info table
    sex        speaker gender (M:male, F:female)
    dr         speaker dialect region (1:new england, 2:northern,
               3:north midland, 4:south midland, 5:southern, 6:new york city,
               7:western, 8:army brat (moved around))
    use        corpus type (TRN:training, TST:test)
               in this sample corpus only TRN is available
    recdate    recording date
    birthdate  speaker birth date
    ht         speaker height
    race       speaker race (WHT:white, BLK:black, AMR:american indian,
               SPN:spanish-american, ORN:oriental,???:unknown)
    edu        speaker education level (HS:high school, AS:associate degree,
               BS:bachelor's degree (BS or BA), MS:master's degree (MS or MA),
               PHD:doctorate degree (PhD,JD,MD), ??:unknown)
    comments   comments by the recorder
  
The 4 functions are as follows.

* raw(sentences=items, offset=False)

  Given a list of items, returns an iterator of a list of word lists,
  each of which corresponds to an item (sentence).  If offset is set to True,
  each element of the word list is a tuple of word(string), start offset and
  end offset, where offset is represented as a number of 16kHz samples.
    
* phonetic(sentences=items, offset=False)

  Given a list of items, returns an iterator of a list of phoneme lists,
  each of which corresponds to an item (sentence).  If offset is set to True,
  each element of the phoneme list is a tuple of word(string), start offset
  and end offset, where offset is represented as a number of 16kHz samples.

* audiodata(item, start=0, end=None)

  Given an item, returns a chunk of audio samples formatted into a string.
  When the fuction is called, if start and end are omitted, the entire
  samples of the recording will be returned.  If only end is omitted,
  samples from the start offset to the end of the recording will be returned.

* play(data)

  Play the given audio samples. The audio samples can be obtained from the
  timit.audiodata function.

Functions [hide private]
 
_prim(ext, sentences=['dr1-fvmh0:sa1', 'dr1-fvmh0:sa2', 'dr1-fvmh0:si1466', 'dr1-fv..., offset=True) source code
 
raw(sentences=['dr1-fvmh0:sa1', 'dr1-fvmh0:sa2', 'dr1-fvmh0:si1466', 'dr1-fv..., offset=True)
Given a list of items, returns an iterator of a list of word lists, each of which corresponds to an item (sentence).
source code
 
phonetic(sentences=['dr1-fvmh0:sa1', 'dr1-fvmh0:sa2', 'dr1-fvmh0:si1466', 'dr1-fv..., offset=True)
Given a list of items, returns an iterator of a list of phoneme lists, each of which corresponds to an item (sentence).
source code
 
audiodata(item, start=0, end=None)
Given an item, returns a chunk of audio samples formatted into a string.
source code
 
play(data)
Play the given audio samples.
source code
 
demo() source code
Variables [hide private]
  PLAY_ENABLED = True
  PREFIX = '/usr/share/nltk_lite/timit'
  speakers = ['dr1-fvmh0', 'dr1-mcpm0', 'dr2-faem0', 'dr2-marc0'...
  items = ['dr1-fvmh0:sa1', 'dr1-fvmh0:sa2', 'dr1-fvmh0:si1466',...
  dictionary = {'a': ['ax'], 'able': ['ey1', 'b', 'el'], 'about'...
  spkrinfo = {'dr1-fvmh0': {'birthdate': '01/08/60', 'comments':...
  header = ['id', 'sex', 'dr', 'use', 'recdate', 'birthdate', 'h...
  a = ['zoos', '/z uw1 z/']
  f = 'dr7-madd0'
  g = 'si1798.wrd'
  key = 'dr8-fbcg1'
  l = 'BCG1 F 8 TRN 04/09/86 02/23/59 4\'9" ??? BS \n'
  rec = ['BCG1', 'F', '8', 'TRN', '04/09/86', '02/23/59', '4\'9"...
Function Details [hide private]

raw(sentences=['dr1-fvmh0:sa1', 'dr1-fvmh0:sa2', 'dr1-fvmh0:si1466', 'dr1-fv..., offset=True)

source code 

Given a list of items, returns an iterator of a list of word lists, each of which corresponds to an item (sentence). If offset is set to True, each element of the word list is a tuple of word(string), start offset and end offset, where offset is represented as a number of 16kHz samples.

Parameters:
  • sentences (list of strings or a string) - List of items (sentences) for which tokenized word list will be returned. In case there is only one item, it is possible to pass the item id as a string.
  • offset (bool) - If True, the start and end offsets are accompanied to each word in the returned list. Note that here, an offset is represented by the number of 16kHz samples.
Returns:
List of list of strings (words) if offset is False. List of list of tuples (word, start offset, end offset) if offset if True.

phonetic(sentences=['dr1-fvmh0:sa1', 'dr1-fvmh0:sa2', 'dr1-fvmh0:si1466', 'dr1-fv..., offset=True)

source code 

Given a list of items, returns an iterator of a list of phoneme lists, each of which corresponds to an item (sentence). If offset is set to True, each element of the phoneme list is a tuple of word(string), start offset and end offset, where offset is represented as a number of 16kHz samples.

Parameters:
  • sentences (list of strings or a string) - List of items (sentences) for which phoneme list will be returned. In case there is only one item, it is possible to pass the item id as a string.
  • offset (bool) - If True, the start and end offsets are accompanied to each phoneme in the returned list. Note that here, an offset is represented by the number of 16kHz samples.
Returns:
List of list of strings (phonemes) if offset is False. List of list of tuples (phoneme, start offset, end offset) if offset if True.

audiodata(item, start=0, end=None)

source code 

Given an item, returns a chunk of audio samples formatted into a string. When the fuction is called, if start and end are omitted, the entire samples of the recording will be returned. If only end is omitted, samples from the start offset to the end of the recording will be returned.

Parameters:
  • start (integer (number of 16kHz frames)) - start offset
  • end (integer (number of 16kHz frames) or None to indicate the end of file) - end offset
Returns:
string of sequence of bytes of audio samples

play(data)

source code 

Play the given audio samples.

Parameters:
  • data (string of bytes of audio samples) - audio samples

Variables Details [hide private]

speakers

Value:
['dr1-fvmh0',
 'dr1-mcpm0',
 'dr2-faem0',
 'dr2-marc0',
 'dr3-falk0',
 'dr3-madc0',
 'dr4-falr0',
 'dr4-maeb0',
...

items

Value:
['dr1-fvmh0:sa1',
 'dr1-fvmh0:sa2',
 'dr1-fvmh0:si1466',
 'dr1-fvmh0:si2096',
 'dr1-fvmh0:si836',
 'dr1-fvmh0:sx116',
 'dr1-fvmh0:sx206',
 'dr1-fvmh0:sx26',
...

dictionary

Value:
{'a': ['ax'],
 'able': ['ey1', 'b', 'el'],
 'about': ['ax', 'b', 'aw1', 't'],
 'according': ['ax', 'k', 'ao1', 'r', 'd', 'ix', 'ng'],
 'action': ['ae1', 'k', 'sh', 'ix', 'n'],
 'advisement': ['ax', 'd', 'v', 'ay1', 'z', 'm', 'ax', 'n', 't'],
 'after': ['ae1', 'f', 't', 'axr'],
 'again': ['ax', 'g', 'eh1', 'n'],
...

spkrinfo

Value:
{'dr1-fvmh0': {'birthdate': '01/08/60',
               'comments': 'BEST NEW ENGLAND ACCENT SO FAR',
               'dr': '1',
               'edu': 'BS',
               'ht': '5\'05"',
               'id': 'VMH0',
               'race': 'WHT',
               'recdate': '03/11/86',
...

header

Value:
['id',
 'sex',
 'dr',
 'use',
 'recdate',
 'birthdate',
 'ht',
 'race',
...

rec

Value:
['BCG1',
 'F',
 '8',
 'TRN',
 '04/09/86',
 '02/23/59',
 '4\'9"',
 '???',
...