returnn.sprint.cache
#
This module is about reading (maybe later also writing) the Sprint archive format.
- class returnn.sprint.cache.FileInfo(name, pos, size, compressed, index)[source]#
File info.
- Parameters:
name (str) –
pos (int) –
size (int) –
compressed (bool|int) –
index (int) –
- class returnn.sprint.cache.FileArchive(filename, must_exists=True, encoding='ascii')[source]#
File archive.
- read_str(length, encoding='ascii')[source]#
- Parameters:
length (int) –
encoding (str) –
- Return type:
str
- read_v(typ, size)[source]#
- Parameters:
typ (str) – “f” for float (float32) or “d” for double (float64)
size (int) – number of elements to return
- Returns:
numpy array of shape (size,) of dtype depending on typ
- Return type:
numpy.ndarray
- has_entry(filename)[source]#
- Parameters:
filename (str) – argument for self.read()
- Returns:
True if we have this entry
- read(filename, typ)[source]#
- Parameters:
filename (str) – the entry-name in the archive
typ (str) – “str”, “feat” or “align”
- Returns:
depending on typ, “str” -> string, “feat” -> (time, data), “align” -> align, where string is a str, time is list of time-stamp tuples (start-time,end-time) in millisecs,
data is a list of features, each a numpy vector,
- align is a list of (time, allophone, state, weight), time is an int from 0 to len of align,
allophone is some int, state is e.g. in [0,1,2].
- Return type:
str|(list[numpy.ndarray],list[numpy.ndarray])|list[(int,int,int,float)]
- set_allophones(f)[source]#
- Parameters:
f (str) – allophone filename. line-separated. will ignore lines starting with “#”
- class returnn.sprint.cache.FileArchiveBundle(filename=None, encoding='ascii')[source]#
File archive bundle.
- Parameters:
filename (str|None) – .bundle file
encoding (str) – encoding used in the files
- add_bundle(filename, encoding='ascii')[source]#
- Parameters:
filename (str) – bundle
encoding (str) –
- add_archive(filename, encoding='ascii')[source]#
- Parameters:
filename (str) – single archive
encoding (str) –
- add_bundle_or_archive(filename, encoding='ascii')[source]#
- Parameters:
filename (str) –
encoding (str) –
- file_list()[source]#
- Return type:
list[str]
- Returns:
list of content-filenames (which can be used for self.read())
- has_entry(filename)[source]#
- Parameters:
filename (str) – argument for self.read()
- Returns:
True if we have this entry
- read(filename, typ)[source]#
- Parameters:
filename (str) – the entry-name in the archive
typ (str) – “str”, “feat” or “align”
- Returns:
depending on typ, “str” -> string, “feat” -> (time, data), “align” -> align, where string is a str, time is list of time-stamp tuples (start-time,end-time) in millisecs,
data is a list of features, each a numpy vector,
- align is a list of (time, allophone, state, weight), time is an int from 0 to len of align,
allophone is some int, state is e.g. in [0,1,2].
- Return type:
str|(list[numpy.ndarray],list[numpy.ndarray])|list[(int,int,int,float)]
Uses FileArchive.read().
- returnn.sprint.cache.open_file_archive(archive_filename, must_exists=True, encoding='ascii')[source]#
- Parameters:
archive_filename (str) –
must_exists (bool) –
encoding (str) –
- Return type:
- returnn.sprint.cache.is_sprint_cache_file(filename)[source]#
- Parameters:
filename (str) – file to check. must exist
- Returns:
True iff this is a sprint cache (which can be loaded with open_file_archive())
- Return type:
bool
- class returnn.sprint.cache.AllophoneLabeling(silence_phone, allophone_file, phoneme_file=None, state_tying_file=None, verbose_out=None)[source]#
Allophone labeling.
- Parameters:
silence_phone (str) – e.g. “si”
allophone_file (str) – list of allophones
phoneme_file (str|None) – list of phonemes
state_tying_file (str|None) – allophone state tying (e.g. via CART). maps each allophone state to a class label
verbose_out (file) – stream to dump log messages
- class returnn.sprint.cache.MixtureSet(filename)[source]#
Mixture set.
- Parameters:
filename (str) –