SprintCache

This module is about reading (maybe later also writing) the Sprint archive format.

class SprintCache.AllophoneLabeling(silence_phone, allophone_file, phoneme_file=None, state_tying_file=None, verbose_out=None)[source]
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
get_label_idx(allo_idx, state_idx)[source]
get_label_idx_by_allo_state_idx(allo_state_idx)[source]
class SprintCache.FileArchive(filename, must_exists=True)[source]
SprintCacheHeader = 'SP_ARC1\x00'[source]
addAttributes(filename, dim, duration)[source]
addFeatureCache(filename, features, times)[source]
end_recovery_tag = 1437226410[source]
file_list()[source]
finalize()[source]
getState(mix)[source]
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), 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)]

readFileInfoTable()[source]
read_U32()[source]
read_bytes(l)[source]
read_char()[source]
read_f32()[source]
read_f64()[source]
read_str(l, enc='ascii')[source]
read_u32()[source]
read_u64()[source]
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

scanArchive()[source]
setAllophones(f)[source]
Parameters:f (str) – allophone filename. line-separated. will ignore lines starting with “#”
start_recovery_tag = 2857740885[source]
writeFileInfoTable()[source]
write_U32(i)[source]
write_char(i)[source]
write_f32(i)[source]
write_f64(i)[source]
write_str(s)[source]
write_u32(i)[source]
write_u64(i)[source]
class SprintCache.FileArchiveBundle(filename)[source]
Parameters:filename (str) – .bundle file
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), 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)]

Uses FileArchive.read().

setAllophones(filename)[source]
Parameters:filename (str) – allophone filename
class SprintCache.FileInfo(name, pos, size, compressed, index)[source]
class SprintCache.MixtureSet(filename)[source]
getCovByIdx(idx)[source]
getMeanByIdx(idx)[source]
getNumberMixtures()[source]
read_U32()[source]
read_char()[source]
read_f32()[source]
read_f64()[source]
read_str(l, enc='ascii')[source]
read_u32()[source]
read_u64()[source]
read_v(size, a)[source]
write(filename)[source]
SprintCache.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
SprintCache.main()[source]
SprintCache.open_file_archive(archive_filename, must_exists=True)[source]
Parameters:
  • archive_filename (str) –
  • must_exists (bool) –
Return type:

FileArchiveBundle|FileArchive