SprintInterface

This is a Sprint interface implementation, i.e. you would specify this module in your Sprint config. (Sprint = the RWTH ASR toolkit.) Note that there are multiple Sprint interface implementations provided. This one would be used explicitly, e.g. for forwarding in recognition or wherever else Sprint needs posteriors (a FeatureScorer). Most of the other Sprint interfaces will be used automatically, e.g. via ExternSprintDataset, when it spawns its Sprint subprocess.

class SprintInterface.Criterion[source]
error = None[source]
errorSignal = None[source]
gotErrorSignal = <threading._Event object>[source]
gotPosteriors = <threading._Event object>[source]
make_node(posteriors, seq_lengths)[source]
perform(node, inputs, output_storage, params=None)[source]
posteriors = None[source]
class SprintInterface.PythonFeatureScorer(callback, version_number, sprint_opts, **kwargs)[source]
Parameters:
  • callback ((str,)->object) –
  • version_number (int) –
  • sprint_opts (dict[str,str]) –
add_feature(feature, time)[source]

Called by Sprint.

Parameters:
  • feature (numpy.ndarray) – shape (input_dim,)
  • time (int) –
compute(num_frames)[source]

Called by Sprint. All the features which we received so far should be evaluated.

Parameters:num_frames (int) –
config[source]
Return type:Config.Config
engine[source]
Return type:TFEngine.Engine|Engine.Engine
exit()[source]
features_to_dataset(num_frames=None)[source]
Parameters:num_frames (int|None) –
Returns:(dataset, seq_idx)
Return type:(Dataset.Dataset, int)
get_feature_buffer_size()[source]

Called by Sprint.

Returns:-1 -> no limit
get_features(num_frames=None)[source]
Parameters:num_frames (int|None) –
Returns:shape (input_dim, num_frames)
Return type:numpy.ndarray
get_posteriors(num_frames=None)[source]
Parameters:num_frames (int|None) –
Returns:shape (output_dim, num_frames)
Return type:numpy.ndarray
get_scores(time)[source]

Called by Sprint.

Parameters:time (int) –
Returns:shape (output_dim,)
Return type:numpy.ndarray
get_segment_name()[source]
init(input_dim, output_dim)[source]

Called by Sprint.

Parameters:
  • input_dim (int) –
  • output_dim (int) – number of emission classes
reset(num_frames)[source]

Called by Sprint. Called when we shall flush any buffers.

Parameters:num_frames (int) –
SprintInterface.demo()[source]
SprintInterface.dumpFlags()[source]
SprintInterface.exit()[source]
SprintInterface.features_to_dataset(features, segment_name)[source]
Parameters:
  • features (numpy.ndarray) – format (input-feature,time) (via Sprint)
  • segment_name (str) –
Returns:

(dataset, seq-idx)

Return type:

(Dataset.Dataset, int)

SprintInterface.feedInput(features, weights=None, segmentName=None)[source]
SprintInterface.feedInputAndTarget(features, weights=None, segmentName=None, orthography=None, alignment=None, speaker_name=None, speaker_gender=None, **kwargs)[source]
SprintInterface.feedInputAndTargetAlignment(features, targetAlignment, weights=None, segmentName=None)[source]
SprintInterface.feedInputAndTargetSegmentOrth(features, targetSegmentOrth, weights=None, segmentName=None)[source]
SprintInterface.feedInputForwarding(features, weights=None, segmentName=None)[source]
SprintInterface.feedInputUnsupervised(features, weights=None, segmentName=None)[source]
SprintInterface.finishDiscard()[source]
SprintInterface.finishError(error, errorSignal, naturalPairingType=None)[source]
SprintInterface.forward(segmentName, features)[source]
Parameters:features (numpy.ndarray) – format (input-feature,time) (via Sprint)

:return numpy.ndarray, format (output-dim,time)

SprintInterface.getFinalEpoch()[source]
SprintInterface.getSegmentList(corpusName, segmentList, **kwargs)[source]

Called by Sprint PythonSegmentOrder. Set python-segment-order = true in Sprint to use this.

If this is used, this gets called really early. If it is used together with the Sprint PythonTrainer, it will get called way earlier before the init() below. It might also get called multiple times, e.g. if Sprint is in interactive mode to calc the seg count. This is optional. You can use the SprintInterface only for the PythonTrainer.

Return type:list[str]

:returns segment list. Can also be an iterator.

SprintInterface.init(name=None, sprint_unit=None, **kwargs)[source]

This will get called by various Sprint interfaces. Depending on name and sprint_unit, we can figure out which interface it is. For all PythonControl-based interfaces, we must return an object which will be used for further callbacks.

Parameters:
  • name (str|None) –
  • sprint_unit (str|None) –
Returns:

some object or None

Return type:

None|object

SprintInterface.initBase(configfile=None, targetMode=None, epoch=None)[source]
Parameters:
  • configfile (str|None) – filename, via init(), this is set
  • targetMode (str|None) – “forward” or so. via init(), this is set
  • epoch (int) – via init(), this is set
SprintInterface.initDataset()[source]
SprintInterface.init_python_feature_scorer(config, **kwargs)[source]
Parameters:config (str) –
Return type:PythonFeatureScorer
SprintInterface.init_python_trainer(inputDim, outputDim, config, targetMode, **kwargs)[source]

Called by Sprint when it initializes the PythonTrainer. Set trainer = python-trainer in Sprint to enable. Note that Sprint will call this, i.e. the trainer init lazily quite late, only once it sees the first data.

Parameters:
  • config (str) – config string, passed by Sprint. assumed to be ”,”-separated
  • targetMode (str) – “target-alignment” or “criterion-by-sprint” or so
Returns:

not expected to return anything

Return type:

None

SprintInterface.prepareForwarding()[source]
SprintInterface.setTargetMode(mode)[source]
Parameters:mode (str) – target mode
SprintInterface.startTrainThread(epoch=None)[source]
SprintInterface.train(segmentName, features, targets=None)[source]
Parameters:
  • segmentName (str|None) – full name
  • features (numpy.ndarray) – 2d array
  • targets (numpy.ndarray|dict[str,numpy.ndarray]|None) – 2d or 1d array