SprintExternInterface

This is a Sprint interface implementation. See SprintInterface.py for another Sprint interface. This Sprint interface is to be used for ExternSprintDataset, which should automatically use it.

SprintExternInterface.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.

SprintExternInterface.exchook(exc_type, exc_obj, exc_tb)[source]

Replacement for sys.excepthook.

SprintExternInterface.init(**kwargs)[source]

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

Parameters:kwargs – all passed to _init_python_trainer() or PythonControl.init()
Return type:None|PythonControl
SprintExternInterface.exit()[source]

Called by Sprint, to signal that it is exiting.

SprintExternInterface.feedInput(features, weights=None, segmentName=None)[source]

Called by Sprint. Unsupervised case.

Parameters:
  • features (numpy.ndarray) –
  • weights (numpy.ndarray|None) –
  • segmentName (str|None) –
SprintExternInterface.feedInputAndTargetAlignment(features, targetAlignment, weights=None, segmentName=None)[source]
Parameters:
  • features (numpy.ndarray) –
  • targetAlignment (numpy.ndarray) –
  • weights (numpy.ndarray|None) –
  • segmentName (str|None) –
SprintExternInterface.feedInputAndTargetSegmentOrth(features, targetSegmentOrth, weights=None, segmentName=None)[source]
Parameters:
  • features (numpy.ndarray) –
  • targetSegmentOrth (str) –
  • weights (numpy.ndarray|None) –
  • segmentName (str|None) –
SprintExternInterface.feedInputUnsupervised(features, weights=None, segmentName=None)[source]

Called by Sprint. Unsupervised case.

Parameters:
  • features (numpy.ndarray) –
  • weights (numpy.ndarray|None) –
  • segmentName (str|None) –
SprintExternInterface.feedInputAndTarget(features, weights=None, segmentName=None, orthography=None, alignment=None, speaker_name=None, speaker_gender=None, **kwargs)[source]
Parameters:
  • features (numpy.ndarray) –
  • weights (numpy.ndarray|None) –
  • segmentName (str|None) –
  • orthography (str|None) –
  • alignment (numpy.ndarray|None) –
  • speaker_name (str|None) –
  • speaker_gender (str|None) –
class SprintExternInterface.PythonControl(config, **kwargs)[source]

PythonControl, interface for Sprint.

instance = None[source]
classmethod init(**kwargs)[source]

Called by global init().

Return type:PythonControl
init_processing(self, input_dim, output_dim, **kwargs)[source]

Called by Sprint.

Parameters:
  • input_dim (int) –
  • output_dim (int) –
  • kwargs – maybe others
process_segment(self, name, orthography, features, alignment, soft_alignment, speaker_name=None, **kwargs)[source]

Called by Sprint.

Parameters:
  • name (str) –
  • orthography (str|None) –
  • features (numpy.ndarray) –
  • alignment (numpy.ndarray|None) –
  • soft_alignment (numpy.ndarray|None) –
  • speaker_name (str|None) –
  • kwargs – maybe others
exit(self, **kwargs)[source]

Called by Sprint.

Parameters:kwargs
class SprintExternInterface.ExternSprintDatasetSource(c2p_fd, p2c_fd, input_dim, output_dim, num_segments)[source]

This will send data to ExternSprintDataset over a pipe. We expect that we are child process and the parent process has spawned us via ExternSprintDataset and is waiting for our data.

Parameters:
  • c2p_fd (int) – child-to-parent file descriptor
  • p2c_fd (int) – parent-to-child file descriptor
  • num_segments (int | None) – can be None if not known in advance
add_new_data(self, segment_name, features, targets)[source]
Parameters:
  • segment_name (str) –
  • features (numpy.ndarray) – 2D array, (feature,time)
  • targets (dict[str,numpy.ndarray]) – each target is either 1D (time->idx) or 2D (time,class)
close(self)[source]

Close pipe fds.