adjustboundaryalgorithm¶
This module contains the following classes:
AdjustBoundaryAlgorithmimplementing functions to adjust the boundary point between two consecutive fragments.
Warning
This module is likely to be refactored in a future version
-
class
aeneas.adjustboundaryalgorithm.AdjustBoundaryAlgorithm(rconf=None, logger=None)[source]¶ Enumeration and implementation of the available algorithms to adjust the boundary point between two consecutive fragments.
Parameters: - rconf (
RuntimeConfiguration) – a runtime configuration - logger (
Logger) – the logger object
Raises: TypeError: if one of
boundary_indices,real_wave_mfcc, ortext_fileisNoneor it has a wrong type-
AFTERCURRENT= 'aftercurrent'¶ Set the boundary at
valueseconds after the end of the current fragment, if the current boundary falls inside a nonspeech interval. If not, no adjustment is made.Example (value
0.200seconds):
-
ALLOWED_VALUES= ['aftercurrent', 'auto', 'beforenext', 'offset', 'percent', 'rate', 'rateaggressive']¶ List of all the allowed values
-
AUTO= 'auto'¶ Auto (no adjustment).
Example:
-
BEFORENEXT= 'beforenext'¶ Set the boundary at
valueseconds before the beginning of the next fragment, if the current boundary falls inside a nonspeech interval. If not, no adjustment is made.Example (value
0.200seconds):
-
OFFSET= 'offset'¶ Offset the current boundaries by
valueseconds. Thevaluecan be negative or positive.Example (value
-0.200seconds):
Example (value
0.200seconds):
New in version 1.1.0.
-
PERCENT= 'percent'¶ Set the boundary at
valuepercent of the nonspeech interval between the current and the next fragment, if the current boundary falls inside a nonspeech interval. Thevaluemust be an integer in[0, 100]. If not, no adjustment is made.Example (value
25%):
Example (value
50%):
Example (value
75%):
-
RATE= 'rate'¶ Adjust boundaries trying to respect the
valuecharacters/second constraint. Thevaluemust be positive. First, the rates of all fragments are computed, using the current boundaries. For those fragments exceedingvaluecharacters/second, the algorithm will try to move the end boundary forward, so that its time interval increases (and hence its rate decreases). Clearly, it is possible that not all fragments can be adjusted this way: for example, if you have three consecutive fragments exceedingvalue, the middle one cannot be stretched.Example (value
13.0, note howf000003is modified):
-
RATEAGGRESSIVE= 'rateaggressive'¶ Adjust boundaries trying to respect the
valuecharacters/second constraint, in aggressive mode. Thevaluemust be positive. First, the rates of all fragments are computed, using the current boundaries. For those fragments exceedingvaluecharacters/second, the algorithm will try to move the end boundary forward, so that its time interval increases (and hence its rate decreases). If moving the end boundary is not possible, or it is not enough to keep the rate belowvalue, the algorithm will try to move the begin boundary back; this is the difference with the less aggressiveRATEalgorithm. Clearly, it is possible that not all fragments can be adjusted this way: for example, if you have three consecutive fragments exceedingvalue, the middle one cannot be stretched.Example (value
13.0, note howf000003is modified):
New in version 1.1.0.
-
adjust(aba_parameters, boundary_indices, real_wave_mfcc, text_file, allow_arbitrary_shift=False)[source]¶ Adjust the boundaries of the text map using the algorithm and parameters specified in the constructor, storing the sync map fragment list internally.
Parameters: - aba_parameters (dict) – a dictionary containing the algorithm and its parameters,
as produced by
aba_parameters()inTaskConfiguration - boundary_indices (
numpy.ndarray(1D)) – the current boundary indices, with respect to the audio file full MFCCs - real_wave_mfcc (
AudioFileMFCC) – the audio file MFCCs - text_file (
TextFile) – the text file containing the text fragments associated - allow_arbitrary_shift (bool) – if
True, allow arbitrary shifts when adjusting zero length
Return type: list of
SyncMapFragmentList- aba_parameters (dict) – a dictionary containing the algorithm and its parameters,
as produced by
-
append_fragment_list_to_sync_root(sync_root)[source]¶ Append the sync map fragment list to the given node from a sync map tree.
Parameters: sync_root ( Tree) – the root of the sync map tree to which the new nodes should be appended
-
intervals_to_fragment_list(text_file, time_values)[source]¶ Transform a list of at least 4 time values (corresponding to at least 3 intervals) into a sync map fragment list and store it internally. The first interval is a HEAD, the last is a TAIL.
For example:
time_values=[0.000, 1.000, 2.000, 3.456] => [(0.000, 1.000), (1.000, 2.000), (2.000, 3.456)]Parameters: Raises: TypeError: if
text_fileis not an instance ofTextFileortime_valuesis not a listRaises: ValueError: if
time_valueshas length less than four
- rconf (