Package gmisclib :: Module MLF_file :: Class block_MLF_file
[frames] | no frames]

Class block_MLF_file

source code


This class reads in and stores a MLF file. It does not interpret the interior data, but rather just breaks it up into blocks, each corresponding to an utterance.

Instance Methods
 
__init__(self, fname, preprocessor=None)
Read in a MLF file and store the information in self.block.
source code
 
get(self, key)
Get a block of text from a MLF file.
source code
list(tuple(start, end, label, ...), ...)
get3(self, key, n=3)
Get a block of time-aligned labels from a MLF file and interpret it.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  Quantum = 1e-07
Instance Variables
  block
self.block is where all the data is kept.
  fname
The name of the MLF file
  blockname
Mapping from a file pattern to the name of the block.
Properties

Inherited from object: __class__

Method Details

__init__(self, fname, preprocessor=None)
(Constructor)

source code 

Read in a MLF file and store the information in self.block.

Parameters:
  • fname (str) - Filename to read
  • preprocessor (function str -> str) - A function to project the name of each block onto something that you want to use as an index of blocks. Typically, this function cleans up the names, removing asterisks and such.
Overrides: object.__init__

get3(self, key, n=3)

source code 

Get a block of time-aligned labels from a MLF file and interpret it.

Returns: list(tuple(start, end, label, ...), ...)
(start, end, label, ...) tuples, with start and end in seconds, label is a string indicating a phoneme or word or whatever. If there is more information on a line, it will be passed along in the tuple.

Instance Variable Details

block

self.block is where all the data is kept. This is a dictionary mapping from a file pattern (name, roughly) to a block of label information. The block is a list of strings, one per line in the MLF file. The file pattern is the output of preprocessor. dict(str: list(str))