repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
readbeyond/aeneas
aeneas/exacttiming.py
TimeInterval.starts_at
def starts_at(self, time_point): """ Returns ``True`` if this interval starts at the given time point. :param time_point: the time point to test :type time_point: :class:`~aeneas.exacttiming.TimeValue` :raises TypeError: if ``time_point`` is not an instance of ``TimeValue`` ...
python
def starts_at(self, time_point): """ Returns ``True`` if this interval starts at the given time point. :param time_point: the time point to test :type time_point: :class:`~aeneas.exacttiming.TimeValue` :raises TypeError: if ``time_point`` is not an instance of ``TimeValue`` ...
[ "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...
Returns ``True`` if this interval starts at the given time point. :param time_point: the time point to test :type time_point: :class:`~aeneas.exacttiming.TimeValue` :raises TypeError: if ``time_point`` is not an instance of ``TimeValue`` :rtype: bool
[ "Returns", "True", "if", "this", "interval", "starts", "at", "the", "given", "time", "point", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/exacttiming.py#L371-L382
train
readbeyond/aeneas
aeneas/exacttiming.py
TimeInterval.ends_at
def ends_at(self, time_point): """ Returns ``True`` if this interval ends at the given time point. :param time_point: the time point to test :type time_point: :class:`~aeneas.exacttiming.TimeValue` :raises TypeError: if ``time_point`` is not an instance of ``TimeValue`` ...
python
def ends_at(self, time_point): """ Returns ``True`` if this interval ends at the given time point. :param time_point: the time point to test :type time_point: :class:`~aeneas.exacttiming.TimeValue` :raises TypeError: if ``time_point`` is not an instance of ``TimeValue`` ...
[ "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_poi...
Returns ``True`` if this interval ends at the given time point. :param time_point: the time point to test :type time_point: :class:`~aeneas.exacttiming.TimeValue` :raises TypeError: if ``time_point`` is not an instance of ``TimeValue`` :rtype: bool
[ "Returns", "True", "if", "this", "interval", "ends", "at", "the", "given", "time", "point", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/exacttiming.py#L384-L395
train
readbeyond/aeneas
aeneas/exacttiming.py
TimeInterval.percent_value
def percent_value(self, percent): """ Returns the time value at ``percent`` of this interval. :param percent: the percent :type percent: :class:`~aeneas.exacttiming.Decimal` :raises TypeError: if ``time_point`` is not an instance of ``TimeValue`` :rtype: :class:`~aeneas...
python
def percent_value(self, percent): """ Returns the time value at ``percent`` of this interval. :param percent: the percent :type percent: :class:`~aeneas.exacttiming.Decimal` :raises TypeError: if ``time_point`` is not an instance of ``TimeValue`` :rtype: :class:`~aeneas...
[ "def", "percent_value", "(", "self", ",", "percent", ")", ":", "if", "not", "isinstance", "(", "percent", ",", "Decimal", ")", ":", "raise", "TypeError", "(", "u\"percent is not an instance of Decimal\"", ")", "percent", "=", "Decimal", "(", "max", "(", "min",...
Returns the time value at ``percent`` of this interval. :param percent: the percent :type percent: :class:`~aeneas.exacttiming.Decimal` :raises TypeError: if ``time_point`` is not an instance of ``TimeValue`` :rtype: :class:`~aeneas.exacttiming.TimeValue`
[ "Returns", "the", "time", "value", "at", "percent", "of", "this", "interval", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/exacttiming.py#L397-L409
train
readbeyond/aeneas
aeneas/exacttiming.py
TimeInterval.offset
def offset(self, offset, allow_negative=False, min_begin_value=None, max_end_value=None): """ Move this interval by the given shift ``offset``. The begin and end time points of the translated interval are ensured to be non-negative (i.e., they are maxed with ``0.000``), ...
python
def offset(self, offset, allow_negative=False, min_begin_value=None, max_end_value=None): """ Move this interval by the given shift ``offset``. The begin and end time points of the translated interval are ensured to be non-negative (i.e., they are maxed with ``0.000``), ...
[ "def", "offset", "(", "self", ",", "offset", ",", "allow_negative", "=", "False", ",", "min_begin_value", "=", "None", ",", "max_end_value", "=", "None", ")", ":", "if", "not", "isinstance", "(", "offset", ",", "TimeValue", ")", ":", "raise", "TypeError", ...
Move this interval by the given shift ``offset``. The begin and end time points of the translated interval are ensured to be non-negative (i.e., they are maxed with ``0.000``), unless ``allow_negative`` is set to ``True``. :param offset: the shift to be applied :type o...
[ "Move", "this", "interval", "by", "the", "given", "shift", "offset", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/exacttiming.py#L411-L441
train
readbeyond/aeneas
aeneas/exacttiming.py
TimeInterval.intersection
def intersection(self, other): """ Return the intersection between this time interval and the given time interval, or ``None`` if the two intervals do not overlap. :rtype: :class:`~aeneas.exacttiming.TimeInterval` or ``NoneType`` """ relative_position = self.rela...
python
def intersection(self, other): """ Return the intersection between this time interval and the given time interval, or ``None`` if the two intervals do not overlap. :rtype: :class:`~aeneas.exacttiming.TimeInterval` or ``NoneType`` """ relative_position = self.rela...
[ "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", ...
Return the intersection between this time interval and the given time interval, or ``None`` if the two intervals do not overlap. :rtype: :class:`~aeneas.exacttiming.TimeInterval` or ``NoneType``
[ "Return", "the", "intersection", "between", "this", "time", "interval", "and", "the", "given", "time", "interval", "or", "None", "if", "the", "two", "intervals", "do", "not", "overlap", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/exacttiming.py#L569-L610
train
readbeyond/aeneas
aeneas/exacttiming.py
TimeInterval.is_non_zero_before_non_zero
def is_non_zero_before_non_zero(self, other): """ Return ``True`` if this time interval ends when the given other time interval begins, and both have non zero length. :param other: the other interval :type other: :class:`~aeneas.exacttiming.TimeInterval` :raises...
python
def is_non_zero_before_non_zero(self, other): """ Return ``True`` if this time interval ends when the given other time interval begins, and both have non zero length. :param other: the other interval :type other: :class:`~aeneas.exacttiming.TimeInterval` :raises...
[ "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. :param other: the other interval :type other: :class:`~aeneas.exacttiming.TimeInterval` :raises TypeError: if ``other`` is not an instance of ``TimeInterval`` ...
[ "Return", "True", "if", "this", "time", "interval", "ends", "when", "the", "given", "other", "time", "interval", "begins", "and", "both", "have", "non", "zero", "length", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/exacttiming.py#L623-L634
train
readbeyond/aeneas
aeneas/exacttiming.py
TimeInterval.is_adjacent_before
def is_adjacent_before(self, other): """ Return ``True`` if this time interval ends when the given other time interval begins. :param other: the other interval :type other: :class:`~aeneas.exacttiming.TimeInterval` :raises TypeError: if ``other`` is not an instance of `...
python
def is_adjacent_before(self, other): """ Return ``True`` if this time interval ends when the given other time interval begins. :param other: the other interval :type other: :class:`~aeneas.exacttiming.TimeInterval` :raises TypeError: if ``other`` is not an instance of `...
[ "def", "is_adjacent_before", "(", "self", ",", "other", ")", ":", "if", "not", "isinstance", "(", "other", ",", "TimeInterval", ")", ":", "raise", "TypeError", "(", "u\"other is not an instance of TimeInterval\"", ")", "return", "(", "self", ".", "end", "==", ...
Return ``True`` if this time interval ends when the given other time interval begins. :param other: the other interval :type other: :class:`~aeneas.exacttiming.TimeInterval` :raises TypeError: if ``other`` is not an instance of ``TimeInterval`` :rtype: bool
[ "Return", "True", "if", "this", "time", "interval", "ends", "when", "the", "given", "other", "time", "interval", "begins", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/exacttiming.py#L649-L661
train
readbeyond/aeneas
aeneas/tools/convert_syncmap.py
ConvertSyncMapCLI.check_format
def check_format(self, sm_format): """ Return ``True`` if the given sync map format is allowed, and ``False`` otherwise. :param sm_format: the sync map format to be checked :type sm_format: Unicode string :rtype: bool """ if sm_format not in SyncMapForma...
python
def check_format(self, sm_format): """ Return ``True`` if the given sync map format is allowed, and ``False`` otherwise. :param sm_format: the sync map format to be checked :type sm_format: Unicode string :rtype: bool """ if sm_format not in SyncMapForma...
[ "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", "."...
Return ``True`` if the given sync map format is allowed, and ``False`` otherwise. :param sm_format: the sync map format to be checked :type sm_format: Unicode string :rtype: bool
[ "Return", "True", "if", "the", "given", "sync", "map", "format", "is", "allowed", "and", "False", "otherwise", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/convert_syncmap.py#L163-L177
train
readbeyond/aeneas
aeneas/syncmap/smfbase.py
SyncMapFormatBase._add_fragment
def _add_fragment(cls, syncmap, identifier, lines, begin, end, language=None): """ Add a new fragment to ``syncmap``. :param syncmap: the syncmap to append to :type syncmap: :class:`~aeneas.syncmap.SyncMap` :param identifier: the identifier :type identifier: string ...
python
def _add_fragment(cls, syncmap, identifier, lines, begin, end, language=None): """ Add a new fragment to ``syncmap``. :param syncmap: the syncmap to append to :type syncmap: :class:`~aeneas.syncmap.SyncMap` :param identifier: the identifier :type identifier: string ...
[ "def", "_add_fragment", "(", "cls", ",", "syncmap", ",", "identifier", ",", "lines", ",", "begin", ",", "end", ",", "language", "=", "None", ")", ":", "syncmap", ".", "add_fragment", "(", "SyncMapFragment", "(", "text_fragment", "=", "TextFragment", "(", "...
Add a new fragment to ``syncmap``. :param syncmap: the syncmap to append to :type syncmap: :class:`~aeneas.syncmap.SyncMap` :param identifier: the identifier :type identifier: string :param lines: the lines of the text :type lines: list of string :param begin: th...
[ "Add", "a", "new", "fragment", "to", "syncmap", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/smfbase.py#L53-L80
train
readbeyond/aeneas
aeneas/syncmap/smfbase.py
SyncMapFormatBase.parse
def parse(self, input_text, syncmap): """ Parse the given ``input_text`` and append the extracted fragments to ``syncmap``. :param input_text: the input text as a Unicode string (read from file) :type input_text: string :param syncmap: the syncmap to append to :t...
python
def parse(self, input_text, syncmap): """ Parse the given ``input_text`` and append the extracted fragments to ``syncmap``. :param input_text: the input text as a Unicode string (read from file) :type input_text: string :param syncmap: the syncmap to append to :t...
[ "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``. :param input_text: the input text as a Unicode string (read from file) :type input_text: string :param syncmap: the syncmap to append to :type syncmap: :class:`~aeneas.syncmap.SyncMap`
[ "Parse", "the", "given", "input_text", "and", "append", "the", "extracted", "fragments", "to", "syncmap", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/smfbase.py#L82-L92
train
readbeyond/aeneas
aeneas/syncmap/smfbase.py
SyncMapFormatBase.format
def format(self, syncmap): """ Format the given ``syncmap`` as a Unicode string. :param syncmap: the syncmap to output :type syncmap: :class:`~aeneas.syncmap.SyncMap` :rtype: string """ self.log_exc(u"%s is abstract and cannot be called directly" % (self.TAG), No...
python
def format(self, syncmap): """ Format the given ``syncmap`` as a Unicode string. :param syncmap: the syncmap to output :type syncmap: :class:`~aeneas.syncmap.SyncMap` :rtype: string """ self.log_exc(u"%s is abstract and cannot be called directly" % (self.TAG), No...
[ "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. :param syncmap: the syncmap to output :type syncmap: :class:`~aeneas.syncmap.SyncMap` :rtype: string
[ "Format", "the", "given", "syncmap", "as", "a", "Unicode", "string", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/smfbase.py#L94-L102
train
readbeyond/aeneas
aeneas/tools/execute_task.py
ExecuteTaskCLI.print_examples
def print_examples(self, full=False): """ Print the examples and exit. :param bool full: if ``True``, print all examples; otherwise, print only selected ones """ msg = [] i = 1 for key in sorted(self.DEMOS.keys()): example = ...
python
def print_examples(self, full=False): """ Print the examples and exit. :param bool full: if ``True``, print all examples; otherwise, print only selected ones """ msg = [] i = 1 for key in sorted(self.DEMOS.keys()): example = ...
[ "def", "print_examples", "(", "self", ",", "full", "=", "False", ")", ":", "msg", "=", "[", "]", "i", "=", "1", "for", "key", "in", "sorted", "(", "self", ".", "DEMOS", ".", "keys", "(", ")", ")", ":", "example", "=", "self", ".", "DEMOS", "[",...
Print the examples and exit. :param bool full: if ``True``, print all examples; otherwise, print only selected ones
[ "Print", "the", "examples", "and", "exit", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/execute_task.py#L682-L699
train
readbeyond/aeneas
aeneas/tools/execute_task.py
ExecuteTaskCLI.print_values
def print_values(self, parameter): """ Print the list of values for the given parameter and exit. If ``parameter`` is invalid, print the list of parameter names that have allowed values. :param parameter: the parameter name :type parameter: Unicode string """ ...
python
def print_values(self, parameter): """ Print the list of values for the given parameter and exit. If ``parameter`` is invalid, print the list of parameter names that have allowed values. :param parameter: the parameter name :type parameter: Unicode string """ ...
[ "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\""...
Print the list of values for the given parameter and exit. If ``parameter`` is invalid, print the list of parameter names that have allowed values. :param parameter: the parameter name :type parameter: Unicode string
[ "Print", "the", "list", "of", "values", "for", "the", "given", "parameter", "and", "exit", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/execute_task.py#L711-L729
train
readbeyond/aeneas
setup.py
prepare_cew_for_windows
def prepare_cew_for_windows(): """ Copy files needed to compile the ``cew`` Python C extension on Windows. A glorious day, when Microsoft will offer a decent support for Python and shared libraries, all this mess will be unnecessary and it should be removed. May that day come soon. Return ...
python
def prepare_cew_for_windows(): """ Copy files needed to compile the ``cew`` Python C extension on Windows. A glorious day, when Microsoft will offer a decent support for Python and shared libraries, all this mess will be unnecessary and it should be removed. May that day come soon. Return ...
[ "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\"", ...
Copy files needed to compile the ``cew`` Python C extension on Windows. A glorious day, when Microsoft will offer a decent support for Python and shared libraries, all this mess will be unnecessary and it should be removed. May that day come soon. Return ``True`` if successful, ``False`` otherwise...
[ "Copy", "files", "needed", "to", "compile", "the", "cew", "Python", "C", "extension", "on", "Windows", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/setup.py#L69-L145
train
readbeyond/aeneas
aeneas/validator.py
Validator.check_file_encoding
def check_file_encoding(self, input_file_path): """ Check whether the given file is UTF-8 encoded. :param string input_file_path: the path of the file to be checked :rtype: :class:`~aeneas.validator.ValidatorResult` """ self.log([u"Checking encoding of file '%s'", input_...
python
def check_file_encoding(self, input_file_path): """ Check whether the given file is UTF-8 encoded. :param string input_file_path: the path of the file to be checked :rtype: :class:`~aeneas.validator.ValidatorResult` """ self.log([u"Checking encoding of file '%s'", input_...
[ "def", "check_file_encoding", "(", "self", ",", "input_file_path", ")", ":", "self", ".", "log", "(", "[", "u\"Checking encoding of file '%s'\"", ",", "input_file_path", "]", ")", "self", ".", "result", "=", "ValidatorResult", "(", ")", "if", "self", ".", "_ar...
Check whether the given file is UTF-8 encoded. :param string input_file_path: the path of the file to be checked :rtype: :class:`~aeneas.validator.ValidatorResult`
[ "Check", "whether", "the", "given", "file", "is", "UTF", "-", "8", "encoded", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/validator.py#L259-L276
train
readbeyond/aeneas
aeneas/validator.py
Validator.check_config_xml
def check_config_xml(self, contents): """ Check whether the given XML config file contents is well-formed and it has all the required parameters. :param string contents: the XML config file contents or XML config string :param bool is_config_string: if ``True``, contents is a co...
python
def check_config_xml(self, contents): """ Check whether the given XML config file contents is well-formed and it has all the required parameters. :param string contents: the XML config file contents or XML config string :param bool is_config_string: if ``True``, contents is a co...
[ "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_con...
Check whether the given XML config file contents is well-formed and it has all the required parameters. :param string contents: the XML config file contents or XML config string :param bool is_config_string: if ``True``, contents is a config string :rtype: :class:`~aeneas.validator.Vali...
[ "Check", "whether", "the", "given", "XML", "config", "file", "contents", "is", "well", "-", "formed", "and", "it", "has", "all", "the", "required", "parameters", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/validator.py#L380-L410
train
readbeyond/aeneas
aeneas/validator.py
Validator.check_container
def check_container(self, container_path, container_format=None, config_string=None): """ Check whether the given container is well-formed. :param string container_path: the path of the container to be checked :param container_format: the format of the container :type container...
python
def check_container(self, container_path, container_format=None, config_string=None): """ Check whether the given container is well-formed. :param string container_path: the path of the container to be checked :param container_format: the format of the container :type container...
[ "def", "check_container", "(", "self", ",", "container_path", ",", "container_format", "=", "None", ",", "config_string", "=", "None", ")", ":", "self", ".", "log", "(", "[", "u\"Checking container '%s'\"", ",", "container_path", "]", ")", "self", ".", "result...
Check whether the given container is well-formed. :param string container_path: the path of the container to be checked :param container_format: the format of the container :type container_format: :class:`~aeneas.container.ContainerFormat` :param string config_string: the configuration...
[ "Check", "whether", "the", "given", "container", "is", "well", "-", "formed", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/validator.py#L412-L468
train
readbeyond/aeneas
aeneas/validator.py
Validator._are_safety_checks_disabled
def _are_safety_checks_disabled(self, caller=u"unknown_function"): """ Return ``True`` if safety checks are disabled. :param string caller: the name of the caller function :rtype: bool """ if self.rconf.safety_checks: return False self.log_warn([u"Saf...
python
def _are_safety_checks_disabled(self, caller=u"unknown_function"): """ Return ``True`` if safety checks are disabled. :param string caller: the name of the caller function :rtype: bool """ if self.rconf.safety_checks: return False self.log_warn([u"Saf...
[ "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\"", ",", ...
Return ``True`` if safety checks are disabled. :param string caller: the name of the caller function :rtype: bool
[ "Return", "True", "if", "safety", "checks", "are", "disabled", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/validator.py#L470-L480
train
readbeyond/aeneas
aeneas/validator.py
Validator._failed
def _failed(self, msg): """ Log a validation failure. :param string msg: the error message """ self.log(msg) self.result.passed = False self.result.add_error(msg) self.log(u"Failed")
python
def _failed(self, msg): """ Log a validation failure. :param string msg: the error message """ self.log(msg) self.result.passed = False self.result.add_error(msg) self.log(u"Failed")
[ "def", "_failed", "(", "self", ",", "msg", ")", ":", "self", ".", "log", "(", "msg", ")", "self", ".", "result", ".", "passed", "=", "False", "self", ".", "result", ".", "add_error", "(", "msg", ")", "self", ".", "log", "(", "u\"Failed\"", ")" ]
Log a validation failure. :param string msg: the error message
[ "Log", "a", "validation", "failure", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/validator.py#L482-L491
train
readbeyond/aeneas
aeneas/validator.py
Validator._check_utf8_encoding
def _check_utf8_encoding(self, bstring): """ Check whether the given sequence of bytes is properly encoded in UTF-8. :param bytes bstring: the byte string to be checked """ if not gf.is_bytes(bstring): self._failed(u"The given string is not a sequence of byte...
python
def _check_utf8_encoding(self, bstring): """ Check whether the given sequence of bytes is properly encoded in UTF-8. :param bytes bstring: the byte string to be checked """ if not gf.is_bytes(bstring): self._failed(u"The given string is not a sequence of byte...
[ "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...
Check whether the given sequence of bytes is properly encoded in UTF-8. :param bytes bstring: the byte string to be checked
[ "Check", "whether", "the", "given", "sequence", "of", "bytes", "is", "properly", "encoded", "in", "UTF", "-", "8", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/validator.py#L493-L504
train
readbeyond/aeneas
aeneas/validator.py
Validator._check_reserved_characters
def _check_reserved_characters(self, ustring): """ Check whether the given Unicode string contains reserved characters. :param string ustring: the string to be checked """ forbidden = [c for c in gc.CONFIG_RESERVED_CHARACTERS if c in ustring] if len(forbidden) > 0: ...
python
def _check_reserved_characters(self, ustring): """ Check whether the given Unicode string contains reserved characters. :param string ustring: the string to be checked """ forbidden = [c for c in gc.CONFIG_RESERVED_CHARACTERS if c in ustring] if len(forbidden) > 0: ...
[ "def", "_check_reserved_characters", "(", "self", ",", "ustring", ")", ":", "forbidden", "=", "[", "c", "for", "c", "in", "gc", ".", "CONFIG_RESERVED_CHARACTERS", "if", "c", "in", "ustring", "]", "if", "len", "(", "forbidden", ")", ">", "0", ":", "self",...
Check whether the given Unicode string contains reserved characters. :param string ustring: the string to be checked
[ "Check", "whether", "the", "given", "Unicode", "string", "contains", "reserved", "characters", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/validator.py#L515-L523
train
readbeyond/aeneas
aeneas/validator.py
Validator._check_allowed_values
def _check_allowed_values(self, parameters): """ Check whether the given parameter value is allowed. Log messages into ``self.result``. :param dict parameters: the given parameters """ for key, allowed_values in self.ALLOWED_VALUES: self.log([u"Checking allow...
python
def _check_allowed_values(self, parameters): """ Check whether the given parameter value is allowed. Log messages into ``self.result``. :param dict parameters: the given parameters """ for key, allowed_values in self.ALLOWED_VALUES: self.log([u"Checking allow...
[ "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", ...
Check whether the given parameter value is allowed. Log messages into ``self.result``. :param dict parameters: the given parameters
[ "Check", "whether", "the", "given", "parameter", "value", "is", "allowed", ".", "Log", "messages", "into", "self", ".", "result", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/validator.py#L525-L539
train
readbeyond/aeneas
aeneas/validator.py
Validator._check_implied_parameters
def _check_implied_parameters(self, parameters): """ 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``. :param dict par...
python
def _check_implied_parameters(self, parameters): """ 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``. :param dict par...
[ "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",...
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``. :param dict parameters: the given parameters
[ "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", ...
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/validator.py#L541-L565
train
readbeyond/aeneas
aeneas/validator.py
Validator._check_required_parameters
def _check_required_parameters( self, required_parameters, parameters ): """ Check whether the given parameter dictionary contains all the required paramenters. Log messages into ``self.result``. :param list required_parameters: required p...
python
def _check_required_parameters( self, required_parameters, parameters ): """ Check whether the given parameter dictionary contains all the required paramenters. Log messages into ``self.result``. :param list required_parameters: required p...
[ "def", "_check_required_parameters", "(", "self", ",", "required_parameters", ",", "parameters", ")", ":", "self", ".", "log", "(", "[", "u\"Checking required parameters '%s'\"", ",", "required_parameters", "]", ")", "self", ".", "log", "(", "u\"Checking input paramet...
Check whether the given parameter dictionary contains all the required paramenters. Log messages into ``self.result``. :param list required_parameters: required parameters :param dict parameters: parameters specified by the user
[ "Check", "whether", "the", "given", "parameter", "dictionary", "contains", "all", "the", "required", "paramenters", ".", "Log", "messages", "into", "self", ".", "result", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/validator.py#L567-L594
train
readbeyond/aeneas
aeneas/validator.py
Validator._check_analyzed_job
def _check_analyzed_job(self, job, container): """ 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``. :param job: the...
python
def _check_analyzed_job(self, job, container): """ 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``. :param job: the...
[ "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...
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``. :param job: the Job object generated from container :type job: :class:`~a...
[ "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", "en...
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/validator.py#L596-L645
train
readbeyond/aeneas
aeneas/validator.py
ValidatorResult.pretty_print
def pretty_print(self, warnings=False): """ Pretty print warnings and errors. :param bool warnings: if ``True``, also print warnings. :rtype: string """ msg = [] if (warnings) and (len(self.warnings) > 0): msg.append(u"Warnings:") for warn...
python
def pretty_print(self, warnings=False): """ Pretty print warnings and errors. :param bool warnings: if ``True``, also print warnings. :rtype: string """ msg = [] if (warnings) and (len(self.warnings) > 0): msg.append(u"Warnings:") for warn...
[ "def", "pretty_print", "(", "self", ",", "warnings", "=", "False", ")", ":", "msg", "=", "[", "]", "if", "(", "warnings", ")", "and", "(", "len", "(", "self", ".", "warnings", ")", ">", "0", ")", ":", "msg", ".", "append", "(", "u\"Warnings:\"", ...
Pretty print warnings and errors. :param bool warnings: if ``True``, also print warnings. :rtype: string
[ "Pretty", "print", "warnings", "and", "errors", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/validator.py#L670-L686
train
readbeyond/aeneas
aeneas/ffmpegwrapper.py
FFMPEGWrapper.convert
def convert( self, input_file_path, output_file_path, head_length=None, process_length=None ): """ Convert the audio file at ``input_file_path`` into ``output_file_path``, using the parameters set in the constructor ...
python
def convert( self, input_file_path, output_file_path, head_length=None, process_length=None ): """ Convert the audio file at ``input_file_path`` into ``output_file_path``, using the parameters set in the constructor ...
[ "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...
Convert the audio file at ``input_file_path`` into ``output_file_path``, using the parameters set in the constructor or through the ``parameters`` property. You can skip the beginning of the audio file by specifying ``head_length`` seconds to skip (if it is ``None``, sta...
[ "Convert", "the", "audio", "file", "at", "input_file_path", "into", "output_file_path", "using", "the", "parameters", "set", "in", "the", "constructor", "or", "through", "the", "parameters", "property", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/ffmpegwrapper.py#L163-L238
train
readbeyond/aeneas
aeneas/syncmap/fragment.py
SyncMapFragment.rate_lack
def rate_lack(self, max_rate): """ The time interval that this fragment lacks to respect the given max rate. A positive value means that the current fragment is faster than the max rate (bad). A negative or zero value means that the current fragment has rate slow...
python
def rate_lack(self, max_rate): """ The time interval that this fragment lacks to respect the given max rate. A positive value means that the current fragment is faster than the max rate (bad). A negative or zero value means that the current fragment has rate slow...
[ "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. A positive value means that the current fragment is faster than the max rate (bad). A negative or zero value means that the current fragment has rate slower or equal to the max rate (good). Always...
[ "The", "time", "interval", "that", "this", "fragment", "lacks", "to", "respect", "the", "given", "max", "rate", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/fragment.py#L341-L361
train
readbeyond/aeneas
aeneas/syncmap/fragment.py
SyncMapFragment.rate_slack
def rate_slack(self, max_rate): """ The maximum time interval that can be stolen to this fragment while keeping it respecting the given max rate. For ``REGULAR`` fragments this value is the opposite of the ``rate_lack``. For ``NONSPEECH`` fragments this value is equal to...
python
def rate_slack(self, max_rate): """ The maximum time interval that can be stolen to this fragment while keeping it respecting the given max rate. For ``REGULAR`` fragments this value is the opposite of the ``rate_lack``. For ``NONSPEECH`` fragments this value is equal to...
[ "def", "rate_slack", "(", "self", ",", "max_rate", ")", ":", "if", "self", ".", "fragment_type", "==", "self", ".", "REGULAR", ":", "return", "-", "self", ".", "rate_lack", "(", "max_rate", ")", "elif", "self", ".", "fragment_type", "==", "self", ".", ...
The maximum time interval that can be stolen to this fragment while keeping it respecting the given max rate. For ``REGULAR`` fragments this value is the opposite of the ``rate_lack``. For ``NONSPEECH`` fragments this value is equal to the length of the fragment. For ``H...
[ "The", "maximum", "time", "interval", "that", "can", "be", "stolen", "to", "this", "fragment", "while", "keeping", "it", "respecting", "the", "given", "max", "rate", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/fragment.py#L363-L386
train
readbeyond/aeneas
aeneas/tools/run_vad.py
RunVADCLI.write_to_file
def write_to_file(self, output_file_path, intervals, template): """ Write intervals to file. :param output_file_path: path of the output file to be written; if ``None``, print to stdout :type output_file_path: string (path) :param intervals: a l...
python
def write_to_file(self, output_file_path, intervals, template): """ Write intervals to file. :param output_file_path: path of the output file to be written; if ``None``, print to stdout :type output_file_path: string (path) :param intervals: a l...
[ "def", "write_to_file", "(", "self", ",", "output_file_path", ",", "intervals", ",", "template", ")", ":", "msg", "=", "[", "template", "%", "(", "interval", ")", "for", "interval", "in", "intervals", "]", "if", "output_file_path", "is", "None", ":", "self...
Write intervals to file. :param output_file_path: path of the output file to be written; if ``None``, print to stdout :type output_file_path: string (path) :param intervals: a list of tuples, each representing an interval :type intervals: list of tuple...
[ "Write", "intervals", "to", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/run_vad.py#L145-L163
train
readbeyond/aeneas
aeneas/tools/execute_job.py
ExecuteJobCLI.print_parameters
def print_parameters(self): """ Print the list of parameters and exit. """ self.print_info(u"Available parameters:") self.print_generic(u"\n" + u"\n".join(self.PARAMETERS) + u"\n") return self.HELP_EXIT_CODE
python
def print_parameters(self): """ Print the list of parameters and exit. """ self.print_info(u"Available parameters:") self.print_generic(u"\n" + u"\n".join(self.PARAMETERS) + u"\n") return self.HELP_EXIT_CODE
[ "def", "print_parameters", "(", "self", ")", ":", "self", ".", "print_info", "(", "u\"Available parameters:\"", ")", "self", ".", "print_generic", "(", "u\"\\n\"", "+", "u\"\\n\"", ".", "join", "(", "self", ".", "PARAMETERS", ")", "+", "u\"\\n\"", ")", "retu...
Print the list of parameters and exit.
[ "Print", "the", "list", "of", "parameters", "and", "exit", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/execute_job.py#L148-L154
train
readbeyond/aeneas
aeneas/cewsubprocess.py
main
def main(): """ Run ``aeneas.cew``, reading input text from file and writing audio and interval data to file. """ # make sure we have enough parameters if len(sys.argv) < 6: print("You must pass five arguments: QUIT_AFTER BACKWARDS TEXT_FILE_PATH AUDIO_FILE_PATH DATA_FILE_PATH") ret...
python
def main(): """ Run ``aeneas.cew``, reading input text from file and writing audio and interval data to file. """ # make sure we have enough parameters if len(sys.argv) < 6: print("You must pass five arguments: QUIT_AFTER BACKWARDS TEXT_FILE_PATH AUDIO_FILE_PATH DATA_FILE_PATH") ret...
[ "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"...
Run ``aeneas.cew``, reading input text from file and writing audio and interval data to file.
[ "Run", "aeneas", ".", "cew", "reading", "input", "text", "from", "file", "and", "writing", "audio", "and", "interval", "data", "to", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/cewsubprocess.py#L137-L188
train
readbeyond/aeneas
aeneas/syncmap/smfsmil.py
SyncMapFormatSMIL.parse
def parse(self, input_text, syncmap): """ Read from SMIL file. Limitations: 1. parses only ``<par>`` elements, in order 2. timings must have ``hh:mm:ss.mmm`` or ``ss.mmm`` format (autodetected) 3. both ``clipBegin`` and ``clipEnd`` attributes of ``<audio>`` must be popul...
python
def parse(self, input_text, syncmap): """ Read from SMIL file. Limitations: 1. parses only ``<par>`` elements, in order 2. timings must have ``hh:mm:ss.mmm`` or ``ss.mmm`` format (autodetected) 3. both ``clipBegin`` and ``clipEnd`` attributes of ``<audio>`` must be popul...
[ "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", ")", ")"...
Read from SMIL file. Limitations: 1. parses only ``<par>`` elements, in order 2. timings must have ``hh:mm:ss.mmm`` or ``ss.mmm`` format (autodetected) 3. both ``clipBegin`` and ``clipEnd`` attributes of ``<audio>`` must be populated
[ "Read", "from", "SMIL", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/smfsmil.py#L55-L89
train
readbeyond/aeneas
aeneas/syncmap/fragmentlist.py
SyncMapFragmentList._is_valid_index
def _is_valid_index(self, index): """ Return ``True`` if and only if the given ``index`` is valid. """ if isinstance(index, int): return (index >= 0) and (index < len(self)) if isinstance(index, list): valid = True for i in index: ...
python
def _is_valid_index(self, index): """ Return ``True`` if and only if the given ``index`` is valid. """ if isinstance(index, int): return (index >= 0) and (index < len(self)) if isinstance(index, list): valid = True for i in index: ...
[ "def", "_is_valid_index", "(", "self", ",", "index", ")", ":", "if", "isinstance", "(", "index", ",", "int", ")", ":", "return", "(", "index", ">=", "0", ")", "and", "(", "index", "<", "len", "(", "self", ")", ")", "if", "isinstance", "(", "index",...
Return ``True`` if and only if the given ``index`` is valid.
[ "Return", "True", "if", "and", "only", "if", "the", "given", "index", "is", "valid", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/fragmentlist.py#L105-L117
train
readbeyond/aeneas
aeneas/syncmap/fragmentlist.py
SyncMapFragmentList._check_boundaries
def _check_boundaries(self, fragment): """ Check that the interval of the given fragment is within the boundaries of the list. Raises an error if not OK. """ if not isinstance(fragment, SyncMapFragment): raise TypeError(u"fragment is not an instance of SyncMap...
python
def _check_boundaries(self, fragment): """ Check that the interval of the given fragment is within the boundaries of the list. Raises an error if not OK. """ if not isinstance(fragment, SyncMapFragment): raise TypeError(u"fragment is not an instance of SyncMap...
[ "def", "_check_boundaries", "(", "self", ",", "fragment", ")", ":", "if", "not", "isinstance", "(", "fragment", ",", "SyncMapFragment", ")", ":", "raise", "TypeError", "(", "u\"fragment is not an instance of SyncMapFragment\"", ")", "interval", "=", "fragment", ".",...
Check that the interval of the given fragment is within the boundaries of the list. Raises an error if not OK.
[ "Check", "that", "the", "interval", "of", "the", "given", "fragment", "is", "within", "the", "boundaries", "of", "the", "list", ".", "Raises", "an", "error", "if", "not", "OK", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/fragmentlist.py#L119-L133
train
readbeyond/aeneas
aeneas/syncmap/fragmentlist.py
SyncMapFragmentList.remove
def remove(self, indices): """ Remove the fragments corresponding to the given list of indices. :param indices: the list of indices to be removed :type indices: list of int :raises ValueError: if one of the indices is not valid """ if not self._is_valid_index(in...
python
def remove(self, indices): """ Remove the fragments corresponding to the given list of indices. :param indices: the list of indices to be removed :type indices: list of int :raises ValueError: if one of the indices is not valid """ if not self._is_valid_index(in...
[ "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_...
Remove the fragments corresponding to the given list of indices. :param indices: the list of indices to be removed :type indices: list of int :raises ValueError: if one of the indices is not valid
[ "Remove", "the", "fragments", "corresponding", "to", "the", "given", "list", "of", "indices", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/fragmentlist.py#L223-L246
train
readbeyond/aeneas
aeneas/syncmap/fragmentlist.py
SyncMapFragmentList.sort
def sort(self): """ Sort the fragments in the list. :raises ValueError: if there is a fragment which violates the list constraints """ if self.is_guaranteed_sorted: self.log(u"Already sorted, returning") return self.log...
python
def sort(self): """ Sort the fragments in the list. :raises ValueError: if there is a fragment which violates the list constraints """ if self.is_guaranteed_sorted: self.log(u"Already sorted, returning") return self.log...
[ "def", "sort", "(", "self", ")", ":", "if", "self", ".", "is_guaranteed_sorted", ":", "self", ".", "log", "(", "u\"Already sorted, returning\"", ")", "return", "self", ".", "log", "(", "u\"Sorting...\"", ")", "self", ".", "__fragments", "=", "sorted", "(", ...
Sort the fragments in the list. :raises ValueError: if there is a fragment which violates the list constraints
[ "Sort", "the", "fragments", "in", "the", "list", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/fragmentlist.py#L248-L271
train
readbeyond/aeneas
aeneas/syncmap/fragmentlist.py
SyncMapFragmentList.remove_nonspeech_fragments
def remove_nonspeech_fragments(self, zero_length_only=False): """ Remove ``NONSPEECH`` fragments from the list. If ``zero_length_only`` is ``True``, remove only those fragments with zero length, and make all the others ``REGULAR``. :param bool zero_length_only: remove o...
python
def remove_nonspeech_fragments(self, zero_length_only=False): """ Remove ``NONSPEECH`` fragments from the list. If ``zero_length_only`` is ``True``, remove only those fragments with zero length, and make all the others ``REGULAR``. :param bool zero_length_only: remove o...
[ "def", "remove_nonspeech_fragments", "(", "self", ",", "zero_length_only", "=", "False", ")", ":", "self", ".", "log", "(", "u\"Removing nonspeech fragments...\"", ")", "nonspeech", "=", "list", "(", "self", ".", "nonspeech_fragments", ")", "if", "zero_length_only",...
Remove ``NONSPEECH`` fragments from the list. If ``zero_length_only`` is ``True``, remove only those fragments with zero length, and make all the others ``REGULAR``. :param bool zero_length_only: remove only zero length NONSPEECH fragments
[ "Remove", "NONSPEECH", "fragments", "from", "the", "list", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/fragmentlist.py#L273-L292
train
readbeyond/aeneas
aeneas/syncmap/fragmentlist.py
SyncMapFragmentList.has_zero_length_fragments
def has_zero_length_fragments(self, min_index=None, max_index=None): """ 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. :param int min_index: examine fragments ...
python
def has_zero_length_fragments(self, min_index=None, max_index=None): """ 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. :param int min_index: examine fragments ...
[ "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"...
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. :param int min_index: examine fragments with index greater than or equal to this index (i.e., included) :param int max_in...
[ "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", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/fragmentlist.py#L294-L309
train
readbeyond/aeneas
aeneas/syncmap/fragmentlist.py
SyncMapFragmentList.has_adjacent_fragments_only
def has_adjacent_fragments_only(self, min_index=None, max_index=None): """ Return ``True`` if the list contains only adjacent fragments, that is, if it does not have gaps. :param int min_index: examine fragments with index greater than or equal to this index (i.e., included) :pa...
python
def has_adjacent_fragments_only(self, min_index=None, max_index=None): """ Return ``True`` if the list contains only adjacent fragments, that is, if it does not have gaps. :param int min_index: examine fragments with index greater than or equal to this index (i.e., included) :pa...
[ "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", "...
Return ``True`` if the list contains only adjacent fragments, that is, if it does not have gaps. :param int min_index: examine fragments with index greater than or equal to this index (i.e., included) :param int max_index: examine fragments with index smaller than this index (i.e., excluded) ...
[ "Return", "True", "if", "the", "list", "contains", "only", "adjacent", "fragments", "that", "is", "if", "it", "does", "not", "have", "gaps", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/fragmentlist.py#L311-L331
train
readbeyond/aeneas
aeneas/syncmap/fragmentlist.py
SyncMapFragmentList.offset
def offset(self, offset): """ Move all the intervals in the list by the given ``offset``. :param offset: the shift to be applied :type offset: :class:`~aeneas.exacttiming.TimeValue` :raises TypeError: if ``offset`` is not an instance of ``TimeValue`` """ self.lo...
python
def offset(self, offset): """ Move all the intervals in the list by the given ``offset``. :param offset: the shift to be applied :type offset: :class:`~aeneas.exacttiming.TimeValue` :raises TypeError: if ``offset`` is not an instance of ``TimeValue`` """ self.lo...
[ "def", "offset", "(", "self", ",", "offset", ")", ":", "self", ".", "log", "(", "u\"Applying offset to all fragments...\"", ")", "self", ".", "log", "(", "[", "u\" Offset %.3f\"", ",", "offset", "]", ")", "for", "fragment", "in", "self", ".", "fragments", ...
Move all the intervals in the list by the given ``offset``. :param offset: the shift to be applied :type offset: :class:`~aeneas.exacttiming.TimeValue` :raises TypeError: if ``offset`` is not an instance of ``TimeValue``
[ "Move", "all", "the", "intervals", "in", "the", "list", "by", "the", "given", "offset", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/fragmentlist.py#L360-L377
train
readbeyond/aeneas
aeneas/syncmap/fragmentlist.py
SyncMapFragmentList.move_transition_point
def move_transition_point(self, fragment_index, value): """ Change the transition point between fragment ``fragment_index`` and the next fragment to the time value ``value``. This method fails silently (without changing the fragment list) if at least one of the following...
python
def move_transition_point(self, fragment_index, value): """ Change the transition point between fragment ``fragment_index`` and the next fragment to the time value ``value``. This method fails silently (without changing the fragment list) if at least one of the following...
[ "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", ...
Change the transition point between fragment ``fragment_index`` and the next fragment to the time value ``value``. This method fails silently (without changing the fragment list) if at least one of the following conditions holds: * ``fragment_index`` is negative * ``fra...
[ "Change", "the", "transition", "point", "between", "fragment", "fragment_index", "and", "the", "next", "fragment", "to", "the", "time", "value", "value", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/fragmentlist.py#L379-L416
train
readbeyond/aeneas
aeneas/syncmap/fragmentlist.py
SyncMapFragmentList.inject_long_nonspeech_fragments
def inject_long_nonspeech_fragments(self, pairs, replacement_string): """ Inject nonspeech fragments corresponding to the given intervals in this fragment list. It is assumed that ``pairs`` are consistent, e.g. they are produced by ``fragments_ending_inside_nonspeech_intervals``...
python
def inject_long_nonspeech_fragments(self, pairs, replacement_string): """ Inject nonspeech fragments corresponding to the given intervals in this fragment list. It is assumed that ``pairs`` are consistent, e.g. they are produced by ``fragments_ending_inside_nonspeech_intervals``...
[ "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_BOUND...
Inject nonspeech fragments corresponding to the given intervals in this fragment list. It is assumed that ``pairs`` are consistent, e.g. they are produced by ``fragments_ending_inside_nonspeech_intervals``. :param list pairs: list of ``(TimeInterval, int)`` pairs, ...
[ "Inject", "nonspeech", "fragments", "corresponding", "to", "the", "given", "intervals", "in", "this", "fragment", "list", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/fragmentlist.py#L507-L550
train
readbeyond/aeneas
aeneas/dtw.py
DTWAligner.compute_accumulated_cost_matrix
def compute_accumulated_cost_matrix(self): """ Compute the accumulated cost matrix, and return it. Return ``None`` if the accumulated cost matrix cannot be computed because one of the two waves is empty after masking (if requested). :rtype: :class:`numpy.ndarray` (2D) :...
python
def compute_accumulated_cost_matrix(self): """ Compute the accumulated cost matrix, and return it. Return ``None`` if the accumulated cost matrix cannot be computed because one of the two waves is empty after masking (if requested). :rtype: :class:`numpy.ndarray` (2D) :...
[ "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", ".", "lo...
Compute the accumulated cost matrix, and return it. Return ``None`` if the accumulated cost matrix cannot be computed because one of the two waves is empty after masking (if requested). :rtype: :class:`numpy.ndarray` (2D) :raises: RuntimeError: if both the C extension and ...
[ "Compute", "the", "accumulated", "cost", "matrix", "and", "return", "it", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/dtw.py#L160-L178
train
readbeyond/aeneas
aeneas/dtw.py
DTWAligner.compute_path
def compute_path(self): """ Compute the min cost path between the two waves, and return it. Return the computed path as a tuple with two elements, each being a :class:`numpy.ndarray` (1D) of ``int`` indices: :: ([r_1, r_2, ..., r_k], [s_1, s_2, ..., s_k]) where ``r_i``...
python
def compute_path(self): """ Compute the min cost path between the two waves, and return it. Return the computed path as a tuple with two elements, each being a :class:`numpy.ndarray` (1D) of ``int`` indices: :: ([r_1, r_2, ..., r_k], [s_1, s_2, ..., s_k]) where ``r_i``...
[ "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\"Co...
Compute the min cost path between the two waves, and return it. Return the computed path as a tuple with two elements, each being a :class:`numpy.ndarray` (1D) of ``int`` indices: :: ([r_1, r_2, ..., r_k], [s_1, s_2, ..., s_k]) where ``r_i`` are the indices in the real wave an...
[ "Compute", "the", "min", "cost", "path", "between", "the", "two", "waves", "and", "return", "it", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/dtw.py#L180-L224
train
readbeyond/aeneas
aeneas/dtw.py
DTWAligner.compute_boundaries
def compute_boundaries(self, synt_anchors): """ 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. If ``synt_anchors`` has ``k`` elements, th...
python
def compute_boundaries(self, synt_anchors): """ 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. If ``synt_anchors`` has ``k`` elements, th...
[ "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"...
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. If ``synt_anchors`` has ``k`` elements, the returned array will have ``k+1`` elements, accounting ...
[ "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", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/dtw.py#L226-L296
train
readbeyond/aeneas
aeneas/dtw.py
DTWAligner._setup_dtw
def _setup_dtw(self): """ Set the DTW object up. """ # check if the DTW object has already been set up if self.dtw is not None: return # check we have the AudioFileMFCC objects if (self.real_wave_mfcc is None) or (self.real_wave_mfcc.middle_mfcc is No...
python
def _setup_dtw(self): """ Set the DTW object up. """ # check if the DTW object has already been set up if self.dtw is not None: return # check we have the AudioFileMFCC objects if (self.real_wave_mfcc is None) or (self.real_wave_mfcc.middle_mfcc is No...
[ "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", ")", ":...
Set the DTW object up.
[ "Set", "the", "DTW", "object", "up", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/dtw.py#L298-L363
train
readbeyond/aeneas
check_dependencies.py
check_import
def check_import(): """ Try to import the aeneas package and return ``True`` if that fails. """ try: import aeneas print_success(u"aeneas OK") return False except ImportError: print_error(u"aeneas ERROR") print_info(u" Unable to load the aenea...
python
def check_import(): """ Try to import the aeneas package and return ``True`` if that fails. """ try: import aeneas print_success(u"aeneas OK") return False except ImportError: print_error(u"aeneas ERROR") print_info(u" Unable to load the aenea...
[ "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 th...
Try to import the aeneas package and return ``True`` if that fails.
[ "Try", "to", "import", "the", "aeneas", "package", "and", "return", "True", "if", "that", "fails", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/check_dependencies.py#L86-L105
train
readbeyond/aeneas
check_dependencies.py
main
def main(): """ The entry point for this module """ # first, check we can import aeneas package, exiting on failure if check_import(): sys.exit(1) # import and run the built-in diagnostics from aeneas.diagnostics import Diagnostics errors, warnings, c_ext_warnings = Diagnostics.check_al...
python
def main(): """ The entry point for this module """ # first, check we can import aeneas package, exiting on failure if check_import(): sys.exit(1) # import and run the built-in diagnostics from aeneas.diagnostics import Diagnostics errors, warnings, c_ext_warnings = Diagnostics.check_al...
[ "def", "main", "(", ")", ":", "if", "check_import", "(", ")", ":", "sys", ".", "exit", "(", "1", ")", "from", "aeneas", ".", "diagnostics", "import", "Diagnostics", "errors", ",", "warnings", ",", "c_ext_warnings", "=", "Diagnostics", ".", "check_all", "...
The entry point for this module
[ "The", "entry", "point", "for", "this", "module" ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/check_dependencies.py#L108-L127
train
readbeyond/aeneas
aeneas/tree.py
Tree.is_pleasant
def is_pleasant(self): """ Return ``True`` if all the leaves in the subtree rooted at this node are at the same level. :rtype: bool """ levels = sorted([n.level for n in self.leaves]) return levels[0] == levels[-1]
python
def is_pleasant(self): """ Return ``True`` if all the leaves in the subtree rooted at this node are at the same level. :rtype: bool """ levels = sorted([n.level for n in self.leaves]) return levels[0] == levels[-1]
[ "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. :rtype: bool
[ "Return", "True", "if", "all", "the", "leaves", "in", "the", "subtree", "rooted", "at", "this", "node", "are", "at", "the", "same", "level", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tree.py#L208-L217
train
readbeyond/aeneas
aeneas/tree.py
Tree.add_child
def add_child(self, node, as_last=True): """ Add the given child to the current list of children. The new child is appended as the last child if ``as_last`` is ``True``, or as the first child if ``as_last`` is ``False``. This call updates the ``__parent`` and ``__level`` fields...
python
def add_child(self, node, as_last=True): """ Add the given child to the current list of children. The new child is appended as the last child if ``as_last`` is ``True``, or as the first child if ``as_last`` is ``False``. This call updates the ``__parent`` and ``__level`` fields...
[ "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", ",", "TypeE...
Add the given child to the current list of children. The new child is appended as the last child if ``as_last`` is ``True``, or as the first child if ``as_last`` is ``False``. This call updates the ``__parent`` and ``__level`` fields of ``node``. :param node: the child node to be adde...
[ "Add", "the", "given", "child", "to", "the", "current", "list", "of", "children", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tree.py#L219-L243
train
readbeyond/aeneas
aeneas/tree.py
Tree.remove_child
def remove_child(self, index): """ Remove the child at the given index from the current list of children. :param int index: the index of the child to be removed """ if index < 0: index = index + len(self) self.__children = self.__children[0:index] + s...
python
def remove_child(self, index): """ Remove the child at the given index from the current list of children. :param int index: the index of the child to be removed """ if index < 0: index = index + len(self) self.__children = self.__children[0:index] + s...
[ "def", "remove_child", "(", "self", ",", "index", ")", ":", "if", "index", "<", "0", ":", "index", "=", "index", "+", "len", "(", "self", ")", "self", ".", "__children", "=", "self", ".", "__children", "[", "0", ":", "index", "]", "+", "self", "....
Remove the child at the given index from the current list of children. :param int index: the index of the child to be removed
[ "Remove", "the", "child", "at", "the", "given", "index", "from", "the", "current", "list", "of", "children", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tree.py#L245-L254
train
readbeyond/aeneas
aeneas/tree.py
Tree.remove
def remove(self): """ Remove this node from the list of children of its current parent, if the current parent is not ``None``, otherwise do nothing. .. versionadded:: 1.7.0 """ if self.parent is not None: for i, child in enumerate(self.parent.children): ...
python
def remove(self): """ Remove this node from the list of children of its current parent, if the current parent is not ``None``, otherwise do nothing. .. versionadded:: 1.7.0 """ if self.parent is not None: for i, child in enumerate(self.parent.children): ...
[ "def", "remove", "(", "self", ")", ":", "if", "self", ".", "parent", "is", "not", "None", ":", "for", "i", ",", "child", "in", "enumerate", "(", "self", ".", "parent", ".", "children", ")", ":", "if", "id", "(", "child", ")", "==", "id", "(", "...
Remove this node from the list of children of its current parent, if the current parent is not ``None``, otherwise do nothing. .. versionadded:: 1.7.0
[ "Remove", "this", "node", "from", "the", "list", "of", "children", "of", "its", "current", "parent", "if", "the", "current", "parent", "is", "not", "None", "otherwise", "do", "nothing", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tree.py#L256-L268
train
readbeyond/aeneas
aeneas/tree.py
Tree.remove_children
def remove_children(self, reset_parent=True): """ Remove all the children of this node. :param bool reset_parent: if ``True``, set to ``None`` the parent attribute of the children """ if reset_parent: for child in self.children: ...
python
def remove_children(self, reset_parent=True): """ Remove all the children of this node. :param bool reset_parent: if ``True``, set to ``None`` the parent attribute of the children """ if reset_parent: for child in self.children: ...
[ "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. :param bool reset_parent: if ``True``, set to ``None`` the parent attribute of the children
[ "Remove", "all", "the", "children", "of", "this", "node", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tree.py#L270-L280
train
readbeyond/aeneas
aeneas/tree.py
Tree.leaves_not_empty
def leaves_not_empty(self): """ Return the list of leaves not empty in the tree rooted at this node, in DFS order. :rtype: list of :class:`~aeneas.tree.Tree` """ return [n for n in self.dfs if ((n.is_leaf) and (not n.is_empty))]
python
def leaves_not_empty(self): """ Return the list of leaves not empty in the tree rooted at this node, in DFS order. :rtype: list of :class:`~aeneas.tree.Tree` """ return [n for n in self.dfs if ((n.is_leaf) and (not n.is_empty))]
[ "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. :rtype: list of :class:`~aeneas.tree.Tree`
[ "Return", "the", "list", "of", "leaves", "not", "empty", "in", "the", "tree", "rooted", "at", "this", "node", "in", "DFS", "order", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tree.py#L335-L343
train
readbeyond/aeneas
aeneas/tree.py
Tree.height
def height(self): """ 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. :rtype: int """...
python
def height(self): """ 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. :rtype: int """...
[ "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. :rtype: int
[ "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", "si...
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tree.py#L357-L368
train
readbeyond/aeneas
aeneas/tree.py
Tree.levels
def levels(self): """ 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. :rtype: list of lists of :class:`~aeneas.tree.Tree` """ ret = [[] for i in range(self.height)] ...
python
def levels(self): """ 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. :rtype: list of lists of :class:`~aeneas.tree.Tree` """ ret = [[] for i in range(self.height)] ...
[ "def", "levels", "(", "self", ")", ":", "ret", "=", "[", "[", "]", "for", "i", "in", "range", "(", "self", ".", "height", ")", "]", "for", "node", "in", "self", ".", "subtree", ":", "ret", "[", "node", ".", "level", "-", "self", ".", "level", ...
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. :rtype: list of lists of :class:`~aeneas.tree.Tree`
[ "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", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tree.py#L397-L409
train
readbeyond/aeneas
aeneas/tree.py
Tree.level_at_index
def level_at_index(self, index): """ Return the list of nodes at level ``index``, in DFS order. :param int index: the index :rtype: list of :class:`~aeneas.tree.Tree` :raises: ValueError if the given ``index`` is not valid """ if not isinstance(index, in...
python
def level_at_index(self, index): """ Return the list of nodes at level ``index``, in DFS order. :param int index: the index :rtype: list of :class:`~aeneas.tree.Tree` :raises: ValueError if the given ``index`` is not valid """ if not isinstance(index, in...
[ "def", "level_at_index", "(", "self", ",", "index", ")", ":", "if", "not", "isinstance", "(", "index", ",", "int", ")", ":", "self", ".", "log_exc", "(", "u\"Index is not an integer\"", ",", "None", ",", "True", ",", "TypeError", ")", "levels", "=", "sel...
Return the list of nodes at level ``index``, in DFS order. :param int index: the index :rtype: list of :class:`~aeneas.tree.Tree` :raises: ValueError if the given ``index`` is not valid
[ "Return", "the", "list", "of", "nodes", "at", "level", "index", "in", "DFS", "order", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tree.py#L425-L440
train
readbeyond/aeneas
aeneas/tree.py
Tree.ancestor
def ancestor(self, index): """ Return the ``index``-th ancestor. The 0-th ancestor is the node itself, the 1-th ancestor is its parent node, etc. :param int index: the number of levels to go up :rtype: :class:`~aeneas.tree.Tree` :raises: TypeError if ``i...
python
def ancestor(self, index): """ Return the ``index``-th ancestor. The 0-th ancestor is the node itself, the 1-th ancestor is its parent node, etc. :param int index: the number of levels to go up :rtype: :class:`~aeneas.tree.Tree` :raises: TypeError if ``i...
[ "def", "ancestor", "(", "self", ",", "index", ")", ":", "if", "not", "isinstance", "(", "index", ",", "int", ")", ":", "self", ".", "log_exc", "(", "u\"index is not an integer\"", ",", "None", ",", "True", ",", "TypeError", ")", "if", "index", "<", "0"...
Return the ``index``-th ancestor. The 0-th ancestor is the node itself, the 1-th ancestor is its parent node, etc. :param int index: the number of levels to go up :rtype: :class:`~aeneas.tree.Tree` :raises: TypeError if ``index`` is not an int :raises: ValueErro...
[ "Return", "the", "index", "-", "th", "ancestor", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tree.py#L454-L476
train
readbeyond/aeneas
aeneas/tree.py
Tree.keep_levels
def keep_levels(self, level_indices): """ Rearrange the tree rooted at this node to keep only the given levels. The returned Tree will still be rooted at the current node, i.e. this function implicitly adds ``0`` to ``level_indices``. If ``level_indices`` is an ...
python
def keep_levels(self, level_indices): """ Rearrange the tree rooted at this node to keep only the given levels. The returned Tree will still be rooted at the current node, i.e. this function implicitly adds ``0`` to ``level_indices``. If ``level_indices`` is an ...
[ "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", ...
Rearrange the tree rooted at this node to keep only the given levels. The returned Tree will still be rooted at the current node, i.e. this function implicitly adds ``0`` to ``level_indices``. If ``level_indices`` is an empty list, only this node will be returned, with ...
[ "Rearrange", "the", "tree", "rooted", "at", "this", "node", "to", "keep", "only", "the", "given", "levels", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tree.py#L478-L521
train
readbeyond/aeneas
thirdparty/mfcc.py
s2dctmat
def s2dctmat(nfilt,ncep,freqstep): """Return the 'legacy' not-quite-DCT matrix used by Sphinx""" 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')) melco...
python
def s2dctmat(nfilt,ncep,freqstep): """Return the 'legacy' not-quite-DCT matrix used by Sphinx""" 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')) melco...
[ "def", "s2dctmat", "(", "nfilt", ",", "ncep", ",", "freqstep", ")", ":", "melcos", "=", "numpy", ".", "empty", "(", "(", "ncep", ",", "nfilt", ")", ",", "'double'", ")", "for", "i", "in", "range", "(", "0", ",", "ncep", ")", ":", "freq", "=", "...
Return the 'legacy' not-quite-DCT matrix used by Sphinx
[ "Return", "the", "legacy", "not", "-", "quite", "-", "DCT", "matrix", "used", "by", "Sphinx" ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/thirdparty/mfcc.py#L146-L153
train
readbeyond/aeneas
thirdparty/mfcc.py
logspec2s2mfc
def logspec2s2mfc(logspec, ncep=13): """Convert log-power-spectrum bins to MFCC using the 'legacy' Sphinx transform""" nframes, nfilt = logspec.shape melcos = s2dctmat(nfilt, ncep, 1./nfilt) return numpy.dot(logspec, melcos.T) / nfilt
python
def logspec2s2mfc(logspec, ncep=13): """Convert log-power-spectrum bins to MFCC using the 'legacy' Sphinx transform""" nframes, nfilt = logspec.shape melcos = s2dctmat(nfilt, ncep, 1./nfilt) return numpy.dot(logspec, melcos.T) / nfilt
[ "def", "logspec2s2mfc", "(", "logspec", ",", "ncep", "=", "13", ")", ":", "nframes", ",", "nfilt", "=", "logspec", ".", "shape", "melcos", "=", "s2dctmat", "(", "nfilt", ",", "ncep", ",", "1.", "/", "nfilt", ")", "return", "numpy", ".", "dot", "(", ...
Convert log-power-spectrum bins to MFCC using the 'legacy' Sphinx transform
[ "Convert", "log", "-", "power", "-", "spectrum", "bins", "to", "MFCC", "using", "the", "legacy", "Sphinx", "transform" ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/thirdparty/mfcc.py#L155-L160
train
readbeyond/aeneas
thirdparty/mfcc.py
dct
def dct(input, K=13): """Convert log-power-spectrum to MFCC using the orthogonal DCT-II""" nframes, N = input.shape freqstep = numpy.pi / N cosmat = dctmat(N,K,freqstep) return numpy.dot(input, cosmat) * numpy.sqrt(2.0 / N)
python
def dct(input, K=13): """Convert log-power-spectrum to MFCC using the orthogonal DCT-II""" nframes, N = input.shape freqstep = numpy.pi / N cosmat = dctmat(N,K,freqstep) return numpy.dot(input, cosmat) * numpy.sqrt(2.0 / N)
[ "def", "dct", "(", "input", ",", "K", "=", "13", ")", ":", "nframes", ",", "N", "=", "input", ".", "shape", "freqstep", "=", "numpy", ".", "pi", "/", "N", "cosmat", "=", "dctmat", "(", "N", ",", "K", ",", "freqstep", ")", "return", "numpy", "."...
Convert log-power-spectrum to MFCC using the orthogonal DCT-II
[ "Convert", "log", "-", "power", "-", "spectrum", "to", "MFCC", "using", "the", "orthogonal", "DCT", "-", "II" ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/thirdparty/mfcc.py#L174-L179
train
readbeyond/aeneas
thirdparty/mfcc.py
dct2
def dct2(input, K=13): """Convert log-power-spectrum to MFCC using the normalized DCT-II""" nframes, N = input.shape freqstep = numpy.pi / N cosmat = dctmat(N,K,freqstep,False) return numpy.dot(input, cosmat) * (2.0 / N)
python
def dct2(input, K=13): """Convert log-power-spectrum to MFCC using the normalized DCT-II""" nframes, N = input.shape freqstep = numpy.pi / N cosmat = dctmat(N,K,freqstep,False) return numpy.dot(input, cosmat) * (2.0 / N)
[ "def", "dct2", "(", "input", ",", "K", "=", "13", ")", ":", "nframes", ",", "N", "=", "input", ".", "shape", "freqstep", "=", "numpy", ".", "pi", "/", "N", "cosmat", "=", "dctmat", "(", "N", ",", "K", ",", "freqstep", ",", "False", ")", "return...
Convert log-power-spectrum to MFCC using the normalized DCT-II
[ "Convert", "log", "-", "power", "-", "spectrum", "to", "MFCC", "using", "the", "normalized", "DCT", "-", "II" ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/thirdparty/mfcc.py#L181-L186
train
readbeyond/aeneas
aeneas/audiofile.py
AudioFile.read_properties
def read_properties(self): """ Populate this object by reading the audio properties of the file at the given path. Currently this function uses :class:`~aeneas.ffprobewrapper.FFPROBEWrapper` to get the audio file properties. :raises: :class:`~aeneas.audiofile.Au...
python
def read_properties(self): """ Populate this object by reading the audio properties of the file at the given path. Currently this function uses :class:`~aeneas.ffprobewrapper.FFPROBEWrapper` to get the audio file properties. :raises: :class:`~aeneas.audiofile.Au...
[ "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\"", "%",...
Populate this object by reading the audio properties of the file at the given path. Currently this function uses :class:`~aeneas.ffprobewrapper.FFPROBEWrapper` to get the audio file properties. :raises: :class:`~aeneas.audiofile.AudioFileProbeError`: if the path to the ``ffprob...
[ "Populate", "this", "object", "by", "reading", "the", "audio", "properties", "of", "the", "file", "at", "the", "given", "path", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofile.py#L330-L376
train
readbeyond/aeneas
aeneas/audiofile.py
AudioFile.read_samples_from_file
def read_samples_from_file(self): """ Load the audio samples from file into memory. If ``self.file_format`` is ``None`` or it is not ``("pcm_s16le", 1, self.rconf.sample_rate)``, the file will be first converted to a temporary PCM16 mono WAVE file. Audio data wil...
python
def read_samples_from_file(self): """ Load the audio samples from file into memory. If ``self.file_format`` is ``None`` or it is not ``("pcm_s16le", 1, self.rconf.sample_rate)``, the file will be first converted to a temporary PCM16 mono WAVE file. Audio data wil...
[ "def", "read_samples_from_file", "(", "self", ")", ":", "self", ".", "log", "(", "u\"Loading audio data...\"", ")", "if", "not", "gf", ".", "file_can_be_read", "(", "self", ".", "file_path", ")", ":", "self", ".", "log_exc", "(", "u\"File '%s' cannot be read\"",...
Load the audio samples from file into memory. If ``self.file_format`` is ``None`` or it is not ``("pcm_s16le", 1, self.rconf.sample_rate)``, the file will be first converted to a temporary PCM16 mono WAVE file. Audio data will be read from this temporary file, which will...
[ "Load", "the", "audio", "samples", "from", "file", "into", "memory", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofile.py#L378-L464
train
readbeyond/aeneas
aeneas/audiofile.py
AudioFile.preallocate_memory
def preallocate_memory(self, capacity): """ Preallocate memory to store audio samples, to avoid repeated new allocations and copies while performing several consecutive append operations. If ``self.__samples`` is not initialized, it will become an array of ``capacity`` z...
python
def preallocate_memory(self, capacity): """ Preallocate memory to store audio samples, to avoid repeated new allocations and copies while performing several consecutive append operations. If ``self.__samples`` is not initialized, it will become an array of ``capacity`` z...
[ "def", "preallocate_memory", "(", "self", ",", "capacity", ")", ":", "if", "capacity", "<", "0", ":", "raise", "ValueError", "(", "u\"The capacity value cannot be negative\"", ")", "if", "self", ".", "__samples", "is", "None", ":", "self", ".", "log", "(", "...
Preallocate memory to store audio samples, to avoid repeated new allocations and copies while performing several consecutive append operations. If ``self.__samples`` is not initialized, it will become an array of ``capacity`` zeros. If ``capacity`` is larger than the current ca...
[ "Preallocate", "memory", "to", "store", "audio", "samples", "to", "avoid", "repeated", "new", "allocations", "and", "copies", "while", "performing", "several", "consecutive", "append", "operations", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofile.py#L466-L499
train
readbeyond/aeneas
aeneas/audiofile.py
AudioFile.minimize_memory
def minimize_memory(self): """ Reduce the allocated memory to the minimum required to store the current audio samples. This function is meant to be called when building a wave incrementally, after the last append operation. .. versionadded:: 1.5.0 """ ...
python
def minimize_memory(self): """ Reduce the allocated memory to the minimum required to store the current audio samples. This function is meant to be called when building a wave incrementally, after the last append operation. .. versionadded:: 1.5.0 """ ...
[ "def", "minimize_memory", "(", "self", ")", ":", "if", "self", ".", "__samples", "is", "None", ":", "self", ".", "log", "(", "u\"Not initialized, returning\"", ")", "else", ":", "self", ".", "log", "(", "u\"Initialized, minimizing memory...\"", ")", "self", "....
Reduce the allocated memory to the minimum required to store the current audio samples. This function is meant to be called when building a wave incrementally, after the last append operation. .. versionadded:: 1.5.0
[ "Reduce", "the", "allocated", "memory", "to", "the", "minimum", "required", "to", "store", "the", "current", "audio", "samples", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofile.py#L501-L517
train
readbeyond/aeneas
aeneas/audiofile.py
AudioFile.add_samples
def add_samples(self, samples, reverse=False): """ Concatenate the given new samples to the current audio data. This function initializes the memory if no audio data is present already. If ``reverse`` is ``True``, the new samples will be reversed and then concatenated. ...
python
def add_samples(self, samples, reverse=False): """ Concatenate the given new samples to the current audio data. This function initializes the memory if no audio data is present already. If ``reverse`` is ``True``, the new samples will be reversed and then concatenated. ...
[ "def", "add_samples", "(", "self", ",", "samples", ",", "reverse", "=", "False", ")", ":", "self", ".", "log", "(", "u\"Adding samples...\"", ")", "samples_length", "=", "len", "(", "samples", ")", "current_length", "=", "self", ".", "__samples_length", "fut...
Concatenate the given new samples to the current audio data. This function initializes the memory if no audio data is present already. If ``reverse`` is ``True``, the new samples will be reversed and then concatenated. :param samples: the new samples to be concatenated ...
[ "Concatenate", "the", "given", "new", "samples", "to", "the", "current", "audio", "data", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofile.py#L519-L547
train
readbeyond/aeneas
aeneas/audiofile.py
AudioFile.reverse
def reverse(self): """ Reverse the audio data. :raises: :class:`~aeneas.audiofile.AudioFileNotInitializedError`: if the audio file is not initialized yet .. versionadded:: 1.2.0 """ if self.__samples is None: if self.file_path is None: self.l...
python
def reverse(self): """ Reverse the audio data. :raises: :class:`~aeneas.audiofile.AudioFileNotInitializedError`: if the audio file is not initialized yet .. versionadded:: 1.2.0 """ if self.__samples is None: if self.file_path is None: self.l...
[ "def", "reverse", "(", "self", ")", ":", "if", "self", ".", "__samples", "is", "None", ":", "if", "self", ".", "file_path", "is", "None", ":", "self", ".", "log_exc", "(", "u\"AudioFile object not initialized\"", ",", "None", ",", "True", ",", "AudioFileNo...
Reverse the audio data. :raises: :class:`~aeneas.audiofile.AudioFileNotInitializedError`: if the audio file is not initialized yet .. versionadded:: 1.2.0
[ "Reverse", "the", "audio", "data", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofile.py#L549-L564
train
readbeyond/aeneas
aeneas/audiofile.py
AudioFile.trim
def trim(self, begin=None, length=None): """ Get a slice of the audio data of ``length`` seconds, starting from ``begin`` seconds. If audio data is not loaded, load it and then slice it. :param begin: the start position, in seconds :type begin: :class:`~aeneas.exacttim...
python
def trim(self, begin=None, length=None): """ Get a slice of the audio data of ``length`` seconds, starting from ``begin`` seconds. If audio data is not loaded, load it and then slice it. :param begin: the start position, in seconds :type begin: :class:`~aeneas.exacttim...
[ "def", "trim", "(", "self", ",", "begin", "=", "None", ",", "length", "=", "None", ")", ":", "for", "variable", ",", "name", "in", "[", "(", "begin", ",", "\"begin\"", ")", ",", "(", "length", ",", "\"length\"", ")", "]", ":", "if", "(", "variabl...
Get a slice of the audio data of ``length`` seconds, starting from ``begin`` seconds. If audio data is not loaded, load it and then slice it. :param begin: the start position, in seconds :type begin: :class:`~aeneas.exacttiming.TimeValue` :param length: the position, in secon...
[ "Get", "a", "slice", "of", "the", "audio", "data", "of", "length", "seconds", "starting", "from", "begin", "seconds", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofile.py#L566-L605
train
readbeyond/aeneas
aeneas/audiofile.py
AudioFile.write
def write(self, file_path): """ Write the audio data to file. Return ``True`` on success, or ``False`` otherwise. :param string file_path: the path of the output file to be written :raises: :class:`~aeneas.audiofile.AudioFileNotInitializedError`: if the audio file is not initial...
python
def write(self, file_path): """ Write the audio data to file. Return ``True`` on success, or ``False`` otherwise. :param string file_path: the path of the output file to be written :raises: :class:`~aeneas.audiofile.AudioFileNotInitializedError`: if the audio file is not initial...
[ "def", "write", "(", "self", ",", "file_path", ")", ":", "if", "self", ".", "__samples", "is", "None", ":", "if", "self", ".", "file_path", "is", "None", ":", "self", ".", "log_exc", "(", "u\"AudioFile object not initialized\"", ",", "None", ",", "True", ...
Write the audio data to file. Return ``True`` on success, or ``False`` otherwise. :param string file_path: the path of the output file to be written :raises: :class:`~aeneas.audiofile.AudioFileNotInitializedError`: if the audio file is not initialized yet .. versionadded:: 1.2.0
[ "Write", "the", "audio", "data", "to", "file", ".", "Return", "True", "on", "success", "or", "False", "otherwise", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofile.py#L607-L630
train
readbeyond/aeneas
aeneas/audiofile.py
AudioFile.clear_data
def clear_data(self): """ Clear the audio data, freeing memory. """ self.log(u"Clear audio_data") self.__samples_capacity = 0 self.__samples_length = 0 self.__samples = None
python
def clear_data(self): """ Clear the audio data, freeing memory. """ self.log(u"Clear audio_data") self.__samples_capacity = 0 self.__samples_length = 0 self.__samples = None
[ "def", "clear_data", "(", "self", ")", ":", "self", ".", "log", "(", "u\"Clear audio_data\"", ")", "self", ".", "__samples_capacity", "=", "0", "self", ".", "__samples_length", "=", "0", "self", ".", "__samples", "=", "None" ]
Clear the audio data, freeing memory.
[ "Clear", "the", "audio", "data", "freeing", "memory", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofile.py#L632-L639
train
readbeyond/aeneas
aeneas/audiofile.py
AudioFile._update_length
def _update_length(self): """ Update the audio length property, according to the length of the current audio data and audio sample rate. This function fails silently if one of the two is ``None``. """ if (self.audio_sample_rate is not None) and (self.__samples is...
python
def _update_length(self): """ Update the audio length property, according to the length of the current audio data and audio sample rate. This function fails silently if one of the two is ``None``. """ if (self.audio_sample_rate is not None) and (self.__samples is...
[ "def", "_update_length", "(", "self", ")", ":", "if", "(", "self", ".", "audio_sample_rate", "is", "not", "None", ")", "and", "(", "self", ".", "__samples", "is", "not", "None", ")", ":", "self", ".", "audio_length", "=", "TimeValue", "(", "self", ".",...
Update the audio length property, according to the length of the current audio data and audio sample rate. This function fails silently if one of the two is ``None``.
[ "Update", "the", "audio", "length", "property", "according", "to", "the", "length", "of", "the", "current", "audio", "data", "and", "audio", "sample", "rate", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofile.py#L641-L653
train
readbeyond/aeneas
aeneas/audiofilemfcc.py
AudioFileMFCC.masked_middle_mfcc
def masked_middle_mfcc(self): """ Return the MFCC speech frames in the MIDDLE portion of the wave. :rtype: :class:`numpy.ndarray` (2D) """ begin, end = self._masked_middle_begin_end() return (self.masked_mfcc)[:, begin:end]
python
def masked_middle_mfcc(self): """ Return the MFCC speech frames in the MIDDLE portion of the wave. :rtype: :class:`numpy.ndarray` (2D) """ begin, end = self._masked_middle_begin_end() return (self.masked_mfcc)[:, begin:end]
[ "def", "masked_middle_mfcc", "(", "self", ")", ":", "begin", ",", "end", "=", "self", ".", "_masked_middle_begin_end", "(", ")", "return", "(", "self", ".", "masked_mfcc", ")", "[", ":", ",", "begin", ":", "end", "]" ]
Return the MFCC speech frames in the MIDDLE portion of the wave. :rtype: :class:`numpy.ndarray` (2D)
[ "Return", "the", "MFCC", "speech", "frames", "in", "the", "MIDDLE", "portion", "of", "the", "wave", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofilemfcc.py#L327-L335
train
readbeyond/aeneas
aeneas/audiofilemfcc.py
AudioFileMFCC.masked_middle_map
def masked_middle_map(self): """ Return the map from the MFCC speech frame indices in the MIDDLE portion of the wave to the MFCC FULL frame indices. :rtype: :class:`numpy.ndarray` (1D) """ begin, end = self._masked_middle_begin_end() return self._...
python
def masked_middle_map(self): """ Return the map from the MFCC speech frame indices in the MIDDLE portion of the wave to the MFCC FULL frame indices. :rtype: :class:`numpy.ndarray` (1D) """ begin, end = self._masked_middle_begin_end() return self._...
[ "def", "masked_middle_map", "(", "self", ")", ":", "begin", ",", "end", "=", "self", ".", "_masked_middle_begin_end", "(", ")", "return", "self", ".", "__mfcc_mask_map", "[", "begin", ":", "end", "]" ]
Return the map from the MFCC speech frame indices in the MIDDLE portion of the wave to the MFCC FULL frame indices. :rtype: :class:`numpy.ndarray` (1D)
[ "Return", "the", "map", "from", "the", "MFCC", "speech", "frame", "indices", "in", "the", "MIDDLE", "portion", "of", "the", "wave", "to", "the", "MFCC", "FULL", "frame", "indices", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofilemfcc.py#L349-L359
train
readbeyond/aeneas
aeneas/audiofilemfcc.py
AudioFileMFCC._binary_search_intervals
def _binary_search_intervals(cls, intervals, index): """ Binary search for the interval containing index, assuming there is such an interval. This function should never return ``None``. """ start = 0 end = len(intervals) - 1 while start <= end: ...
python
def _binary_search_intervals(cls, intervals, index): """ Binary search for the interval containing index, assuming there is such an interval. This function should never return ``None``. """ start = 0 end = len(intervals) - 1 while start <= end: ...
[ "def", "_binary_search_intervals", "(", "cls", ",", "intervals", ",", "index", ")", ":", "start", "=", "0", "end", "=", "len", "(", "intervals", ")", "-", "1", "while", "start", "<=", "end", ":", "middle_index", "=", "start", "+", "(", "(", "end", "-...
Binary search for the interval containing index, assuming there is such an interval. This function should never return ``None``.
[ "Binary", "search", "for", "the", "interval", "containing", "index", "assuming", "there", "is", "such", "an", "interval", ".", "This", "function", "should", "never", "return", "None", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofilemfcc.py#L423-L440
train
readbeyond/aeneas
aeneas/audiofilemfcc.py
AudioFileMFCC.middle_begin
def middle_begin(self, index): """ Set the index where MIDDLE starts. :param int index: the new index for MIDDLE begin """ if (index < 0) or (index > self.all_length): raise ValueError(u"The given index is not valid") self.__middle_begin = index
python
def middle_begin(self, index): """ Set the index where MIDDLE starts. :param int index: the new index for MIDDLE begin """ if (index < 0) or (index > self.all_length): raise ValueError(u"The given index is not valid") self.__middle_begin = index
[ "def", "middle_begin", "(", "self", ",", "index", ")", ":", "if", "(", "index", "<", "0", ")", "or", "(", "index", ">", "self", ".", "all_length", ")", ":", "raise", "ValueError", "(", "u\"The given index is not valid\"", ")", "self", ".", "__middle_begin"...
Set the index where MIDDLE starts. :param int index: the new index for MIDDLE begin
[ "Set", "the", "index", "where", "MIDDLE", "starts", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofilemfcc.py#L452-L460
train
readbeyond/aeneas
aeneas/audiofilemfcc.py
AudioFileMFCC._compute_mfcc_c_extension
def _compute_mfcc_c_extension(self): """ Compute MFCCs using the Python C extension cmfcc. """ self.log(u"Computing MFCCs using C extension...") try: self.log(u"Importing cmfcc...") import aeneas.cmfcc.cmfcc self.log(u"Importing cmfcc... done")...
python
def _compute_mfcc_c_extension(self): """ Compute MFCCs using the Python C extension cmfcc. """ self.log(u"Computing MFCCs using C extension...") try: self.log(u"Importing cmfcc...") import aeneas.cmfcc.cmfcc self.log(u"Importing cmfcc... done")...
[ "def", "_compute_mfcc_c_extension", "(", "self", ")", ":", "self", ".", "log", "(", "u\"Computing MFCCs using C extension...\"", ")", "try", ":", "self", ".", "log", "(", "u\"Importing cmfcc...\"", ")", "import", "aeneas", ".", "cmfcc", ".", "cmfcc", "self", "."...
Compute MFCCs using the Python C extension cmfcc.
[ "Compute", "MFCCs", "using", "the", "Python", "C", "extension", "cmfcc", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofilemfcc.py#L509-L534
train
readbeyond/aeneas
aeneas/audiofilemfcc.py
AudioFileMFCC._compute_mfcc_pure_python
def _compute_mfcc_pure_python(self): """ Compute MFCCs using the pure Python code. """ self.log(u"Computing MFCCs using pure Python code...") try: self.__mfcc = MFCC( rconf=self.rconf, logger=self.logger ).compute_from_data(...
python
def _compute_mfcc_pure_python(self): """ Compute MFCCs using the pure Python code. """ self.log(u"Computing MFCCs using pure Python code...") try: self.__mfcc = MFCC( rconf=self.rconf, logger=self.logger ).compute_from_data(...
[ "def", "_compute_mfcc_pure_python", "(", "self", ")", ":", "self", ".", "log", "(", "u\"Computing MFCCs using pure Python code...\"", ")", "try", ":", "self", ".", "__mfcc", "=", "MFCC", "(", "rconf", "=", "self", ".", "rconf", ",", "logger", "=", "self", "....
Compute MFCCs using the pure Python code.
[ "Compute", "MFCCs", "using", "the", "pure", "Python", "code", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofilemfcc.py#L536-L553
train
readbeyond/aeneas
aeneas/audiofilemfcc.py
AudioFileMFCC.reverse
def reverse(self): """ Reverse the audio file. The reversing is done efficiently using NumPy views inplace instead of swapping values. Only speech and nonspeech intervals are actually recomputed as Python lists. """ self.log(u"Reversing...") all_...
python
def reverse(self): """ Reverse the audio file. The reversing is done efficiently using NumPy views inplace instead of swapping values. Only speech and nonspeech intervals are actually recomputed as Python lists. """ self.log(u"Reversing...") all_...
[ "def", "reverse", "(", "self", ")", ":", "self", ".", "log", "(", "u\"Reversing...\"", ")", "all_length", "=", "self", ".", "all_length", "self", ".", "__mfcc", "=", "self", ".", "__mfcc", "[", ":", ",", ":", ":", "-", "1", "]", "tmp", "=", "self",...
Reverse the audio file. The reversing is done efficiently using NumPy views inplace instead of swapping values. Only speech and nonspeech intervals are actually recomputed as Python lists.
[ "Reverse", "the", "audio", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofilemfcc.py#L555-L582
train
readbeyond/aeneas
aeneas/audiofilemfcc.py
AudioFileMFCC.run_vad
def run_vad( self, log_energy_threshold=None, min_nonspeech_length=None, extend_before=None, extend_after=None ): """ Determine which frames contain speech and nonspeech, and store the resulting boolean mask internally. The four parameters mig...
python
def run_vad( self, log_energy_threshold=None, min_nonspeech_length=None, extend_before=None, extend_after=None ): """ Determine which frames contain speech and nonspeech, and store the resulting boolean mask internally. The four parameters mig...
[ "def", "run_vad", "(", "self", ",", "log_energy_threshold", "=", "None", ",", "min_nonspeech_length", "=", "None", ",", "extend_before", "=", "None", ",", "extend_after", "=", "None", ")", ":", "def", "_compute_runs", "(", "array", ")", ":", "if", "len", "...
Determine which frames contain speech and nonspeech, and store the resulting boolean mask internally. The four parameters might be ``None``: in this case, the corresponding RuntimeConfiguration values are applied. :param float log_energy_threshold: the minimum log energy thresh...
[ "Determine", "which", "frames", "contain", "speech", "and", "nonspeech", "and", "store", "the", "resulting", "boolean", "mask", "internally", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofilemfcc.py#L584-L636
train
readbeyond/aeneas
aeneas/audiofilemfcc.py
AudioFileMFCC.set_head_middle_tail
def set_head_middle_tail(self, head_length=None, middle_length=None, tail_length=None): """ Set the HEAD, MIDDLE, TAIL explicitly. If a parameter is ``None``, it will be ignored. If both ``middle_length`` and ``tail_length`` are specified, only ``middle_length`` will be applied....
python
def set_head_middle_tail(self, head_length=None, middle_length=None, tail_length=None): """ Set the HEAD, MIDDLE, TAIL explicitly. If a parameter is ``None``, it will be ignored. If both ``middle_length`` and ``tail_length`` are specified, only ``middle_length`` will be applied....
[ "def", "set_head_middle_tail", "(", "self", ",", "head_length", "=", "None", ",", "middle_length", "=", "None", ",", "tail_length", "=", "None", ")", ":", "for", "variable", ",", "name", "in", "[", "(", "head_length", ",", "\"head_length\"", ")", ",", "(",...
Set the HEAD, MIDDLE, TAIL explicitly. If a parameter is ``None``, it will be ignored. If both ``middle_length`` and ``tail_length`` are specified, only ``middle_length`` will be applied. :param head_length: the length of HEAD, in seconds :type head_length: :class:`~aeneas.exa...
[ "Set", "the", "HEAD", "MIDDLE", "TAIL", "explicitly", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofilemfcc.py#L638-L676
train
readbeyond/aeneas
aeneas/textfile.py
TextFragment.chars
def chars(self): """ Return the number of characters of the text fragment, not including the line separators. :rtype: int """ if self.lines is None: return 0 return sum([len(line) for line in self.lines])
python
def chars(self): """ Return the number of characters of the text fragment, not including the line separators. :rtype: int """ if self.lines is None: return 0 return sum([len(line) for line in self.lines])
[ "def", "chars", "(", "self", ")", ":", "if", "self", ".", "lines", "is", "None", ":", "return", "0", "return", "sum", "(", "[", "len", "(", "line", ")", "for", "line", "in", "self", ".", "lines", "]", ")" ]
Return the number of characters of the text fragment, not including the line separators. :rtype: int
[ "Return", "the", "number", "of", "characters", "of", "the", "text", "fragment", "not", "including", "the", "line", "separators", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L355-L364
train
readbeyond/aeneas
aeneas/textfile.py
TextFile.children_not_empty
def children_not_empty(self): """ Return the direct not empty children of the root of the fragments tree, as ``TextFile`` objects. :rtype: list of :class:`~aeneas.textfile.TextFile` """ children = [] for child_node in self.fragments_tree.children_not_empty: ...
python
def children_not_empty(self): """ Return the direct not empty children of the root of the fragments tree, as ``TextFile`` objects. :rtype: list of :class:`~aeneas.textfile.TextFile` """ children = [] for child_node in self.fragments_tree.children_not_empty: ...
[ "def", "children_not_empty", "(", "self", ")", ":", "children", "=", "[", "]", "for", "child_node", "in", "self", ".", "fragments_tree", ".", "children_not_empty", ":", "child_text_file", "=", "self", ".", "get_subtree", "(", "child_node", ")", "child_text_file"...
Return the direct not empty children of the root of the fragments tree, as ``TextFile`` objects. :rtype: list of :class:`~aeneas.textfile.TextFile`
[ "Return", "the", "direct", "not", "empty", "children", "of", "the", "root", "of", "the", "fragments", "tree", "as", "TextFile", "objects", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L455-L467
train
readbeyond/aeneas
aeneas/textfile.py
TextFile.characters
def characters(self): """ The number of characters in this text file. :rtype: int """ chars = 0 for fragment in self.fragments: chars += fragment.characters return chars
python
def characters(self): """ The number of characters in this text file. :rtype: int """ chars = 0 for fragment in self.fragments: chars += fragment.characters return chars
[ "def", "characters", "(", "self", ")", ":", "chars", "=", "0", "for", "fragment", "in", "self", ".", "fragments", ":", "chars", "+=", "fragment", ".", "characters", "return", "chars" ]
The number of characters in this text file. :rtype: int
[ "The", "number", "of", "characters", "in", "this", "text", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L525-L534
train
readbeyond/aeneas
aeneas/textfile.py
TextFile.add_fragment
def add_fragment(self, fragment, as_last=True): """ Add the given text fragment as the first or last child of the root node of the text file tree. :param fragment: the text fragment to be added :type fragment: :class:`~aeneas.textfile.TextFragment` :param bool as_last: ...
python
def add_fragment(self, fragment, as_last=True): """ Add the given text fragment as the first or last child of the root node of the text file tree. :param fragment: the text fragment to be added :type fragment: :class:`~aeneas.textfile.TextFragment` :param bool as_last: ...
[ "def", "add_fragment", "(", "self", ",", "fragment", ",", "as_last", "=", "True", ")", ":", "if", "not", "isinstance", "(", "fragment", ",", "TextFragment", ")", ":", "self", ".", "log_exc", "(", "u\"fragment is not an instance of TextFragment\"", ",", "None", ...
Add the given text fragment as the first or last child of the root node of the text file tree. :param fragment: the text fragment to be added :type fragment: :class:`~aeneas.textfile.TextFragment` :param bool as_last: if ``True`` append fragment, otherwise prepend it
[ "Add", "the", "given", "text", "fragment", "as", "the", "first", "or", "last", "child", "of", "the", "root", "node", "of", "the", "text", "file", "tree", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L547-L558
train
readbeyond/aeneas
aeneas/textfile.py
TextFile.set_language
def set_language(self, language): """ Set the given language for all the text fragments. :param language: the language of the text fragments :type language: :class:`~aeneas.language.Language` """ self.log([u"Setting language: '%s'", language]) for fragment in se...
python
def set_language(self, language): """ Set the given language for all the text fragments. :param language: the language of the text fragments :type language: :class:`~aeneas.language.Language` """ self.log([u"Setting language: '%s'", language]) for fragment in se...
[ "def", "set_language", "(", "self", ",", "language", ")", ":", "self", ".", "log", "(", "[", "u\"Setting language: '%s'\"", ",", "language", "]", ")", "for", "fragment", "in", "self", ".", "fragments", ":", "fragment", ".", "language", "=", "language" ]
Set the given language for all the text fragments. :param language: the language of the text fragments :type language: :class:`~aeneas.language.Language`
[ "Set", "the", "given", "language", "for", "all", "the", "text", "fragments", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L598-L607
train
readbeyond/aeneas
aeneas/textfile.py
TextFile._read_from_file
def _read_from_file(self): """ Read text fragments from file. """ # test if we can read the given file 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) if self.file_format not in Tex...
python
def _read_from_file(self): """ Read text fragments from file. """ # test if we can read the given file 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) if self.file_format not in Tex...
[ "def", "_read_from_file", "(", "self", ")", ":", "if", "not", "gf", ".", "file_can_be_read", "(", "self", ".", "file_path", ")", ":", "self", ".", "log_exc", "(", "u\"File '%s' cannot be read\"", "%", "(", "self", ".", "file_path", ")", ",", "None", ",", ...
Read text fragments from file.
[ "Read", "text", "fragments", "from", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L638-L669
train
readbeyond/aeneas
aeneas/textfile.py
TextFile._mplain_word_separator
def _mplain_word_separator(self): """ Get the word separator to split words in mplain format. :rtype: string """ word_separator = gf.safe_get(self.parameters, gc.PPN_TASK_IS_TEXT_MPLAIN_WORD_SEPARATOR, u" ") if (word_separator is None) or (word_separator == "space"): ...
python
def _mplain_word_separator(self): """ Get the word separator to split words in mplain format. :rtype: string """ word_separator = gf.safe_get(self.parameters, gc.PPN_TASK_IS_TEXT_MPLAIN_WORD_SEPARATOR, u" ") if (word_separator is None) or (word_separator == "space"): ...
[ "def", "_mplain_word_separator", "(", "self", ")", ":", "word_separator", "=", "gf", ".", "safe_get", "(", "self", ".", "parameters", ",", "gc", ".", "PPN_TASK_IS_TEXT_MPLAIN_WORD_SEPARATOR", ",", "u\" \"", ")", "if", "(", "word_separator", "is", "None", ")", ...
Get the word separator to split words in mplain format. :rtype: string
[ "Get", "the", "word", "separator", "to", "split", "words", "in", "mplain", "format", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L671-L686
train
readbeyond/aeneas
aeneas/textfile.py
TextFile._read_mplain
def _read_mplain(self, lines): """ Read text fragments from a multilevel format text file. :param list lines: the lines of the subtitles text file """ self.log(u"Parsing fragments from subtitles text format") word_separator = self._mplain_word_separator() self.lo...
python
def _read_mplain(self, lines): """ Read text fragments from a multilevel format text file. :param list lines: the lines of the subtitles text file """ self.log(u"Parsing fragments from subtitles text format") word_separator = self._mplain_word_separator() self.lo...
[ "def", "_read_mplain", "(", "self", ",", "lines", ")", ":", "self", ".", "log", "(", "u\"Parsing fragments from subtitles text format\"", ")", "word_separator", "=", "self", ".", "_mplain_word_separator", "(", ")", "self", ".", "log", "(", "[", "u\"Word separator ...
Read text fragments from a multilevel format text file. :param list lines: the lines of the subtitles text file
[ "Read", "text", "fragments", "from", "a", "multilevel", "format", "text", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L688-L760
train
readbeyond/aeneas
aeneas/textfile.py
TextFile._read_subtitles
def _read_subtitles(self, lines): """ Read text fragments from a subtitles format text file. :param list lines: the lines of the subtitles text file :raises: ValueError: if the id regex is not valid """ self.log(u"Parsing fragments from subtitles text format") id...
python
def _read_subtitles(self, lines): """ Read text fragments from a subtitles format text file. :param list lines: the lines of the subtitles text file :raises: ValueError: if the id regex is not valid """ self.log(u"Parsing fragments from subtitles text format") id...
[ "def", "_read_subtitles", "(", "self", ",", "lines", ")", ":", "self", ".", "log", "(", "u\"Parsing fragments from subtitles text format\"", ")", "id_format", "=", "self", ".", "_get_id_format", "(", ")", "lines", "=", "[", "line", ".", "strip", "(", ")", "f...
Read text fragments from a subtitles format text file. :param list lines: the lines of the subtitles text file :raises: ValueError: if the id regex is not valid
[ "Read", "text", "fragments", "from", "a", "subtitles", "format", "text", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L851-L877
train
readbeyond/aeneas
aeneas/textfile.py
TextFile._read_parsed
def _read_parsed(self, lines): """ Read text fragments from a parsed format text file. :param list lines: the lines of the parsed text file :param dict parameters: additional parameters for parsing (e.g., class/id regex strings) """ self.l...
python
def _read_parsed(self, lines): """ Read text fragments from a parsed format text file. :param list lines: the lines of the parsed text file :param dict parameters: additional parameters for parsing (e.g., class/id regex strings) """ self.l...
[ "def", "_read_parsed", "(", "self", ",", "lines", ")", ":", "self", ".", "log", "(", "u\"Parsing fragments from parsed text format\"", ")", "pairs", "=", "[", "]", "for", "line", "in", "lines", ":", "pieces", "=", "line", ".", "split", "(", "gc", ".", "P...
Read text fragments from a parsed format text file. :param list lines: the lines of the parsed text file :param dict parameters: additional parameters for parsing (e.g., class/id regex strings)
[ "Read", "text", "fragments", "from", "a", "parsed", "format", "text", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L879-L896
train
readbeyond/aeneas
aeneas/textfile.py
TextFile._read_plain
def _read_plain(self, lines): """ Read text fragments from a plain format text file. :param list lines: the lines of the plain text file :param dict parameters: additional parameters for parsing (e.g., class/id regex strings) :raises: ValueError: ...
python
def _read_plain(self, lines): """ Read text fragments from a plain format text file. :param list lines: the lines of the plain text file :param dict parameters: additional parameters for parsing (e.g., class/id regex strings) :raises: ValueError: ...
[ "def", "_read_plain", "(", "self", ",", "lines", ")", ":", "self", ".", "log", "(", "u\"Parsing fragments from plain text format\"", ")", "id_format", "=", "self", ".", "_get_id_format", "(", ")", "lines", "=", "[", "line", ".", "strip", "(", ")", "for", "...
Read text fragments from a plain format text file. :param list lines: the lines of the plain text file :param dict parameters: additional parameters for parsing (e.g., class/id regex strings) :raises: ValueError: if the id regex is not valid
[ "Read", "text", "fragments", "from", "a", "plain", "format", "text", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L898-L917
train
readbeyond/aeneas
aeneas/textfile.py
TextFile._read_unparsed
def _read_unparsed(self, lines): """ Read text fragments from an unparsed format text file. :param list lines: the lines of the unparsed text file """ from bs4 import BeautifulSoup def filter_attributes(): """ Return a dict with the bs4 filter parameters """...
python
def _read_unparsed(self, lines): """ Read text fragments from an unparsed format text file. :param list lines: the lines of the unparsed text file """ from bs4 import BeautifulSoup def filter_attributes(): """ Return a dict with the bs4 filter parameters """...
[ "def", "_read_unparsed", "(", "self", ",", "lines", ")", ":", "from", "bs4", "import", "BeautifulSoup", "def", "filter_attributes", "(", ")", ":", "attributes", "=", "{", "}", "for", "attribute_name", ",", "filter_name", "in", "[", "(", "\"class\"", ",", "...
Read text fragments from an unparsed format text file. :param list lines: the lines of the unparsed text file
[ "Read", "text", "fragments", "from", "an", "unparsed", "format", "text", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L919-L978
train
readbeyond/aeneas
aeneas/textfile.py
TextFile._get_id_format
def _get_id_format(self): """ Return the id regex from the parameters""" id_format = gf.safe_get( self.parameters, gc.PPN_TASK_OS_FILE_ID_REGEX, self.DEFAULT_ID_FORMAT, can_return_none=False ) try: identifier = id_format % 1 ...
python
def _get_id_format(self): """ Return the id regex from the parameters""" id_format = gf.safe_get( self.parameters, gc.PPN_TASK_OS_FILE_ID_REGEX, self.DEFAULT_ID_FORMAT, can_return_none=False ) try: identifier = id_format % 1 ...
[ "def", "_get_id_format", "(", "self", ")", ":", "id_format", "=", "gf", ".", "safe_get", "(", "self", ".", "parameters", ",", "gc", ".", "PPN_TASK_OS_FILE_ID_REGEX", ",", "self", ".", "DEFAULT_ID_FORMAT", ",", "can_return_none", "=", "False", ")", "try", ":"...
Return the id regex from the parameters
[ "Return", "the", "id", "regex", "from", "the", "parameters" ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L980-L992
train
readbeyond/aeneas
aeneas/textfile.py
TextFile._create_text_fragments
def _create_text_fragments(self, pairs): """ Create text fragment objects and append them to this list. :param list pairs: a list of pairs, each pair being (id, [line_1, ..., line_n]) """ self.log(u"Creating TextFragment objects") text_filter = self._build_text_filter() ...
python
def _create_text_fragments(self, pairs): """ Create text fragment objects and append them to this list. :param list pairs: a list of pairs, each pair being (id, [line_1, ..., line_n]) """ self.log(u"Creating TextFragment objects") text_filter = self._build_text_filter() ...
[ "def", "_create_text_fragments", "(", "self", ",", "pairs", ")", ":", "self", ".", "log", "(", "u\"Creating TextFragment objects\"", ")", "text_filter", "=", "self", ".", "_build_text_filter", "(", ")", "for", "pair", "in", "pairs", ":", "self", ".", "add_frag...
Create text fragment objects and append them to this list. :param list pairs: a list of pairs, each pair being (id, [line_1, ..., line_n])
[ "Create", "text", "fragment", "objects", "and", "append", "them", "to", "this", "list", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L994-L1009
train
readbeyond/aeneas
aeneas/textfile.py
TextFile._build_text_filter
def _build_text_filter(self): """ Build a suitable TextFilter object. """ text_filter = TextFilter(logger=self.logger) self.log(u"Created TextFilter object") for key, cls, param_name in [ ( gc.PPN_TASK_IS_TEXT_FILE_IGNORE_REGEX, ...
python
def _build_text_filter(self): """ Build a suitable TextFilter object. """ text_filter = TextFilter(logger=self.logger) self.log(u"Created TextFilter object") for key, cls, param_name in [ ( gc.PPN_TASK_IS_TEXT_FILE_IGNORE_REGEX, ...
[ "def", "_build_text_filter", "(", "self", ")", ":", "text_filter", "=", "TextFilter", "(", "logger", "=", "self", ".", "logger", ")", "self", ".", "log", "(", "u\"Created TextFilter object\"", ")", "for", "key", ",", "cls", ",", "param_name", "in", "[", "(...
Build a suitable TextFilter object.
[ "Build", "a", "suitable", "TextFilter", "object", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L1011-L1043
train
readbeyond/aeneas
aeneas/textfile.py
TextFilter.add_filter
def add_filter(self, new_filter, as_last=True): """ Compose this filter with the given ``new_filter`` filter. :param new_filter: the filter to be composed :type new_filter: :class:`~aeneas.textfile.TextFilter` :param bool as_last: if ``True``, compose to the right, otherwise to...
python
def add_filter(self, new_filter, as_last=True): """ Compose this filter with the given ``new_filter`` filter. :param new_filter: the filter to be composed :type new_filter: :class:`~aeneas.textfile.TextFilter` :param bool as_last: if ``True``, compose to the right, otherwise to...
[ "def", "add_filter", "(", "self", ",", "new_filter", ",", "as_last", "=", "True", ")", ":", "if", "as_last", ":", "self", ".", "filters", ".", "append", "(", "new_filter", ")", "else", ":", "self", ".", "filters", "=", "[", "new_filter", "]", "+", "s...
Compose this filter with the given ``new_filter`` filter. :param new_filter: the filter to be composed :type new_filter: :class:`~aeneas.textfile.TextFilter` :param bool as_last: if ``True``, compose to the right, otherwise to the left
[ "Compose", "this", "filter", "with", "the", "given", "new_filter", "filter", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L1071-L1082
train
readbeyond/aeneas
aeneas/textfile.py
TextFilter.apply_filter
def apply_filter(self, strings): """ Apply the text filter filter to the given list of strings. :param list strings: the list of input strings """ result = strings for filt in self.filters: result = filt.apply_filter(result) self.log([u"Applying regex...
python
def apply_filter(self, strings): """ Apply the text filter filter to the given list of strings. :param list strings: the list of input strings """ result = strings for filt in self.filters: result = filt.apply_filter(result) self.log([u"Applying regex...
[ "def", "apply_filter", "(", "self", ",", "strings", ")", ":", "result", "=", "strings", "for", "filt", "in", "self", ".", "filters", ":", "result", "=", "filt", ".", "apply_filter", "(", "result", ")", "self", ".", "log", "(", "[", "u\"Applying regex: '%...
Apply the text filter filter to the given list of strings. :param list strings: the list of input strings
[ "Apply", "the", "text", "filter", "filter", "to", "the", "given", "list", "of", "strings", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/textfile.py#L1084-L1094
train