def _append_trivial_tree(self, text_file, sync_root): """ Append trivial tree, made by one HEAD, one sync map fragment for each element of ``text_file``, and one TAIL. This function is called if either ``text_file`` has only one element, or if ``sync_root.value`` is an interval with zero length (i.e., ``sync_root.value.begin == sync_root.value.end``). """ interval = sync_root.value # # NOTE the following is correct, but it is a bit obscure # time_values = [interval.begin] * (1 + len(text_file)) + [interval.end] * 2 # if len(text_file) == 1: time_values = [ interval.begin, interval.begin, interval.end, interval.end ] else: # interval.begin == interval.end time_values = [interval.begin] * (3 + len(text_file)) aba = AdjustBoundaryAlgorithm(rconf=self.rconf, logger=self.logger) aba.intervals_to_fragment_list(text_file=text_file, time_values=time_values) aba.append_fragment_list_to_sync_root(sync_root=sync_root)
def _append_trivial_tree(self, text_file, sync_root): """ Append trivial tree, made by one HEAD, one sync map fragment for each element of ``text_file``, and one TAIL. This function is called if either ``text_file`` has only one element, or if ``sync_root.value`` is an interval with zero length (i.e., ``sync_root.value.begin == sync_root.value.end``). """ interval = sync_root.value # # NOTE the following is correct, but it is a bit obscure # time_values = [interval.begin] * (1 + len(text_file)) + [interval.end] * 2 # if len(text_file) == 1: time_values = [interval.begin, interval.begin, interval.end, interval.end] else: # interval.begin == interval.end time_values = [interval.begin] * (3 + len(text_file)) aba = AdjustBoundaryAlgorithm(rconf=self.rconf, logger=self.logger) aba.intervals_to_fragment_list( text_file=text_file, time_values=time_values ) aba.append_fragment_list_to_sync_root(sync_root=sync_root)
def _adjust_boundaries(self, boundary_indices, text_file, real_wave_mfcc, sync_root, force_aba_auto=False, leaf_level=False): """ Adjust boundaries as requested by the user. Return the computed time map, that is, a list of pairs ``[start_time, end_time]``, of length equal to number of fragments + 2, where the two extra elements are for the HEAD (first) and TAIL (last). """ # boundary_indices contains the boundary indices in the all_mfcc of real_wave_mfcc # starting with the (head-1st fragment) and ending with (-1th fragment-tail) aba_parameters = self.task.configuration.aba_parameters() if force_aba_auto: self.log(u"Forced running algorithm: 'auto'") aba_parameters["algorithm"] = (AdjustBoundaryAlgorithm.AUTO, []) # note that the other aba settings (nonspeech and nozero) # remain as specified by the user self.log([u"ABA parameters: %s", aba_parameters]) aba = AdjustBoundaryAlgorithm(rconf=self.rconf, logger=self.logger) aba.adjust(aba_parameters=aba_parameters, real_wave_mfcc=real_wave_mfcc, boundary_indices=boundary_indices, text_file=text_file, allow_arbitrary_shift=leaf_level) aba.append_fragment_list_to_sync_root(sync_root=sync_root)
def _adjust_boundaries(self, boundary_indices, text_file, real_wave_mfcc, sync_root, force_aba_auto=False, leaf_level=False): """ Adjust boundaries as requested by the user. Return the computed time map, that is, a list of pairs ``[start_time, end_time]``, of length equal to number of fragments + 2, where the two extra elements are for the HEAD (first) and TAIL (last). """ # boundary_indices contains the boundary indices in the all_mfcc of real_wave_mfcc # starting with the (head-1st fragment) and ending with (-1th fragment-tail) aba_parameters = self.task.configuration.aba_parameters() if force_aba_auto: self.log(u"Forced running algorithm: 'auto'") aba_parameters["algorithm"] = (AdjustBoundaryAlgorithm.AUTO, []) # note that the other aba settings (nonspeech and nozero) # remain as specified by the user self.log([u"ABA parameters: %s", aba_parameters]) aba = AdjustBoundaryAlgorithm(rconf=self.rconf, logger=self.logger) aba.adjust( aba_parameters=aba_parameters, real_wave_mfcc=real_wave_mfcc, boundary_indices=boundary_indices, text_file=text_file, allow_arbitrary_shift=leaf_level ) aba.append_fragment_list_to_sync_root(sync_root=sync_root)