idx int64 0 63k | question stringlengths 61 4.03k | target stringlengths 6 1.23k |
|---|---|---|
38,100 | def _find_files ( self , entries , root , relative_path , file_name_regex ) : self . log ( [ u"Finding files within root: '%s'" , root ] ) target = root if relative_path is not None : self . log ( [ u"Joining relative path: '%s'" , relative_path ] ) target = gf . norm_join ( root , relative_path ) self . log ( [ u"Find... | Return the elements in entries that |
38,101 | def _match_files_flat_hierarchy ( self , text_files , audio_files ) : self . log ( u"Matching files in flat hierarchy" ) self . log ( [ u"Text files: '%s'" , text_files ] ) self . log ( [ u"Audio files: '%s'" , audio_files ] ) d_text = { } d_audio = { } for text_file in text_files : text_file_no_ext = gf . file_name_wi... | Match audio and text files in flat hierarchies . |
38,102 | def _match_directories ( self , entries , root , regex_string ) : self . log ( u"Matching directory names in paged hierarchy" ) self . log ( [ u"Matching within '%s'" , root ] ) self . log ( [ u"Matching regex '%s'" , regex_string ] ) regex = re . compile ( r"" + regex_string ) directories = set ( ) root_len = len ( ro... | Match directory names in paged hierarchies . |
38,103 | def load_task ( self , task ) : if not isinstance ( task , Task ) : self . log_exc ( u"task is not an instance of Task" , None , True , ExecuteTaskInputError ) self . task = task | Load the task from the given Task object . |
38,104 | def _step_begin ( self , label , log = True ) : if log : self . step_label = label self . step_begin_time = self . log ( u"STEP %d BEGIN (%s)" % ( self . step_index , label ) ) | Log begin of a step |
38,105 | def _step_end ( self , log = True ) : if log : step_end_time = self . log ( u"STEP %d END (%s)" % ( self . step_index , self . step_label ) ) diff = ( step_end_time - self . step_begin_time ) diff = float ( diff . seconds + diff . microseconds / 1000000.0 ) self . step_total += diff self . log ( u"STEP %d DURATION %.3f... | Log end of a step |
38,106 | def _step_failure ( self , exc ) : self . log_crit ( u"STEP %d (%s) FAILURE" % ( self . step_index , self . step_label ) ) self . step_index += 1 self . log_exc ( u"Unexpected error while executing task" , exc , True , ExecuteTaskExecutionError ) | Log failure of a step |
38,107 | def execute ( self ) : self . log ( u"Executing task..." ) if self . task . audio_file is None : self . log_exc ( u"The task does not seem to have its audio file set" , None , True , ExecuteTaskInputError ) if ( ( self . task . audio_file . audio_length is None ) or ( self . task . audio_file . audio_length <= 0 ) ) : ... | Execute the task . The sync map produced will be stored inside the task object . |
38,108 | def _execute_single_level_task ( self ) : self . log ( u"Executing single level task..." ) try : self . _step_begin ( u"extract MFCC real wave" ) real_wave_mfcc = self . _extract_mfcc ( file_path = self . task . audio_file_path_absolute , file_format = None , ) self . _step_end ( ) self . _step_begin ( u"compute head t... | Execute a single - level task |
38,109 | def _execute_level ( self , level , audio_file_mfcc , text_files , sync_roots , force_aba_auto = False ) : self . _set_synthesizer ( ) next_level_text_files = [ ] next_level_sync_roots = [ ] for text_file_index , text_file in enumerate ( text_files ) : self . log ( [ u"Text level %d, fragment %d" , level , text_file_in... | Compute the alignment for all the nodes in the given level . |
38,110 | def _execute_inner ( self , audio_file_mfcc , text_file , sync_root = None , force_aba_auto = False , log = True , leaf_level = False ) : self . _step_begin ( u"synthesize text" , log = log ) synt_handler , synt_path , synt_anchors , synt_format = self . _synthesize ( text_file ) self . _step_end ( log = log ) self . _... | Align a subinterval of the given AudioFileMFCC with the given TextFile . |
38,111 | def _load_audio_file ( self ) : self . _step_begin ( u"load audio file" ) audio_file = AudioFile ( file_path = self . task . audio_file_path_absolute , file_format = None , rconf = self . rconf , logger = self . logger ) audio_file . read_samples_from_file ( ) self . _step_end ( ) return audio_file | Load audio in memory . |
38,112 | def _clear_audio_file ( self , audio_file ) : self . _step_begin ( u"clear audio file" ) audio_file . clear_data ( ) audio_file = None self . _step_end ( ) | Clear audio from memory . |
38,113 | def _extract_mfcc ( self , file_path = None , file_format = None , audio_file = None ) : audio_file_mfcc = AudioFileMFCC ( file_path = file_path , file_format = file_format , audio_file = audio_file , rconf = self . rconf , logger = self . logger ) if self . rconf . mmn : self . log ( u"Running VAD inside _extract_mfcc... | Extract the MFCCs from the given audio file . |
38,114 | def _compute_head_process_tail ( self , audio_file_mfcc ) : head_length = self . task . configuration [ "i_a_head" ] process_length = self . task . configuration [ "i_a_process" ] tail_length = self . task . configuration [ "i_a_tail" ] head_max = self . task . configuration [ "i_a_head_max" ] head_min = self . task . ... | Set the audio file head or tail by either reading the explicit values from the Task configuration or using SD to determine them . |
38,115 | def _clear_cache_synthesizer ( self ) : self . log ( u"Clearing synthesizer..." ) self . synthesizer . clear_cache ( ) self . log ( u"Clearing synthesizer... done" ) | Clear the cache of the synthesizer |
38,116 | def _synthesize ( self , text_file ) : handler , path = gf . tmp_file ( suffix = u".wav" , root = self . rconf [ RuntimeConfiguration . TMP_PATH ] ) result = self . synthesizer . synthesize ( text_file , path ) return ( handler , path , result [ 0 ] , self . synthesizer . output_audio_format ) | Synthesize text into a WAVE file . |
38,117 | def _align_waves ( self , real_wave_mfcc , synt_wave_mfcc , synt_anchors ) : self . log ( u"Creating DTWAligner..." ) aligner = DTWAligner ( real_wave_mfcc , synt_wave_mfcc , rconf = self . rconf , logger = self . logger ) self . log ( u"Creating DTWAligner... done" ) self . log ( u"Computing boundary indices..." ) bou... | Align two AudioFileMFCC objects representing WAVE files . |
38,118 | def _adjust_boundaries ( self , boundary_indices , text_file , real_wave_mfcc , sync_root , force_aba_auto = False , leaf_level = False ) : aba_parameters = self . task . configuration . aba_parameters ( ) if force_aba_auto : self . log ( u"Forced running algorithm: 'auto'" ) aba_parameters [ "algorithm" ] = ( AdjustBo... | Adjust boundaries as requested by the user . |
38,119 | def _append_trivial_tree ( self , text_file , sync_root ) : interval = sync_root . value if len ( text_file ) == 1 : time_values = [ interval . begin , interval . begin , interval . end , interval . end ] else : time_values = [ interval . begin ] * ( 3 + len ( text_file ) ) aba = AdjustBoundaryAlgorithm ( rconf = self ... | Append trivial tree made by one HEAD one sync map fragment for each element of text_file and one TAIL . |
38,120 | def _create_sync_map ( self , sync_root ) : sync_map = SyncMap ( tree = sync_root , rconf = self . rconf , logger = self . logger ) if self . rconf . safety_checks : self . log ( u"Running sanity check on computed sync map..." ) if not sync_map . leaves_are_consistent : self . _step_failure ( ValueError ( u"The compute... | If requested check that the computed sync map is consistent . Then add it to the Task . |
38,121 | def detect_interval ( self , min_head_length = None , max_head_length = None , min_tail_length = None , max_tail_length = None ) : head = self . detect_head ( min_head_length , max_head_length ) tail = self . detect_tail ( min_tail_length , max_tail_length ) begin = head end = self . real_wave_mfcc . audio_length - tai... | Detect the interval of the audio file containing the fragments in the text file . |
38,122 | def detect_head ( self , min_head_length = None , max_head_length = None ) : return self . _detect ( min_head_length , max_head_length , tail = False ) | Detect the audio head returning its duration in seconds . |
38,123 | def detect_tail ( self , min_tail_length = None , max_tail_length = None ) : return self . _detect ( min_tail_length , max_tail_length , tail = True ) | Detect the audio tail returning its duration in seconds . |
38,124 | def _select_tts_engine ( self ) : self . log ( u"Selecting TTS engine..." ) requested_tts_engine = self . rconf [ RuntimeConfiguration . TTS ] if requested_tts_engine == self . CUSTOM : self . log ( u"TTS engine: custom" ) tts_path = self . rconf [ RuntimeConfiguration . TTS_PATH ] if tts_path is None : self . log_exc ... | Select the TTS engine to be used by looking at the rconf object . |
38,125 | def check_shell_encoding ( cls ) : is_in_utf8 = True is_out_utf8 = True if sys . stdin . encoding not in [ "UTF-8" , "UTF8" ] : is_in_utf8 = False if sys . stdout . encoding not in [ "UTF-8" , "UTF8" ] : is_out_utf8 = False if ( is_in_utf8 ) and ( is_out_utf8 ) : gf . print_success ( u"shell encoding OK" ) else : gf . ... | Check whether sys . stdin and sys . stdout are UTF - 8 encoded . |
38,126 | def check_ffprobe ( cls ) : try : from aeneas . ffprobewrapper import FFPROBEWrapper file_path = gf . absolute_path ( u"tools/res/audio.mp3" , __file__ ) prober = FFPROBEWrapper ( ) properties = prober . read_properties ( file_path ) gf . print_success ( u"ffprobe OK" ) return False except : pass gf . print_erro... | Check whether ffprobe can be called . |
38,127 | def check_ffmpeg ( cls ) : try : from aeneas . ffmpegwrapper import FFMPEGWrapper input_file_path = gf . absolute_path ( u"tools/res/audio.mp3" , __file__ ) handler , output_file_path = gf . tmp_file ( suffix = u".wav" ) converter = FFMPEGWrapper ( ) result = converter . convert ( input_file_path , output_file_path ) g... | Check whether ffmpeg can be called . |
38,128 | def check_espeak ( cls ) : try : from aeneas . textfile import TextFile from aeneas . textfile import TextFragment from aeneas . ttswrappers . espeakttswrapper import ESPEAKTTSWrapper text = u"From fairest creatures we desire increase," text_file = TextFile ( ) text_file . add_fragment ( TextFragment ( language = u"eng... | Check whether espeak can be called . |
38,129 | def check_cdtw ( cls ) : if gf . can_run_c_extension ( "cdtw" ) : gf . print_success ( u"aeneas.cdtw AVAILABLE" ) return False gf . print_warning ( u"aeneas.cdtw NOT AVAILABLE" ) gf . print_info ( u" You can still run aeneas but it will be significantly slower" ) gf . print_info ( u" Please refer to the install... | Check whether Python C extension cdtw can be imported . |
38,130 | def check_cmfcc ( cls ) : if gf . can_run_c_extension ( "cmfcc" ) : gf . print_success ( u"aeneas.cmfcc AVAILABLE" ) return False gf . print_warning ( u"aeneas.cmfcc NOT AVAILABLE" ) gf . print_info ( u" You can still run aeneas but it will be significantly slower" ) gf . print_info ( u" Please refer to the insta... | Check whether Python C extension cmfcc can be imported . |
38,131 | def check_cew ( cls ) : if gf . can_run_c_extension ( "cew" ) : gf . print_success ( u"aeneas.cew AVAILABLE" ) return False gf . print_warning ( u"aeneas.cew NOT AVAILABLE" ) gf . print_info ( u" You can still run aeneas but it will be a bit slower" ) gf . print_info ( u" Please refer to the installation docu... | Check whether Python C extension cew can be imported . |
38,132 | def check_all ( cls , tools = True , encoding = True , c_ext = True ) : if cls . check_ffprobe ( ) : return ( True , False , False ) if cls . check_ffmpeg ( ) : return ( True , False , False ) if cls . check_espeak ( ) : return ( True , False , False ) if ( tools ) and ( cls . check_tools ( ) ) : return ( True , False ... | Perform all checks . |
38,133 | def config_string ( self ) : return ( gc . CONFIG_STRING_SEPARATOR_SYMBOL ) . join ( [ u"%s%s%s" % ( fn , gc . CONFIG_STRING_ASSIGNMENT_SYMBOL , self . data [ fn ] ) for fn in sorted ( self . data . keys ( ) ) if self . data [ fn ] is not None ] ) | Build the storable string corresponding to this configuration object . |
38,134 | def geq_multiple ( self , other ) : if other == TimeValue ( "0.000" ) : return self return int ( math . ceil ( other / self ) ) * self | Return the next multiple of this time value greater than or equal to other . If other is zero return this time value . |
38,135 | def starts_at ( self , time_point ) : if not isinstance ( time_point , TimeValue ) : raise TypeError ( u"time_point is not an instance of TimeValue" ) return self . begin == time_point | Returns True if this interval starts at the given time point . |
38,136 | def ends_at ( self , time_point ) : if not isinstance ( time_point , TimeValue ) : raise TypeError ( u"time_point is not an instance of TimeValue" ) return self . end == time_point | Returns True if this interval ends at the given time point . |
38,137 | def percent_value ( self , percent ) : if not isinstance ( percent , Decimal ) : raise TypeError ( u"percent is not an instance of Decimal" ) percent = Decimal ( max ( min ( percent , 100 ) , 0 ) / 100 ) return self . begin + self . length * percent | Returns the time value at percent of this interval . |
38,138 | def offset ( self , offset , allow_negative = False , min_begin_value = None , max_end_value = None ) : if not isinstance ( offset , TimeValue ) : raise TypeError ( u"offset is not an instance of TimeValue" ) self . begin += offset self . end += offset if not allow_negative : self . begin = max ( self . begin , TimeVal... | Move this interval by the given shift offset . |
38,139 | def intersection ( self , other ) : relative_position = self . relative_position_of ( other ) if relative_position in [ self . RELATIVE_POSITION_PP_C , self . RELATIVE_POSITION_PI_LC , self . RELATIVE_POSITION_PI_LG , self . RELATIVE_POSITION_PI_CG , self . RELATIVE_POSITION_IP_B , self . RELATIVE_POSITION_II_LB , ] : ... | Return the intersection between this time interval and the given time interval or None if the two intervals do not overlap . |
38,140 | def is_non_zero_before_non_zero ( self , other ) : return self . is_adjacent_before ( other ) and ( not self . has_zero_length ) and ( not other . has_zero_length ) | Return True if this time interval ends when the given other time interval begins and both have non zero length . |
38,141 | def is_adjacent_before ( self , other ) : if not isinstance ( other , TimeInterval ) : raise TypeError ( u"other is not an instance of TimeInterval" ) return ( self . end == other . begin ) | Return True if this time interval ends when the given other time interval begins . |
38,142 | def check_format ( self , sm_format ) : if sm_format not in SyncMapFormat . ALLOWED_VALUES : self . print_error ( u"Sync map format '%s' is not allowed" % ( sm_format ) ) self . print_info ( u"Allowed formats:" ) self . print_generic ( u" " . join ( SyncMapFormat . ALLOWED_VALUES ) ) return False return True | Return True if the given sync map format is allowed and False otherwise . |
38,143 | def _add_fragment ( cls , syncmap , identifier , lines , begin , end , language = None ) : syncmap . add_fragment ( SyncMapFragment ( text_fragment = TextFragment ( identifier = identifier , lines = lines , language = language ) , begin = begin , end = end ) ) | Add a new fragment to syncmap . |
38,144 | def parse ( self , input_text , syncmap ) : self . log_exc ( u"%s is abstract and cannot be called directly" % ( self . TAG ) , None , True , NotImplementedError ) | Parse the given input_text and append the extracted fragments to syncmap . |
38,145 | def format ( self , syncmap ) : self . log_exc ( u"%s is abstract and cannot be called directly" % ( self . TAG ) , None , True , NotImplementedError ) | Format the given syncmap as a Unicode string . |
38,146 | def print_examples ( self , full = False ) : msg = [ ] i = 1 for key in sorted ( self . DEMOS . keys ( ) ) : example = self . DEMOS [ key ] if full or example [ "show" ] : msg . append ( u"Example %d (%s)" % ( i , example [ u"description" ] ) ) msg . append ( u" $ %s %s" % ( self . invoke , key ) ) msg . append ( u"" ... | Print the examples and exit . |
38,147 | def print_values ( self , parameter ) : if parameter in self . VALUES : self . print_info ( u"Available values for parameter '%s':" % parameter ) self . print_generic ( u"\n" . join ( self . VALUES [ parameter ] ) ) return self . HELP_EXIT_CODE if parameter not in [ u"?" , u"" ] : self . print_error ( u"Invalid paramet... | Print the list of values for the given parameter and exit . |
38,148 | def prepare_cew_for_windows ( ) : try : espeak_dll_win_path = "C:\\Windows\\System32\\espeak.dll" espeak_dll_dst_path = "aeneas\\cew\\espeak.dll" espeak_dll_src_paths = [ "C:\\aeneas\\eSpeak\\espeak_sapi.dll" , "C:\\sync\\eSpeak\\espeak_sapi.dll" , "C:\\Program Files\\eSpeak\\espeak_sapi.dll" , "C:\\Program Files (x86)... | Copy files needed to compile the cew Python C extension on Windows . |
38,149 | def check_file_encoding ( self , input_file_path ) : self . log ( [ u"Checking encoding of file '%s'" , input_file_path ] ) self . result = ValidatorResult ( ) if self . _are_safety_checks_disabled ( u"check_file_encoding" ) : return self . result if not gf . file_can_be_read ( input_file_path ) : self . _failed ( u"Fi... | Check whether the given file is UTF - 8 encoded . |
38,150 | def check_config_xml ( self , contents ) : self . log ( u"Checking contents XML config file" ) self . result = ValidatorResult ( ) if self . _are_safety_checks_disabled ( u"check_config_xml" ) : return self . result contents = gf . safe_bytes ( contents ) self . log ( u"Checking that contents is well formed" ) self . c... | Check whether the given XML config file contents is well - formed and it has all the required parameters . |
38,151 | def check_container ( self , container_path , container_format = None , config_string = None ) : self . log ( [ u"Checking container '%s'" , container_path ] ) self . result = ValidatorResult ( ) if self . _are_safety_checks_disabled ( u"check_container" ) : return self . result if not ( gf . file_exists ( container_pa... | Check whether the given container is well - formed . |
38,152 | def _are_safety_checks_disabled ( self , caller = u"unknown_function" ) : if self . rconf . safety_checks : return False self . log_warn ( [ u"Safety checks disabled => %s passed" , caller ] ) return True | Return True if safety checks are disabled . |
38,153 | def _failed ( self , msg ) : self . log ( msg ) self . result . passed = False self . result . add_error ( msg ) self . log ( u"Failed" ) | Log a validation failure . |
38,154 | def _check_utf8_encoding ( self , bstring ) : if not gf . is_bytes ( bstring ) : self . _failed ( u"The given string is not a sequence of bytes" ) return if not gf . is_utf8_encoded ( bstring ) : self . _failed ( u"The given string is not encoded in UTF-8." ) | Check whether the given sequence of bytes is properly encoded in UTF - 8 . |
38,155 | def _check_reserved_characters ( self , ustring ) : forbidden = [ c for c in gc . CONFIG_RESERVED_CHARACTERS if c in ustring ] if len ( forbidden ) > 0 : self . _failed ( u"The given string contains the reserved characters '%s'." % u" " . join ( forbidden ) ) | Check whether the given Unicode string contains reserved characters . |
38,156 | def _check_allowed_values ( self , parameters ) : for key , allowed_values in self . ALLOWED_VALUES : self . log ( [ u"Checking allowed values for parameter '%s'" , key ] ) if key in parameters : value = parameters [ key ] if value not in allowed_values : self . _failed ( u"Parameter '%s' has value '%s' which is not al... | Check whether the given parameter value is allowed . Log messages into self . result . |
38,157 | def _check_implied_parameters ( self , parameters ) : for key , values , implied_keys in self . IMPLIED_PARAMETERS : self . log ( [ u"Checking implied parameters by '%s'='%s'" , key , values ] ) if ( key in parameters ) and ( parameters [ key ] in values ) : found = False for implied_key in implied_keys : if implied_ke... | Check whether at least one of the keys in implied_keys is in parameters when a given key = value is present in parameters for some value in values . Log messages into self . result . |
38,158 | def _check_required_parameters ( self , required_parameters , parameters ) : self . log ( [ u"Checking required parameters '%s'" , required_parameters ] ) self . log ( u"Checking input parameters are not empty" ) if ( parameters is None ) or ( len ( parameters ) == 0 ) : self . _failed ( u"No parameters supplied." ) re... | Check whether the given parameter dictionary contains all the required paramenters . Log messages into self . result . |
38,159 | def _check_analyzed_job ( self , job , container ) : self . log ( u"Checking the Job object generated from container" ) self . log ( u"Checking that the Job is not None" ) if job is None : self . _failed ( u"Unable to create a Job from the container." ) return self . log ( u"Checking that the Job has at least one Task"... | Check that the job object generated from the given container is well formed that it has at least one task and that the text file of each task has the correct encoding . Log messages into self . result . |
38,160 | def pretty_print ( self , warnings = False ) : msg = [ ] if ( warnings ) and ( len ( self . warnings ) > 0 ) : msg . append ( u"Warnings:" ) for warning in self . warnings : msg . append ( u" %s" % warning ) if len ( self . errors ) > 0 : msg . append ( u"Errors:" ) for error in self . errors : msg . append ( u" %s" ... | Pretty print warnings and errors . |
38,161 | def convert ( self , input_file_path , output_file_path , head_length = None , process_length = None ) : if not gf . file_can_be_read ( input_file_path ) : self . log_exc ( u"Input file '%s' cannot be read" % ( input_file_path ) , None , True , OSError ) if not gf . file_can_be_written ( output_file_path ) : self . log... | Convert the audio file at input_file_path into output_file_path using the parameters set in the constructor or through the parameters property . |
38,162 | def rate_lack ( self , max_rate ) : if self . fragment_type == self . REGULAR : return self . chars / max_rate - self . length return TimeValue ( "0.000" ) | The time interval that this fragment lacks to respect the given max rate . |
38,163 | def rate_slack ( self , max_rate ) : if self . fragment_type == self . REGULAR : return - self . rate_lack ( max_rate ) elif self . fragment_type == self . NONSPEECH : return self . length else : return TimeValue ( "0.000" ) | The maximum time interval that can be stolen to this fragment while keeping it respecting the given max rate . |
38,164 | def write_to_file ( self , output_file_path , intervals , template ) : msg = [ template % ( interval ) for interval in intervals ] if output_file_path is None : self . print_info ( u"Intervals detected:" ) for line in msg : self . print_generic ( line ) else : with io . open ( output_file_path , "w" , encoding = "utf-8... | Write intervals to file . |
38,165 | def print_parameters ( self ) : self . print_info ( u"Available parameters:" ) self . print_generic ( u"\n" + u"\n" . join ( self . PARAMETERS ) + u"\n" ) return self . HELP_EXIT_CODE | Print the list of parameters and exit . |
38,166 | def main ( ) : if len ( sys . argv ) < 6 : print ( "You must pass five arguments: QUIT_AFTER BACKWARDS TEXT_FILE_PATH AUDIO_FILE_PATH DATA_FILE_PATH" ) return 1 c_quit_after = float ( sys . argv [ 1 ] ) c_backwards = int ( sys . argv [ 2 ] ) text_file_path = sys . argv [ 3 ] audio_file_path = sys . argv [ 4 ] data_file... | Run aeneas . cew reading input text from file and writing audio and interval data to file . |
38,167 | def parse ( self , input_text , syncmap ) : from lxml import etree smil_ns = "{http://www.w3.org/ns/SMIL}" root = etree . fromstring ( gf . safe_bytes ( input_text ) ) for par in root . iter ( smil_ns + "par" ) : for child in par : if child . tag == ( smil_ns + "text" ) : identifier = gf . safe_unicode ( gf . split_url... | Read from SMIL file . |
38,168 | def _is_valid_index ( self , index ) : if isinstance ( index , int ) : return ( index >= 0 ) and ( index < len ( self ) ) if isinstance ( index , list ) : valid = True for i in index : valid = valid or self . _is_valid_index ( i ) return valid return False | Return True if and only if the given index is valid . |
38,169 | def _check_boundaries ( self , fragment ) : if not isinstance ( fragment , SyncMapFragment ) : raise TypeError ( u"fragment is not an instance of SyncMapFragment" ) interval = fragment . interval if not isinstance ( interval , TimeInterval ) : raise TypeError ( u"interval is not an instance of TimeInterval" ) if ( self... | Check that the interval of the given fragment is within the boundaries of the list . Raises an error if not OK . |
38,170 | def remove ( self , indices ) : if not self . _is_valid_index ( indices ) : self . log_exc ( u"The given list of indices is not valid" , None , True , ValueError ) new_fragments = [ ] sorted_indices = sorted ( indices ) i = 0 j = 0 while ( i < len ( self ) ) and ( j < len ( sorted_indices ) ) : if i != sorted_indices [... | Remove the fragments corresponding to the given list of indices . |
38,171 | def sort ( self ) : if self . is_guaranteed_sorted : self . log ( u"Already sorted, returning" ) return self . log ( u"Sorting..." ) self . __fragments = sorted ( self . __fragments ) self . log ( u"Sorting... done" ) self . log ( u"Checking relative positions..." ) for i in range ( len ( self ) - 1 ) : current_interva... | Sort the fragments in the list . |
38,172 | def remove_nonspeech_fragments ( self , zero_length_only = False ) : self . log ( u"Removing nonspeech fragments..." ) nonspeech = list ( self . nonspeech_fragments ) if zero_length_only : nonspeech = [ ( i , f ) for i , f in nonspeech if f . has_zero_length ] nonspeech_indices = [ i for i , f in nonspeech ] self . rem... | Remove NONSPEECH fragments from the list . |
38,173 | def has_zero_length_fragments ( self , min_index = None , max_index = None ) : min_index , max_index = self . _check_min_max_indices ( min_index , max_index ) zero = [ i for i in range ( min_index , max_index ) if self [ i ] . has_zero_length ] self . log ( [ u"Fragments with zero length: %s" , zero ] ) return ( len ( ... | Return True if the list has at least one interval with zero length withing min_index and max_index . If the latter are not specified check all intervals . |
38,174 | def has_adjacent_fragments_only ( self , min_index = None , max_index = None ) : min_index , max_index = self . _check_min_max_indices ( min_index , max_index ) for i in range ( min_index , max_index - 1 ) : current_interval = self [ i ] . interval next_interval = self [ i + 1 ] . interval if not current_interval . is_... | Return True if the list contains only adjacent fragments that is if it does not have gaps . |
38,175 | def offset ( self , offset ) : self . log ( u"Applying offset to all fragments..." ) self . log ( [ u" Offset %.3f" , offset ] ) for fragment in self . fragments : fragment . interval . offset ( offset = offset , allow_negative = False , min_begin_value = self . begin , max_end_value = self . end ) self . log ( u"Appl... | Move all the intervals in the list by the given offset . |
38,176 | def move_transition_point ( self , fragment_index , value ) : self . log ( u"Called move_transition_point with" ) self . log ( [ u" fragment_index %d" , fragment_index ] ) self . log ( [ u" value %.3f" , value ] ) if ( fragment_index < 0 ) or ( fragment_index > ( len ( self ) - 3 ) ) : self . log ( u"Bad fra... | Change the transition point between fragment fragment_index and the next fragment to the time value value . |
38,177 | def inject_long_nonspeech_fragments ( self , pairs , replacement_string ) : self . log ( u"Called inject_long_nonspeech_fragments" ) if replacement_string in [ None , gc . PPV_TASK_ADJUST_BOUNDARY_NONSPEECH_REMOVE ] : self . log ( u" Remove long nonspeech" ) lines = [ ] else : self . log ( [ u" Replace long nonspeech... | Inject nonspeech fragments corresponding to the given intervals in this fragment list . |
38,178 | def compute_accumulated_cost_matrix ( self ) : self . _setup_dtw ( ) if self . dtw is None : self . log ( u"Inner self.dtw is None => returning None" ) return None self . log ( u"Returning accumulated cost matrix" ) return self . dtw . compute_accumulated_cost_matrix ( ) | Compute the accumulated cost matrix and return it . |
38,179 | def compute_path ( self ) : self . _setup_dtw ( ) if self . dtw is None : self . log ( u"Inner self.dtw is None => returning None" ) return None self . log ( u"Computing path..." ) wave_path = self . dtw . compute_path ( ) self . log ( u"Computing path... done" ) self . log ( u"Translating path to full wave indices..."... | Compute the min cost path between the two waves and return it . |
38,180 | def compute_boundaries ( self , synt_anchors ) : self . _setup_dtw ( ) if self . dtw is None : self . log ( u"Inner self.dtw is None => returning artificial boundary indices" ) begin = self . real_wave_mfcc . middle_begin end = self . real_wave_mfcc . tail_begin n = len ( synt_anchors ) step = float ( end - begin ) / n... | Compute the min cost path between the two waves and return a list of boundary points representing the argmin values with respect to the provided synt_anchors timings . |
38,181 | def _setup_dtw ( self ) : if self . dtw is not None : return if ( self . real_wave_mfcc is None ) or ( self . real_wave_mfcc . middle_mfcc is None ) : self . log_exc ( u"The real wave MFCCs are not initialized" , None , True , DTWAlignerNotInitialized ) if ( self . synt_wave_mfcc is None ) or ( self . synt_wave_mfcc . ... | Set the DTW object up . |
38,182 | def check_import ( ) : try : import aeneas print_success ( u"aeneas OK" ) return False except ImportError : print_error ( u"aeneas ERROR" ) print_info ( u" Unable to load the aeneas Python package" ) print_info ( u" This error is probably caused by:" ) print_info ( u" A. you did not download/git-cl... | Try to import the aeneas package and return True if that fails . |
38,183 | def main ( ) : if check_import ( ) : sys . exit ( 1 ) from aeneas . diagnostics import Diagnostics errors , warnings , c_ext_warnings = Diagnostics . check_all ( ) if errors : sys . exit ( 1 ) if c_ext_warnings : print_warning ( u"All required dependencies are met but at least one Python C extension is not available" )... | The entry point for this module |
38,184 | def is_pleasant ( self ) : levels = sorted ( [ n . level for n in self . leaves ] ) return levels [ 0 ] == levels [ - 1 ] | Return True if all the leaves in the subtree rooted at this node are at the same level . |
38,185 | def add_child ( self , node , as_last = True ) : if not isinstance ( node , Tree ) : self . log_exc ( u"node is not an instance of Tree" , None , True , TypeError ) if as_last : self . __children . append ( node ) else : self . __children = [ node ] + self . __children node . __parent = self new_height = 1 + self . lev... | Add the given child to the current list of children . |
38,186 | def remove_child ( self , index ) : if index < 0 : index = index + len ( self ) self . __children = self . __children [ 0 : index ] + self . __children [ ( index + 1 ) : ] | Remove the child at the given index from the current list of children . |
38,187 | def remove ( self ) : if self . parent is not None : for i , child in enumerate ( self . parent . children ) : if id ( child ) == id ( self ) : self . parent . remove_child ( i ) self . parent = None break | Remove this node from the list of children of its current parent if the current parent is not None otherwise do nothing . |
38,188 | def remove_children ( self , reset_parent = True ) : if reset_parent : for child in self . children : child . parent = None self . __children = [ ] | Remove all the children of this node . |
38,189 | def leaves_not_empty ( self ) : return [ n for n in self . dfs if ( ( n . is_leaf ) and ( not n . is_empty ) ) ] | Return the list of leaves not empty in the tree rooted at this node in DFS order . |
38,190 | def height ( self ) : return max ( [ n . level for n in self . subtree ] ) - self . level + 1 | Return the height of the tree rooted at this node that is the difference between the level of a deepest leaf and the level of this node . Return 1 for a single - node tree 2 for a two - levels tree etc . |
38,191 | def levels ( self ) : ret = [ [ ] for i in range ( self . height ) ] for node in self . subtree : ret [ node . level - self . level ] . append ( node ) return ret | Return a list of lists of nodes . The outer list is indexed by the level . Each inner list contains the nodes at that level in DFS order . |
38,192 | def level_at_index ( self , index ) : if not isinstance ( index , int ) : self . log_exc ( u"Index is not an integer" , None , True , TypeError ) levels = self . levels if ( index < 0 ) or ( index >= len ( levels ) ) : self . log_exc ( u"The given level index '%d' is not valid" % ( index ) , None , True , ValueError ) ... | Return the list of nodes at level index in DFS order . |
38,193 | def ancestor ( self , index ) : if not isinstance ( index , int ) : self . log_exc ( u"index is not an integer" , None , True , TypeError ) if index < 0 : self . log_exc ( u"index cannot be negative" , None , True , ValueError ) parent_node = self for i in range ( index ) : if parent_node is None : break parent_node = ... | Return the index - th ancestor . |
38,194 | def keep_levels ( self , level_indices ) : if not isinstance ( level_indices , list ) : self . log_exc ( u"level_indices is not an instance of list" , None , True , TypeError ) for l in level_indices : if not isinstance ( l , int ) : self . log_exc ( u"level_indices contains an element not int" , None , True , TypeErro... | Rearrange the tree rooted at this node to keep only the given levels . |
38,195 | def s2dctmat ( nfilt , ncep , freqstep ) : melcos = numpy . empty ( ( ncep , nfilt ) , 'double' ) for i in range ( 0 , ncep ) : freq = numpy . pi * float ( i ) / nfilt melcos [ i ] = numpy . cos ( freq * numpy . arange ( 0.5 , float ( nfilt ) + 0.5 , 1.0 , 'double' ) ) melcos [ : , 0 ] = melcos [ : , 0 ] * 0.5 return m... | Return the legacy not - quite - DCT matrix used by Sphinx |
38,196 | def logspec2s2mfc ( logspec , ncep = 13 ) : nframes , nfilt = logspec . shape melcos = s2dctmat ( nfilt , ncep , 1. / nfilt ) return numpy . dot ( logspec , melcos . T ) / nfilt | Convert log - power - spectrum bins to MFCC using the legacy Sphinx transform |
38,197 | def dct ( input , K = 13 ) : nframes , N = input . shape freqstep = numpy . pi / N cosmat = dctmat ( N , K , freqstep ) return numpy . dot ( input , cosmat ) * numpy . sqrt ( 2.0 / N ) | Convert log - power - spectrum to MFCC using the orthogonal DCT - II |
38,198 | def dct2 ( input , K = 13 ) : nframes , N = input . shape freqstep = numpy . pi / N cosmat = dctmat ( N , K , freqstep , False ) return numpy . dot ( input , cosmat ) * ( 2.0 / N ) | Convert log - power - spectrum to MFCC using the normalized DCT - II |
38,199 | def read_properties ( self ) : self . log ( u"Reading properties..." ) if not gf . file_can_be_read ( self . file_path ) : self . log_exc ( u"File '%s' cannot be read" % ( self . file_path ) , None , True , OSError ) self . log ( [ u"Getting file size for '%s'" , self . file_path ] ) self . file_size = gf . file_size (... | Populate this object by reading the audio properties of the file at the given path . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.