id
int32
0
252k
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
51
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
245,900
readbeyond/aeneas
aeneas/plotter.py
PlotTimeScale.draw_png
def draw_png(self, image, h_zoom, v_zoom, current_y): """ Draw this time scale to PNG. :param image: the image to draw onto :param int h_zoom: the horizontal zoom :param int v_zoom: the vertical zoom :param int current_y: the current y offset, in modules :type i...
python
def draw_png(self, image, h_zoom, v_zoom, current_y): # PIL object draw = ImageDraw.Draw(image) mws = self.rconf.mws pixels_per_second = int(h_zoom / mws) current_y_px = current_y * v_zoom # create font, as tall as possible font_height_pt = 18 font = Imag...
[ "def", "draw_png", "(", "self", ",", "image", ",", "h_zoom", ",", "v_zoom", ",", "current_y", ")", ":", "# PIL object", "draw", "=", "ImageDraw", ".", "Draw", "(", "image", ")", "mws", "=", "self", ".", "rconf", ".", "mws", "pixels_per_second", "=", "i...
Draw this time scale to PNG. :param image: the image to draw onto :param int h_zoom: the horizontal zoom :param int v_zoom: the vertical zoom :param int current_y: the current y offset, in modules :type image: :class:`PIL.Image`
[ "Draw", "this", "time", "scale", "to", "PNG", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/plotter.py#L305-L341
245,901
readbeyond/aeneas
aeneas/plotter.py
PlotWaveform.draw_png
def draw_png(self, image, h_zoom, v_zoom, current_y): """ Draw this waveform to PNG. :param image: the image to draw onto :param int h_zoom: the horizontal zoom :param int v_zoom: the vertical zoom :param int current_y: the current y offset, in modules :type ima...
python
def draw_png(self, image, h_zoom, v_zoom, current_y): draw = ImageDraw.Draw(image) mws = self.rconf.mws rate = self.audio_file.audio_sample_rate samples = self.audio_file.audio_samples duration = self.audio_file.audio_length current_y_px = current_y * v_zoom half...
[ "def", "draw_png", "(", "self", ",", "image", ",", "h_zoom", ",", "v_zoom", ",", "current_y", ")", ":", "draw", "=", "ImageDraw", ".", "Draw", "(", "image", ")", "mws", "=", "self", ".", "rconf", ".", "mws", "rate", "=", "self", ".", "audio_file", ...
Draw this waveform to PNG. :param image: the image to draw onto :param int h_zoom: the horizontal zoom :param int v_zoom: the vertical zoom :param int current_y: the current y offset, in modules :type image: :class:`PIL.Image`
[ "Draw", "this", "waveform", "to", "PNG", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/plotter.py#L524-L567
245,902
readbeyond/aeneas
aeneas/tools/run_sd.py
RunSDCLI.print_result
def print_result(self, audio_len, start, end): """ Print result of SD. :param audio_len: the length of the entire audio file, in seconds :type audio_len: float :param start: the start position of the spoken text :type start: float :param end: the end position o...
python
def print_result(self, audio_len, start, end): msg = [] zero = 0 head_len = start text_len = end - start tail_len = audio_len - end msg.append(u"") msg.append(u"Head: %.3f %.3f (%.3f)" % (zero, start, head_len)) msg.append(u"Text: %.3f %.3f (%.3f)" % (star...
[ "def", "print_result", "(", "self", ",", "audio_len", ",", "start", ",", "end", ")", ":", "msg", "=", "[", "]", "zero", "=", "0", "head_len", "=", "start", "text_len", "=", "end", "-", "start", "tail_len", "=", "audio_len", "-", "end", "msg", ".", ...
Print result of SD. :param audio_len: the length of the entire audio file, in seconds :type audio_len: float :param start: the start position of the spoken text :type start: float :param end: the end position of the spoken text :type end: float
[ "Print", "result", "of", "SD", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/run_sd.py#L171-L203
245,903
readbeyond/aeneas
aeneas/task.py
Task.sync_map_leaves
def sync_map_leaves(self, fragment_type=None): """ Return the list of non-empty leaves in the sync map associated with the task. If ``fragment_type`` has been specified, return only leaves of that fragment type. :param int fragment_type: type of fragment to return ...
python
def sync_map_leaves(self, fragment_type=None): if (self.sync_map is None) or (self.sync_map.fragments_tree is None): return [] return [f for f in self.sync_map.leaves(fragment_type)]
[ "def", "sync_map_leaves", "(", "self", ",", "fragment_type", "=", "None", ")", ":", "if", "(", "self", ".", "sync_map", "is", "None", ")", "or", "(", "self", ".", "sync_map", ".", "fragments_tree", "is", "None", ")", ":", "return", "[", "]", "return", ...
Return the list of non-empty leaves in the sync map associated with the task. If ``fragment_type`` has been specified, return only leaves of that fragment type. :param int fragment_type: type of fragment to return :rtype: list .. versionadded:: 1.7.0
[ "Return", "the", "list", "of", "non", "-", "empty", "leaves", "in", "the", "sync", "map", "associated", "with", "the", "task", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/task.py#L149-L164
245,904
readbeyond/aeneas
aeneas/task.py
Task.output_sync_map_file
def output_sync_map_file(self, container_root_path=None): """ Output the sync map file for this task. If ``container_root_path`` is specified, the output sync map file will be created at the path obtained by joining the ``container_root_path`` and the relative path ...
python
def output_sync_map_file(self, container_root_path=None): if self.sync_map is None: self.log_exc(u"The sync_map object has not been set", None, True, TypeError) if (container_root_path is not None) and (self.sync_map_file_path is None): self.log_exc(u"The (internal) path of the ...
[ "def", "output_sync_map_file", "(", "self", ",", "container_root_path", "=", "None", ")", ":", "if", "self", ".", "sync_map", "is", "None", ":", "self", ".", "log_exc", "(", "u\"The sync_map object has not been set\"", ",", "None", ",", "True", ",", "TypeError",...
Output the sync map file for this task. If ``container_root_path`` is specified, the output sync map file will be created at the path obtained by joining the ``container_root_path`` and the relative path of the sync map inside the container. Otherwise, the sync map file...
[ "Output", "the", "sync", "map", "file", "for", "this", "task", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/task.py#L166-L227
245,905
readbeyond/aeneas
aeneas/task.py
Task._populate_audio_file
def _populate_audio_file(self): """ Create the ``self.audio_file`` object by reading the audio file at ``self.audio_file_path_absolute``. """ self.log(u"Populate audio file...") if self.audio_file_path_absolute is not None: self.log([u"audio_file_path_absolute...
python
def _populate_audio_file(self): self.log(u"Populate audio file...") if self.audio_file_path_absolute is not None: self.log([u"audio_file_path_absolute is '%s'", self.audio_file_path_absolute]) self.audio_file = AudioFile( file_path=self.audio_file_path_absolute, ...
[ "def", "_populate_audio_file", "(", "self", ")", ":", "self", ".", "log", "(", "u\"Populate audio file...\"", ")", "if", "self", ".", "audio_file_path_absolute", "is", "not", "None", ":", "self", ".", "log", "(", "[", "u\"audio_file_path_absolute is '%s'\"", ",", ...
Create the ``self.audio_file`` object by reading the audio file at ``self.audio_file_path_absolute``.
[ "Create", "the", "self", ".", "audio_file", "object", "by", "reading", "the", "audio", "file", "at", "self", ".", "audio_file_path_absolute", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/task.py#L229-L244
245,906
readbeyond/aeneas
aeneas/task.py
Task._populate_text_file
def _populate_text_file(self): """ Create the ``self.text_file`` object by reading the text file at ``self.text_file_path_absolute``. """ self.log(u"Populate text file...") if ( (self.text_file_path_absolute is not None) and (self.configura...
python
def _populate_text_file(self): self.log(u"Populate text file...") if ( (self.text_file_path_absolute is not None) and (self.configuration["language"] is not None) ): # the following values might be None parameters = { gc.PPN...
[ "def", "_populate_text_file", "(", "self", ")", ":", "self", ".", "log", "(", "u\"Populate text file...\"", ")", "if", "(", "(", "self", ".", "text_file_path_absolute", "is", "not", "None", ")", "and", "(", "self", ".", "configuration", "[", "\"language\"", ...
Create the ``self.text_file`` object by reading the text file at ``self.text_file_path_absolute``.
[ "Create", "the", "self", ".", "text_file", "object", "by", "reading", "the", "text", "file", "at", "self", ".", "text_file_path_absolute", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/task.py#L246-L278
245,907
readbeyond/aeneas
aeneas/syncmap/smfgxml.py
SyncMapFormatGenericXML._tree_to_string
def _tree_to_string(cls, root_element, xml_declaration=True, pretty_print=True): """ Return an ``lxml`` tree as a Unicode string. """ from lxml import etree return gf.safe_unicode(etree.tostring( root_element, encoding="UTF-8", method="xml", ...
python
def _tree_to_string(cls, root_element, xml_declaration=True, pretty_print=True): from lxml import etree return gf.safe_unicode(etree.tostring( root_element, encoding="UTF-8", method="xml", xml_declaration=xml_declaration, pretty_print=pretty_pr...
[ "def", "_tree_to_string", "(", "cls", ",", "root_element", ",", "xml_declaration", "=", "True", ",", "pretty_print", "=", "True", ")", ":", "from", "lxml", "import", "etree", "return", "gf", ".", "safe_unicode", "(", "etree", ".", "tostring", "(", "root_elem...
Return an ``lxml`` tree as a Unicode string.
[ "Return", "an", "lxml", "tree", "as", "a", "Unicode", "string", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/syncmap/smfgxml.py#L63-L74
245,908
readbeyond/aeneas
aeneas/tools/abstract_cli_program.py
AbstractCLIProgram.print_generic
def print_generic(self, msg, prefix=None): """ Print a message and log it. :param msg: the message :type msg: Unicode string :param prefix: the (optional) prefix :type prefix: Unicode string """ if prefix is None: self._log(msg, Logger.INFO)...
python
def print_generic(self, msg, prefix=None): if prefix is None: self._log(msg, Logger.INFO) else: self._log(msg, prefix) if self.use_sys: if (prefix is not None) and (prefix in self.PREFIX_TO_PRINT_FUNCTION): self.PREFIX_TO_PRINT_FUNCTION[prefix]...
[ "def", "print_generic", "(", "self", ",", "msg", ",", "prefix", "=", "None", ")", ":", "if", "prefix", "is", "None", ":", "self", ".", "_log", "(", "msg", ",", "Logger", ".", "INFO", ")", "else", ":", "self", ".", "_log", "(", "msg", ",", "prefix...
Print a message and log it. :param msg: the message :type msg: Unicode string :param prefix: the (optional) prefix :type prefix: Unicode string
[ "Print", "a", "message", "and", "log", "it", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L109-L126
245,909
readbeyond/aeneas
aeneas/tools/abstract_cli_program.py
AbstractCLIProgram.print_name_version
def print_name_version(self): """ Print program name and version and exit. :rtype: int """ if self.use_sys: self.print_generic(u"%s v%s" % (self.NAME, aeneas_version)) return self.exit(self.HELP_EXIT_CODE)
python
def print_name_version(self): if self.use_sys: self.print_generic(u"%s v%s" % (self.NAME, aeneas_version)) return self.exit(self.HELP_EXIT_CODE)
[ "def", "print_name_version", "(", "self", ")", ":", "if", "self", ".", "use_sys", ":", "self", ".", "print_generic", "(", "u\"%s v%s\"", "%", "(", "self", ".", "NAME", ",", "aeneas_version", ")", ")", "return", "self", ".", "exit", "(", "self", ".", "H...
Print program name and version and exit. :rtype: int
[ "Print", "program", "name", "and", "version", "and", "exit", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L260-L268
245,910
readbeyond/aeneas
aeneas/tools/abstract_cli_program.py
AbstractCLIProgram.print_rconf_parameters
def print_rconf_parameters(self): """ Print the list of runtime configuration parameters and exit. """ if self.use_sys: self.print_info(u"Available runtime configuration parameters:") self.print_generic(u"\n" + u"\n".join(self.RCONF_PARAMETERS) + u"\n") re...
python
def print_rconf_parameters(self): if self.use_sys: self.print_info(u"Available runtime configuration parameters:") self.print_generic(u"\n" + u"\n".join(self.RCONF_PARAMETERS) + u"\n") return self.exit(self.HELP_EXIT_CODE)
[ "def", "print_rconf_parameters", "(", "self", ")", ":", "if", "self", ".", "use_sys", ":", "self", ".", "print_info", "(", "u\"Available runtime configuration parameters:\"", ")", "self", ".", "print_generic", "(", "u\"\\n\"", "+", "u\"\\n\"", ".", "join", "(", ...
Print the list of runtime configuration parameters and exit.
[ "Print", "the", "list", "of", "runtime", "configuration", "parameters", "and", "exit", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L270-L277
245,911
readbeyond/aeneas
aeneas/tools/abstract_cli_program.py
AbstractCLIProgram.has_option
def has_option(self, target): """ Return ``True`` if the actual arguments include the specified ``target`` option or, if ``target`` is a list of options, at least one of them. :param target: the option or a list of options :type target: Unicode string or list of...
python
def has_option(self, target): if isinstance(target, list): target_set = set(target) else: target_set = set([target]) return len(target_set & set(self.actual_arguments)) > 0
[ "def", "has_option", "(", "self", ",", "target", ")", ":", "if", "isinstance", "(", "target", ",", "list", ")", ":", "target_set", "=", "set", "(", "target", ")", "else", ":", "target_set", "=", "set", "(", "[", "target", "]", ")", "return", "len", ...
Return ``True`` if the actual arguments include the specified ``target`` option or, if ``target`` is a list of options, at least one of them. :param target: the option or a list of options :type target: Unicode string or list of Unicode strings :rtype: bool
[ "Return", "True", "if", "the", "actual", "arguments", "include", "the", "specified", "target", "option", "or", "if", "target", "is", "a", "list", "of", "options", "at", "least", "one", "of", "them", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L387-L402
245,912
readbeyond/aeneas
aeneas/tools/abstract_cli_program.py
AbstractCLIProgram.check_c_extensions
def check_c_extensions(self, name=None): """ If C extensions cannot be run, emit a warning and return ``False``. Otherwise return ``True``. If ``name`` is not ``None``, check just the C extension with that name. :param name: the name of the Python C extension to test ...
python
def check_c_extensions(self, name=None): if not gf.can_run_c_extension(name=name): if name is None: self.print_warning(u"Unable to load Python C Extensions") else: self.print_warning(u"Unable to load Python C Extension %s" % (name)) self.print_...
[ "def", "check_c_extensions", "(", "self", ",", "name", "=", "None", ")", ":", "if", "not", "gf", ".", "can_run_c_extension", "(", "name", "=", "name", ")", ":", "if", "name", "is", "None", ":", "self", ".", "print_warning", "(", "u\"Unable to load Python C...
If C extensions cannot be run, emit a warning and return ``False``. Otherwise return ``True``. If ``name`` is not ``None``, check just the C extension with that name. :param name: the name of the Python C extension to test :type name: string :rtype: bool
[ "If", "C", "extensions", "cannot", "be", "run", "emit", "a", "warning", "and", "return", "False", ".", "Otherwise", "return", "True", ".", "If", "name", "is", "not", "None", "check", "just", "the", "C", "extension", "with", "that", "name", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L437-L456
245,913
readbeyond/aeneas
aeneas/tools/abstract_cli_program.py
AbstractCLIProgram.check_output_file
def check_output_file(self, path): """ If the given path cannot be written, emit an error and return ``False``. Otherwise return ``True``. :param path: the path of the output file :type path: string (path) :rtype: bool """ if not gf.file_can_be_written(p...
python
def check_output_file(self, path): if not gf.file_can_be_written(path): self.print_error(u"Unable to create file '%s'" % (path)) self.print_error(u"Make sure the file path is written/escaped correctly and that you have write permission on it") return False return True
[ "def", "check_output_file", "(", "self", ",", "path", ")", ":", "if", "not", "gf", ".", "file_can_be_written", "(", "path", ")", ":", "self", ".", "print_error", "(", "u\"Unable to create file '%s'\"", "%", "(", "path", ")", ")", "self", ".", "print_error", ...
If the given path cannot be written, emit an error and return ``False``. Otherwise return ``True``. :param path: the path of the output file :type path: string (path) :rtype: bool
[ "If", "the", "given", "path", "cannot", "be", "written", "emit", "an", "error", "and", "return", "False", ".", "Otherwise", "return", "True", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L488-L501
245,914
readbeyond/aeneas
aeneas/tools/abstract_cli_program.py
AbstractCLIProgram.check_output_directory
def check_output_directory(self, path): """ If the given directory cannot be written, emit an error and return ``False``. Otherwise return ``True``. :param path: the path of the output directory :type path: string (path) :rtype: bool """ if not os.path.i...
python
def check_output_directory(self, path): if not os.path.isdir(path): self.print_error(u"Directory '%s' does not exist" % (path)) return False test_file = os.path.join(path, u"file.test") if not gf.file_can_be_written(test_file): self.print_error(u"Unable to wri...
[ "def", "check_output_directory", "(", "self", ",", "path", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "self", ".", "print_error", "(", "u\"Directory '%s' does not exist\"", "%", "(", "path", ")", ")", "return", "False", ...
If the given directory cannot be written, emit an error and return ``False``. Otherwise return ``True``. :param path: the path of the output directory :type path: string (path) :rtype: bool
[ "If", "the", "given", "directory", "cannot", "be", "written", "emit", "an", "error", "and", "return", "False", ".", "Otherwise", "return", "True", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/tools/abstract_cli_program.py#L503-L520
245,915
readbeyond/aeneas
aeneas/container.py
Container.is_safe
def is_safe(self): """ Return ``True`` if the container can be safely extracted, that is, if all its entries are safe, ``False`` otherwise. :rtype: bool :raises: same as :func:`~aeneas.container.Container.entries` """ self.log(u"Checking if this container is safe...
python
def is_safe(self): self.log(u"Checking if this container is safe") for entry in self.entries: if not self.is_entry_safe(entry): self.log([u"This container is not safe: found unsafe entry '%s'", entry]) return False self.log(u"This container is safe") ...
[ "def", "is_safe", "(", "self", ")", ":", "self", ".", "log", "(", "u\"Checking if this container is safe\"", ")", "for", "entry", "in", "self", ".", "entries", ":", "if", "not", "self", ".", "is_entry_safe", "(", "entry", ")", ":", "self", ".", "log", "(...
Return ``True`` if the container can be safely extracted, that is, if all its entries are safe, ``False`` otherwise. :rtype: bool :raises: same as :func:`~aeneas.container.Container.entries`
[ "Return", "True", "if", "the", "container", "can", "be", "safely", "extracted", "that", "is", "if", "all", "its", "entries", "are", "safe", "False", "otherwise", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/container.py#L186-L200
245,916
readbeyond/aeneas
aeneas/container.py
Container.entries
def entries(self): """ Return the sorted list of entries in this container, each represented by its full path inside the container. :rtype: list of strings (path) :raises: TypeError: if this container does not exist :raises: OSError: if an error occurred reading the give...
python
def entries(self): self.log(u"Getting entries") if not self.exists(): self.log_exc(u"This container does not exist. Wrong path?", None, True, TypeError) if self.actual_container is None: self.log_exc(u"The actual container object has not been set", None, True, TypeError) ...
[ "def", "entries", "(", "self", ")", ":", "self", ".", "log", "(", "u\"Getting entries\"", ")", "if", "not", "self", ".", "exists", "(", ")", ":", "self", ".", "log_exc", "(", "u\"This container does not exist. Wrong path?\"", ",", "None", ",", "True", ",", ...
Return the sorted list of entries in this container, each represented by its full path inside the container. :rtype: list of strings (path) :raises: TypeError: if this container does not exist :raises: OSError: if an error occurred reading the given container (...
[ "Return", "the", "sorted", "list", "of", "entries", "in", "this", "container", "each", "represented", "by", "its", "full", "path", "inside", "the", "container", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/container.py#L218-L233
245,917
readbeyond/aeneas
aeneas/container.py
Container.find_entry
def find_entry(self, entry, exact=True): """ Return the full path to the first entry whose file name equals the given ``entry`` path. Return ``None`` if the entry cannot be found. If ``exact`` is ``True``, the path must be exact, otherwise the comparison is done only on...
python
def find_entry(self, entry, exact=True): if exact: self.log([u"Finding entry '%s' with exact=True", entry]) if entry in self.entries: self.log([u"Found entry '%s'", entry]) return entry else: self.log([u"Finding entry '%s' with exact=Fa...
[ "def", "find_entry", "(", "self", ",", "entry", ",", "exact", "=", "True", ")", ":", "if", "exact", ":", "self", ".", "log", "(", "[", "u\"Finding entry '%s' with exact=True\"", ",", "entry", "]", ")", "if", "entry", "in", "self", ".", "entries", ":", ...
Return the full path to the first entry whose file name equals the given ``entry`` path. Return ``None`` if the entry cannot be found. If ``exact`` is ``True``, the path must be exact, otherwise the comparison is done only on the file name. Example: :: entry = "co...
[ "Return", "the", "full", "path", "to", "the", "first", "entry", "whose", "file", "name", "equals", "the", "given", "entry", "path", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/container.py#L235-L272
245,918
readbeyond/aeneas
aeneas/container.py
Container.read_entry
def read_entry(self, entry): """ Read the contents of an entry in this container, and return them as a byte string. Return ``None`` if the entry is not safe or it cannot be found. :rtype: byte string :raises: same as :func:`~aeneas.container.Container.entries` ...
python
def read_entry(self, entry): if not self.is_entry_safe(entry): self.log([u"Accessing entry '%s' is not safe", entry]) return None if entry not in self.entries: self.log([u"Entry '%s' not found in this container", entry]) return None self.log([u"R...
[ "def", "read_entry", "(", "self", ",", "entry", ")", ":", "if", "not", "self", ".", "is_entry_safe", "(", "entry", ")", ":", "self", ".", "log", "(", "[", "u\"Accessing entry '%s' is not safe\"", ",", "entry", "]", ")", "return", "None", "if", "entry", "...
Read the contents of an entry in this container, and return them as a byte string. Return ``None`` if the entry is not safe or it cannot be found. :rtype: byte string :raises: same as :func:`~aeneas.container.Container.entries`
[ "Read", "the", "contents", "of", "an", "entry", "in", "this", "container", "and", "return", "them", "as", "a", "byte", "string", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/container.py#L274-L298
245,919
readbeyond/aeneas
aeneas/container.py
Container.decompress
def decompress(self, output_path): """ Decompress the entire container into the given directory. :param string output_path: path of the destination directory :raises: TypeError: if this container does not exist :raises: ValueError: if this container contains unsafe entries, ...
python
def decompress(self, output_path): self.log([u"Decompressing the container into '%s'", output_path]) if not self.exists(): self.log_exc(u"This container does not exist. Wrong path?", None, True, TypeError) if self.actual_container is None: self.log_exc(u"The actual contai...
[ "def", "decompress", "(", "self", ",", "output_path", ")", ":", "self", ".", "log", "(", "[", "u\"Decompressing the container into '%s'\"", ",", "output_path", "]", ")", "if", "not", "self", ".", "exists", "(", ")", ":", "self", ".", "log_exc", "(", "u\"Th...
Decompress the entire container into the given directory. :param string output_path: path of the destination directory :raises: TypeError: if this container does not exist :raises: ValueError: if this container contains unsafe entries, or ``output_path`` is not an e...
[ "Decompress", "the", "entire", "container", "into", "the", "given", "directory", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/container.py#L300-L320
245,920
readbeyond/aeneas
aeneas/container.py
Container.compress
def compress(self, input_path): """ Compress the contents of the given directory. :param string input_path: path of the input directory :raises: TypeError: if the container path has not been set :raises: ValueError: if ``input_path`` is not an existing directory :raises:...
python
def compress(self, input_path): self.log([u"Compressing '%s' into this container", input_path]) if self.file_path is None: self.log_exc(u"The container path has not been set", None, True, TypeError) if self.actual_container is None: self.log_exc(u"The actual container ob...
[ "def", "compress", "(", "self", ",", "input_path", ")", ":", "self", ".", "log", "(", "[", "u\"Compressing '%s' into this container\"", ",", "input_path", "]", ")", "if", "self", ".", "file_path", "is", "None", ":", "self", ".", "log_exc", "(", "u\"The conta...
Compress the contents of the given directory. :param string input_path: path of the input directory :raises: TypeError: if the container path has not been set :raises: ValueError: if ``input_path`` is not an existing directory :raises: OSError: if an error occurred compressing the given...
[ "Compress", "the", "contents", "of", "the", "given", "directory", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/container.py#L322-L341
245,921
readbeyond/aeneas
aeneas/container.py
Container.exists
def exists(self): """ Return ``True`` if the container has its path set and it exists, ``False`` otherwise. :rtype: boolean """ return gf.file_exists(self.file_path) or gf.directory_exists(self.file_path)
python
def exists(self): return gf.file_exists(self.file_path) or gf.directory_exists(self.file_path)
[ "def", "exists", "(", "self", ")", ":", "return", "gf", ".", "file_exists", "(", "self", ".", "file_path", ")", "or", "gf", ".", "directory_exists", "(", "self", ".", "file_path", ")" ]
Return ``True`` if the container has its path set and it exists, ``False`` otherwise. :rtype: boolean
[ "Return", "True", "if", "the", "container", "has", "its", "path", "set", "and", "it", "exists", "False", "otherwise", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/container.py#L343-L350
245,922
readbeyond/aeneas
aeneas/container.py
Container._set_actual_container
def _set_actual_container(self): """ Set the actual container, based on the specified container format. If the container format is not specified, infer it from the (lowercased) extension of the file path. If the format cannot be inferred, it is assumed to be of type :cla...
python
def _set_actual_container(self): # infer container format if self.container_format is None: self.log(u"Inferring actual container format...") path_lowercased = self.file_path.lower() self.log([u"Lowercased file path: '%s'", path_lowercased]) self.container...
[ "def", "_set_actual_container", "(", "self", ")", ":", "# infer container format", "if", "self", ".", "container_format", "is", "None", ":", "self", ".", "log", "(", "u\"Inferring actual container format...\"", ")", "path_lowercased", "=", "self", ".", "file_path", ...
Set the actual container, based on the specified container format. If the container format is not specified, infer it from the (lowercased) extension of the file path. If the format cannot be inferred, it is assumed to be of type :class:`~aeneas.container.ContainerFormat.UNPACKED` ...
[ "Set", "the", "actual", "container", "based", "on", "the", "specified", "container", "format", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/container.py#L352-L393
245,923
readbeyond/aeneas
aeneas/extra/ctw_speect.py
CustomTTSWrapper._synthesize_single_python_helper
def _synthesize_single_python_helper( self, text, voice_code, output_file_path=None, return_audio_data=True ): """ This is an helper function to synthesize a single text fragment via a Python call. If ``output_file_path`` is ``None``, the audi...
python
def _synthesize_single_python_helper( self, text, voice_code, output_file_path=None, return_audio_data=True ): # return zero if text is the empty string if len(text) == 0: # # NOTE values of sample_rate, encoding, data # ...
[ "def", "_synthesize_single_python_helper", "(", "self", ",", "text", ",", "voice_code", ",", "output_file_path", "=", "None", ",", "return_audio_data", "=", "True", ")", ":", "# return zero if text is the empty string", "if", "len", "(", "text", ")", "==", "0", ":...
This is an helper function to synthesize a single text fragment via a Python call. If ``output_file_path`` is ``None``, the audio data will not persist to file at the end of the method. :rtype: tuple (result, (duration, sample_rate, encoding, data))
[ "This", "is", "an", "helper", "function", "to", "synthesize", "a", "single", "text", "fragment", "via", "a", "Python", "call", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/extra/ctw_speect.py#L91-L163
245,924
readbeyond/aeneas
aeneas/analyzecontainer.py
AnalyzeContainer.analyze
def analyze(self, config_string=None): """ Analyze the given container and return the corresponding job object. On error, it will return ``None``. :param string config_string: the configuration string generated by wizard :rtype: :class:`~aeneas.job.Job` or ``None`` ...
python
def analyze(self, config_string=None): try: if config_string is not None: self.log(u"Analyzing container with the given config string") return self._analyze_txt_config(config_string=config_string) elif self.container.has_config_xml: self.lo...
[ "def", "analyze", "(", "self", ",", "config_string", "=", "None", ")", ":", "try", ":", "if", "config_string", "is", "not", "None", ":", "self", ".", "log", "(", "u\"Analyzing container with the given config string\"", ")", "return", "self", ".", "_analyze_txt_c...
Analyze the given container and return the corresponding job object. On error, it will return ``None``. :param string config_string: the configuration string generated by wizard :rtype: :class:`~aeneas.job.Job` or ``None``
[ "Analyze", "the", "given", "container", "and", "return", "the", "corresponding", "job", "object", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/analyzecontainer.py#L72-L96
245,925
readbeyond/aeneas
aeneas/analyzecontainer.py
AnalyzeContainer._create_task
def _create_task( self, task_info, config_string, sync_map_root_directory, job_os_hierarchy_type ): """ Create a task object from 1. the ``task_info`` found analyzing the container entries, and 2. the given ``config_string`...
python
def _create_task( self, task_info, config_string, sync_map_root_directory, job_os_hierarchy_type ): self.log(u"Converting config string to config dict") parameters = gf.config_string_to_dict(config_string) self.log(u"Creating task")...
[ "def", "_create_task", "(", "self", ",", "task_info", ",", "config_string", ",", "sync_map_root_directory", ",", "job_os_hierarchy_type", ")", ":", "self", ".", "log", "(", "u\"Converting config string to config dict\"", ")", "parameters", "=", "gf", ".", "config_stri...
Create a task object from 1. the ``task_info`` found analyzing the container entries, and 2. the given ``config_string``. :param list task_info: the task information: ``[prefix, text_path, audio_path]`` :param string config_string: the configuration string :param string sync_ma...
[ "Create", "a", "task", "object", "from" ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/analyzecontainer.py#L330-L388
245,926
readbeyond/aeneas
aeneas/analyzecontainer.py
AnalyzeContainer._compute_sync_map_file_path
def _compute_sync_map_file_path( self, root, hierarchy_type, custom_id, file_name ): """ Compute the sync map file path inside the output container. :param string root: the root of the sync map files inside the container :p...
python
def _compute_sync_map_file_path( self, root, hierarchy_type, custom_id, file_name ): prefix = root if hierarchy_type == HierarchyType.PAGED: prefix = gf.norm_join(prefix, custom_id) file_name_joined = gf.norm_join(prefix...
[ "def", "_compute_sync_map_file_path", "(", "self", ",", "root", ",", "hierarchy_type", ",", "custom_id", ",", "file_name", ")", ":", "prefix", "=", "root", "if", "hierarchy_type", "==", "HierarchyType", ".", "PAGED", ":", "prefix", "=", "gf", ".", "norm_join",...
Compute the sync map file path inside the output container. :param string root: the root of the sync map files inside the container :param job_os_hierarchy_type: type of job output hierarchy :type job_os_hierarchy_type: :class:`~aeneas.hierarchytype.HierarchyType` :param string custom_...
[ "Compute", "the", "sync", "map", "file", "path", "inside", "the", "output", "container", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/analyzecontainer.py#L403-L425
245,927
readbeyond/aeneas
aeneas/analyzecontainer.py
AnalyzeContainer._find_files
def _find_files(self, entries, root, relative_path, file_name_regex): """ Return the elements in entries that 1. are in ``root/relative_path``, and 2. match ``file_name_regex``. :param list entries: the list of entries (file paths) in the container :param string root: t...
python
def _find_files(self, entries, root, relative_path, file_name_regex): self.log([u"Finding files within root: '%s'", root]) target = root if relative_path is not None: self.log([u"Joining relative path: '%s'", relative_path]) target = gf.norm_join(root, relative_path) ...
[ "def", "_find_files", "(", "self", ",", "entries", ",", "root", ",", "relative_path", ",", "file_name_regex", ")", ":", "self", ".", "log", "(", "[", "u\"Finding files within root: '%s'\"", ",", "root", "]", ")", "target", "=", "root", "if", "relative_path", ...
Return the elements in entries that 1. are in ``root/relative_path``, and 2. match ``file_name_regex``. :param list entries: the list of entries (file paths) in the container :param string root: the root directory of the container :param string relative_path: the relative path ...
[ "Return", "the", "elements", "in", "entries", "that" ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/analyzecontainer.py#L427-L458
245,928
readbeyond/aeneas
aeneas/analyzecontainer.py
AnalyzeContainer._match_files_flat_hierarchy
def _match_files_flat_hierarchy(self, text_files, audio_files): """ Match audio and text files in flat hierarchies. Two files match if their names, once removed the file extension, are the same. Examples: :: foo/text/a.txt foo/audio/a.mp3 => match: ["a", "f...
python
def _match_files_flat_hierarchy(self, text_files, audio_files): self.log(u"Matching files in flat hierarchy") self.log([u"Text files: '%s'", text_files]) self.log([u"Audio files: '%s'", audio_files]) d_text = {} d_audio = {} for text_file in text_files: text_f...
[ "def", "_match_files_flat_hierarchy", "(", "self", ",", "text_files", ",", "audio_files", ")", ":", "self", ".", "log", "(", "u\"Matching files in flat hierarchy\"", ")", "self", ".", "log", "(", "[", "u\"Text files: '%s'\"", ",", "text_files", "]", ")", "self", ...
Match audio and text files in flat hierarchies. Two files match if their names, once removed the file extension, are the same. Examples: :: foo/text/a.txt foo/audio/a.mp3 => match: ["a", "foo/text/a.txt", "foo/audio/a.mp3"] foo/text/a.txt foo/audio/b.mp3 => no ...
[ "Match", "audio", "and", "text", "files", "in", "flat", "hierarchies", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/analyzecontainer.py#L460-L499
245,929
readbeyond/aeneas
aeneas/analyzecontainer.py
AnalyzeContainer._match_directories
def _match_directories(self, entries, root, regex_string): """ Match directory names in paged hierarchies. Example: :: root = /foo/bar regex_string = [0-9]+ /foo/bar/ 1/ bar baz ...
python
def _match_directories(self, entries, root, regex_string): self.log(u"Matching directory names in paged hierarchy") self.log([u"Matching within '%s'", root]) self.log([u"Matching regex '%s'", regex_string]) regex = re.compile(r"" + regex_string) directories = set() root_l...
[ "def", "_match_directories", "(", "self", ",", "entries", ",", "root", ",", "regex_string", ")", ":", "self", ".", "log", "(", "u\"Matching directory names in paged hierarchy\"", ")", "self", ".", "log", "(", "[", "u\"Matching within '%s'\"", ",", "root", "]", "...
Match directory names in paged hierarchies. Example: :: root = /foo/bar regex_string = [0-9]+ /foo/bar/ 1/ bar baz 2/ bar 3/ ...
[ "Match", "directory", "names", "in", "paged", "hierarchies", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/analyzecontainer.py#L501-L547
245,930
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask.load_task
def load_task(self, task): """ Load the task from the given ``Task`` object. :param task: the task to load :type task: :class:`~aeneas.task.Task` :raises: :class:`~aeneas.executetask.ExecuteTaskInputError`: if ``task`` is not an instance of :class:`~aeneas.task.Task` ""...
python
def load_task(self, task): if not isinstance(task, Task): self.log_exc(u"task is not an instance of Task", None, True, ExecuteTaskInputError) self.task = task
[ "def", "load_task", "(", "self", ",", "task", ")", ":", "if", "not", "isinstance", "(", "task", ",", "Task", ")", ":", "self", ".", "log_exc", "(", "u\"task is not an instance of Task\"", ",", "None", ",", "True", ",", "ExecuteTaskInputError", ")", "self", ...
Load the task from the given ``Task`` object. :param task: the task to load :type task: :class:`~aeneas.task.Task` :raises: :class:`~aeneas.executetask.ExecuteTaskInputError`: if ``task`` is not an instance of :class:`~aeneas.task.Task`
[ "Load", "the", "task", "from", "the", "given", "Task", "object", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L97-L107
245,931
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._step_begin
def _step_begin(self, label, log=True): """ Log begin of a step """ if log: self.step_label = label self.step_begin_time = self.log(u"STEP %d BEGIN (%s)" % (self.step_index, label))
python
def _step_begin(self, label, log=True): if log: self.step_label = label self.step_begin_time = self.log(u"STEP %d BEGIN (%s)" % (self.step_index, label))
[ "def", "_step_begin", "(", "self", ",", "label", ",", "log", "=", "True", ")", ":", "if", "log", ":", "self", ".", "step_label", "=", "label", "self", ".", "step_begin_time", "=", "self", ".", "log", "(", "u\"STEP %d BEGIN (%s)\"", "%", "(", "self", "....
Log begin of a step
[ "Log", "begin", "of", "a", "step" ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L109-L113
245,932
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._step_end
def _step_end(self, log=True): """ Log end of a step """ if log: step_end_time = self.log(u"STEP %d END (%s)" % (self.step_index, self.step_label)) diff = (step_end_time - self.step_begin_time) diff = float(diff.seconds + diff.microseconds / 1000000.0) sel...
python
def _step_end(self, log=True): if log: step_end_time = self.log(u"STEP %d END (%s)" % (self.step_index, self.step_label)) diff = (step_end_time - self.step_begin_time) diff = float(diff.seconds + diff.microseconds / 1000000.0) self.step_total += diff s...
[ "def", "_step_end", "(", "self", ",", "log", "=", "True", ")", ":", "if", "log", ":", "step_end_time", "=", "self", ".", "log", "(", "u\"STEP %d END (%s)\"", "%", "(", "self", ".", "step_index", ",", "self", ".", "step_label", ")", ")", "diff", "=", ...
Log end of a step
[ "Log", "end", "of", "a", "step" ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L115-L123
245,933
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._step_failure
def _step_failure(self, exc): """ Log failure of a step """ self.log_crit(u"STEP %d (%s) FAILURE" % (self.step_index, self.step_label)) self.step_index += 1 self.log_exc(u"Unexpected error while executing task", exc, True, ExecuteTaskExecutionError)
python
def _step_failure(self, exc): self.log_crit(u"STEP %d (%s) FAILURE" % (self.step_index, self.step_label)) self.step_index += 1 self.log_exc(u"Unexpected error while executing task", exc, True, ExecuteTaskExecutionError)
[ "def", "_step_failure", "(", "self", ",", "exc", ")", ":", "self", ".", "log_crit", "(", "u\"STEP %d (%s) FAILURE\"", "%", "(", "self", ".", "step_index", ",", "self", ".", "step_label", ")", ")", "self", ".", "step_index", "+=", "1", "self", ".", "log_e...
Log failure of a step
[ "Log", "failure", "of", "a", "step" ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L125-L129
245,934
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask.execute
def execute(self): """ Execute the task. The sync map produced will be stored inside the task object. :raises: :class:`~aeneas.executetask.ExecuteTaskInputError`: if there is a problem with the input parameters :raises: :class:`~aeneas.executetask.ExecuteTaskExecutionError`: if ...
python
def execute(self): self.log(u"Executing task...") # check that we have the AudioFile object if self.task.audio_file is None: self.log_exc(u"The task does not seem to have its audio file set", None, True, ExecuteTaskInputError) if ( (self.task.audio_file.audio...
[ "def", "execute", "(", "self", ")", ":", "self", ".", "log", "(", "u\"Executing task...\"", ")", "# check that we have the AudioFile object", "if", "self", ".", "task", ".", "audio_file", "is", "None", ":", "self", ".", "log_exc", "(", "u\"The task does not seem t...
Execute the task. The sync map produced will be stored inside the task object. :raises: :class:`~aeneas.executetask.ExecuteTaskInputError`: if there is a problem with the input parameters :raises: :class:`~aeneas.executetask.ExecuteTaskExecutionError`: if there is a problem during the task exec...
[ "Execute", "the", "task", ".", "The", "sync", "map", "produced", "will", "be", "stored", "inside", "the", "task", "object", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L135-L183
245,935
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._execute_single_level_task
def _execute_single_level_task(self): """ Execute a single-level task """ self.log(u"Executing single level task...") try: # load audio file, extract MFCCs from real wave, clear audio file self._step_begin(u"extract MFCC real wave") real_wave_mfcc = self._extr...
python
def _execute_single_level_task(self): self.log(u"Executing single level task...") try: # load audio file, extract MFCCs from real wave, clear audio file self._step_begin(u"extract MFCC real wave") real_wave_mfcc = self._extract_mfcc( file_path=self.tas...
[ "def", "_execute_single_level_task", "(", "self", ")", ":", "self", ".", "log", "(", "u\"Executing single level task...\"", ")", "try", ":", "# load audio file, extract MFCCs from real wave, clear audio file", "self", ".", "_step_begin", "(", "u\"extract MFCC real wave\"", ")...
Execute a single-level task
[ "Execute", "a", "single", "-", "level", "task" ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L185-L225
245,936
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._execute_level
def _execute_level(self, level, audio_file_mfcc, text_files, sync_roots, force_aba_auto=False): """ Compute the alignment for all the nodes in the given level. Return a pair (next_level_text_files, next_level_sync_roots), containing two lists of text file subtrees and sync map subtrees ...
python
def _execute_level(self, level, audio_file_mfcc, text_files, sync_roots, force_aba_auto=False): self._set_synthesizer() next_level_text_files = [] next_level_sync_roots = [] for text_file_index, text_file in enumerate(text_files): self.log([u"Text level %d, fragment %d", leve...
[ "def", "_execute_level", "(", "self", ",", "level", ",", "audio_file_mfcc", ",", "text_files", ",", "sync_roots", ",", "force_aba_auto", "=", "False", ")", ":", "self", ".", "_set_synthesizer", "(", ")", "next_level_text_files", "=", "[", "]", "next_level_sync_r...
Compute the alignment for all the nodes in the given level. Return a pair (next_level_text_files, next_level_sync_roots), containing two lists of text file subtrees and sync map subtrees on the next level. :param int level: the level :param audio_file_mfcc: the audio MFCC repre...
[ "Compute", "the", "alignment", "for", "all", "the", "nodes", "in", "the", "given", "level", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L303-L358
245,937
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._execute_inner
def _execute_inner(self, audio_file_mfcc, text_file, sync_root=None, force_aba_auto=False, log=True, leaf_level=False): """ Align a subinterval of the given AudioFileMFCC with the given TextFile. Return the computed tree of time intervals, rooted at ``sync_root`` if the latter i...
python
def _execute_inner(self, audio_file_mfcc, text_file, sync_root=None, force_aba_auto=False, log=True, leaf_level=False): self._step_begin(u"synthesize text", log=log) synt_handler, synt_path, synt_anchors, synt_format = self._synthesize(text_file) self._step_end(log=log) self._step_begin...
[ "def", "_execute_inner", "(", "self", ",", "audio_file_mfcc", ",", "text_file", ",", "sync_root", "=", "None", ",", "force_aba_auto", "=", "False", ",", "log", "=", "True", ",", "leaf_level", "=", "False", ")", ":", "self", ".", "_step_begin", "(", "u\"syn...
Align a subinterval of the given AudioFileMFCC with the given TextFile. Return the computed tree of time intervals, rooted at ``sync_root`` if the latter is not ``None``, or as a new ``Tree`` otherwise. The begin and end positions inside the AudioFileMFCC must have been...
[ "Align", "a", "subinterval", "of", "the", "given", "AudioFileMFCC", "with", "the", "given", "TextFile", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L360-L403
245,938
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._load_audio_file
def _load_audio_file(self): """ Load audio in memory. :rtype: :class:`~aeneas.audiofile.AudioFile` """ self._step_begin(u"load audio file") # NOTE file_format=None forces conversion to # PCM16 mono WAVE with default sample rate audio_file = AudioFile...
python
def _load_audio_file(self): self._step_begin(u"load audio file") # NOTE file_format=None forces conversion to # PCM16 mono WAVE with default sample rate audio_file = AudioFile( file_path=self.task.audio_file_path_absolute, file_format=None, rconf=...
[ "def", "_load_audio_file", "(", "self", ")", ":", "self", ".", "_step_begin", "(", "u\"load audio file\"", ")", "# NOTE file_format=None forces conversion to", "# PCM16 mono WAVE with default sample rate", "audio_file", "=", "AudioFile", "(", "file_path", "=", "self", ...
Load audio in memory. :rtype: :class:`~aeneas.audiofile.AudioFile`
[ "Load", "audio", "in", "memory", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L405-L422
245,939
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._clear_audio_file
def _clear_audio_file(self, audio_file): """ Clear audio from memory. :param audio_file: the object to clear :type audio_file: :class:`~aeneas.audiofile.AudioFile` """ self._step_begin(u"clear audio file") audio_file.clear_data() audio_file = None ...
python
def _clear_audio_file(self, audio_file): self._step_begin(u"clear audio file") audio_file.clear_data() audio_file = None self._step_end()
[ "def", "_clear_audio_file", "(", "self", ",", "audio_file", ")", ":", "self", ".", "_step_begin", "(", "u\"clear audio file\"", ")", "audio_file", ".", "clear_data", "(", ")", "audio_file", "=", "None", "self", ".", "_step_end", "(", ")" ]
Clear audio from memory. :param audio_file: the object to clear :type audio_file: :class:`~aeneas.audiofile.AudioFile`
[ "Clear", "audio", "from", "memory", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L424-L434
245,940
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._extract_mfcc
def _extract_mfcc(self, file_path=None, file_format=None, audio_file=None): """ Extract the MFCCs from the given audio file. :rtype: :class:`~aeneas.audiofilemfcc.AudioFileMFCC` """ audio_file_mfcc = AudioFileMFCC( file_path=file_path, file_format=file_fo...
python
def _extract_mfcc(self, file_path=None, file_format=None, audio_file=None): audio_file_mfcc = AudioFileMFCC( file_path=file_path, file_format=file_format, audio_file=audio_file, rconf=self.rconf, logger=self.logger ) if self.rconf.mmn: ...
[ "def", "_extract_mfcc", "(", "self", ",", "file_path", "=", "None", ",", "file_format", "=", "None", ",", "audio_file", "=", "None", ")", ":", "audio_file_mfcc", "=", "AudioFileMFCC", "(", "file_path", "=", "file_path", ",", "file_format", "=", "file_format", ...
Extract the MFCCs from the given audio file. :rtype: :class:`~aeneas.audiofilemfcc.AudioFileMFCC`
[ "Extract", "the", "MFCCs", "from", "the", "given", "audio", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L436-L458
245,941
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._compute_head_process_tail
def _compute_head_process_tail(self, audio_file_mfcc): """ Set the audio file head or tail, by either reading the explicit values from the Task configuration, or using SD to determine them. This function returns the lengths, in seconds, of the (head, process, tai...
python
def _compute_head_process_tail(self, audio_file_mfcc): head_length = self.task.configuration["i_a_head"] process_length = self.task.configuration["i_a_process"] tail_length = self.task.configuration["i_a_tail"] head_max = self.task.configuration["i_a_head_max"] head_min = self.ta...
[ "def", "_compute_head_process_tail", "(", "self", ",", "audio_file_mfcc", ")", ":", "head_length", "=", "self", ".", "task", ".", "configuration", "[", "\"i_a_head\"", "]", "process_length", "=", "self", ".", "task", ".", "configuration", "[", "\"i_a_process\"", ...
Set the audio file head or tail, by either reading the explicit values from the Task configuration, or using SD to determine them. This function returns the lengths, in seconds, of the (head, process, tail). :rtype: tuple (float, float, float)
[ "Set", "the", "audio", "file", "head", "or", "tail", "by", "either", "reading", "the", "explicit", "values", "from", "the", "Task", "configuration", "or", "using", "SD", "to", "determine", "them", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L460-L505
245,942
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._clear_cache_synthesizer
def _clear_cache_synthesizer(self): """ Clear the cache of the synthesizer """ self.log(u"Clearing synthesizer...") self.synthesizer.clear_cache() self.log(u"Clearing synthesizer... done")
python
def _clear_cache_synthesizer(self): self.log(u"Clearing synthesizer...") self.synthesizer.clear_cache() self.log(u"Clearing synthesizer... done")
[ "def", "_clear_cache_synthesizer", "(", "self", ")", ":", "self", ".", "log", "(", "u\"Clearing synthesizer...\"", ")", "self", ".", "synthesizer", ".", "clear_cache", "(", ")", "self", ".", "log", "(", "u\"Clearing synthesizer... done\"", ")" ]
Clear the cache of the synthesizer
[ "Clear", "the", "cache", "of", "the", "synthesizer" ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L513-L517
245,943
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._synthesize
def _synthesize(self, text_file): """ Synthesize text into a WAVE file. Return a tuple consisting of: 1. the handler of the generated audio file 2. the path of the generated audio file 3. the list of anchors, that is, a list of floats each representing the st...
python
def _synthesize(self, text_file): handler, path = gf.tmp_file(suffix=u".wav", root=self.rconf[RuntimeConfiguration.TMP_PATH]) result = self.synthesizer.synthesize(text_file, path) return (handler, path, result[0], self.synthesizer.output_audio_format)
[ "def", "_synthesize", "(", "self", ",", "text_file", ")", ":", "handler", ",", "path", "=", "gf", ".", "tmp_file", "(", "suffix", "=", "u\".wav\"", ",", "root", "=", "self", ".", "rconf", "[", "RuntimeConfiguration", ".", "TMP_PATH", "]", ")", "result", ...
Synthesize text into a WAVE file. Return a tuple consisting of: 1. the handler of the generated audio file 2. the path of the generated audio file 3. the list of anchors, that is, a list of floats each representing the start time of the corresponding text fragment...
[ "Synthesize", "text", "into", "a", "WAVE", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L519-L539
245,944
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._align_waves
def _align_waves(self, real_wave_mfcc, synt_wave_mfcc, synt_anchors): """ Align two AudioFileMFCC objects, representing WAVE files. Return a list of boundary indices. """ self.log(u"Creating DTWAligner...") aligner = DTWAligner( real_wave_mfcc, ...
python
def _align_waves(self, real_wave_mfcc, synt_wave_mfcc, synt_anchors): self.log(u"Creating DTWAligner...") aligner = DTWAligner( real_wave_mfcc, synt_wave_mfcc, rconf=self.rconf, logger=self.logger ) self.log(u"Creating DTWAligner... done") ...
[ "def", "_align_waves", "(", "self", ",", "real_wave_mfcc", ",", "synt_wave_mfcc", ",", "synt_anchors", ")", ":", "self", ".", "log", "(", "u\"Creating DTWAligner...\"", ")", "aligner", "=", "DTWAligner", "(", "real_wave_mfcc", ",", "synt_wave_mfcc", ",", "rconf", ...
Align two AudioFileMFCC objects, representing WAVE files. Return a list of boundary indices.
[ "Align", "two", "AudioFileMFCC", "objects", "representing", "WAVE", "files", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L541-L559
245,945
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._adjust_boundaries
def _adjust_boundaries(self, boundary_indices, text_file, real_wave_mfcc, sync_root, force_aba_auto=False, leaf_level=False): """ Adjust boundaries as requested by the user. Return the computed time map, that is, a list of pairs ``[start_time, end_time]``, of length equal to num...
python
def _adjust_boundaries(self, boundary_indices, text_file, real_wave_mfcc, sync_root, force_aba_auto=False, leaf_level=False): # boundary_indices contains the boundary indices in the all_mfcc of real_wave_mfcc # starting with the (head-1st fragment) and ending with (-1th fragment-tail) aba_parame...
[ "def", "_adjust_boundaries", "(", "self", ",", "boundary_indices", ",", "text_file", ",", "real_wave_mfcc", ",", "sync_root", ",", "force_aba_auto", "=", "False", ",", "leaf_level", "=", "False", ")", ":", "# boundary_indices contains the boundary indices in the all_mfcc ...
Adjust boundaries as requested by the user. Return the computed time map, that is, a list of pairs ``[start_time, end_time]``, of length equal to number of fragments + 2, where the two extra elements are for the HEAD (first) and TAIL (last).
[ "Adjust", "boundaries", "as", "requested", "by", "the", "user", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L561-L588
245,946
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._append_trivial_tree
def _append_trivial_tree(self, text_file, sync_root): """ Append trivial tree, made by one HEAD, one sync map fragment for each element of ``text_file``, and one TAIL. This function is called if either ``text_file`` has only one element, or if ``sync_root.value`` is an i...
python
def _append_trivial_tree(self, text_file, sync_root): interval = sync_root.value # # NOTE the following is correct, but it is a bit obscure # time_values = [interval.begin] * (1 + len(text_file)) + [interval.end] * 2 # if len(text_file) == 1: time_values = [in...
[ "def", "_append_trivial_tree", "(", "self", ",", "text_file", ",", "sync_root", ")", ":", "interval", "=", "sync_root", ".", "value", "#", "# NOTE the following is correct, but it is a bit obscure", "# time_values = [interval.begin] * (1 + len(text_file)) + [interval.end] * 2", "...
Append trivial tree, made by one HEAD, one sync map fragment for each element of ``text_file``, and one TAIL. This function is called if either ``text_file`` has only one element, or if ``sync_root.value`` is an interval with zero length (i.e., ``sync_root.value.begin == sync_ro...
[ "Append", "trivial", "tree", "made", "by", "one", "HEAD", "one", "sync", "map", "fragment", "for", "each", "element", "of", "text_file", "and", "one", "TAIL", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L590-L615
245,947
readbeyond/aeneas
aeneas/executetask.py
ExecuteTask._create_sync_map
def _create_sync_map(self, sync_root): """ If requested, check that the computed sync map is consistent. Then, add it to the Task. """ sync_map = SyncMap(tree=sync_root, rconf=self.rconf, logger=self.logger) if self.rconf.safety_checks: self.log(u"Running sani...
python
def _create_sync_map(self, sync_root): sync_map = SyncMap(tree=sync_root, rconf=self.rconf, logger=self.logger) if self.rconf.safety_checks: self.log(u"Running sanity check on computed sync map...") if not sync_map.leaves_are_consistent: self._step_failure(ValueEr...
[ "def", "_create_sync_map", "(", "self", ",", "sync_root", ")", ":", "sync_map", "=", "SyncMap", "(", "tree", "=", "sync_root", ",", "rconf", "=", "self", ".", "rconf", ",", "logger", "=", "self", ".", "logger", ")", "if", "self", ".", "rconf", ".", "...
If requested, check that the computed sync map is consistent. Then, add it to the Task.
[ "If", "requested", "check", "that", "the", "computed", "sync", "map", "is", "consistent", ".", "Then", "add", "it", "to", "the", "Task", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/executetask.py#L617-L630
245,948
readbeyond/aeneas
aeneas/sd.py
SD.detect_interval
def detect_interval( self, min_head_length=None, max_head_length=None, min_tail_length=None, max_tail_length=None ): """ Detect the interval of the audio file containing the fragments in the text file. Return the audio inte...
python
def detect_interval( self, min_head_length=None, max_head_length=None, min_tail_length=None, max_tail_length=None ): head = self.detect_head(min_head_length, max_head_length) tail = self.detect_tail(min_tail_length, max_tail_length) ...
[ "def", "detect_interval", "(", "self", ",", "min_head_length", "=", "None", ",", "max_head_length", "=", "None", ",", "min_tail_length", "=", "None", ",", "max_tail_length", "=", "None", ")", ":", "head", "=", "self", ".", "detect_head", "(", "min_head_length"...
Detect the interval of the audio file containing the fragments in the text file. Return the audio interval as a tuple of two :class:`~aeneas.exacttiming.TimeValue` objects, representing the begin and end time, in seconds, with respect to the full wave duration. If one o...
[ "Detect", "the", "interval", "of", "the", "audio", "file", "containing", "the", "fragments", "in", "the", "text", "file", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/sd.py#L126-L170
245,949
readbeyond/aeneas
aeneas/sd.py
SD.detect_head
def detect_head(self, min_head_length=None, max_head_length=None): """ Detect the audio head, returning its duration, in seconds. :param min_head_length: estimated minimum head length :type min_head_length: :class:`~aeneas.exacttiming.TimeValue` :param max_head_length: estimate...
python
def detect_head(self, min_head_length=None, max_head_length=None): return self._detect(min_head_length, max_head_length, tail=False)
[ "def", "detect_head", "(", "self", ",", "min_head_length", "=", "None", ",", "max_head_length", "=", "None", ")", ":", "return", "self", ".", "_detect", "(", "min_head_length", ",", "max_head_length", ",", "tail", "=", "False", ")" ]
Detect the audio head, returning its duration, in seconds. :param min_head_length: estimated minimum head length :type min_head_length: :class:`~aeneas.exacttiming.TimeValue` :param max_head_length: estimated maximum head length :type max_head_length: :class:`~aeneas.exacttiming.TimeV...
[ "Detect", "the", "audio", "head", "returning", "its", "duration", "in", "seconds", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/sd.py#L172-L184
245,950
readbeyond/aeneas
aeneas/sd.py
SD.detect_tail
def detect_tail(self, min_tail_length=None, max_tail_length=None): """ Detect the audio tail, returning its duration, in seconds. :param min_tail_length: estimated minimum tail length :type min_tail_length: :class:`~aeneas.exacttiming.TimeValue` :param max_tail_length: estimate...
python
def detect_tail(self, min_tail_length=None, max_tail_length=None): return self._detect(min_tail_length, max_tail_length, tail=True)
[ "def", "detect_tail", "(", "self", ",", "min_tail_length", "=", "None", ",", "max_tail_length", "=", "None", ")", ":", "return", "self", ".", "_detect", "(", "min_tail_length", ",", "max_tail_length", ",", "tail", "=", "True", ")" ]
Detect the audio tail, returning its duration, in seconds. :param min_tail_length: estimated minimum tail length :type min_tail_length: :class:`~aeneas.exacttiming.TimeValue` :param max_tail_length: estimated maximum tail length :type max_tail_length: :class:`~aeneas.exacttiming.TimeV...
[ "Detect", "the", "audio", "tail", "returning", "its", "duration", "in", "seconds", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/sd.py#L186-L198
245,951
readbeyond/aeneas
aeneas/synthesizer.py
Synthesizer._select_tts_engine
def _select_tts_engine(self): """ Select the TTS engine to be used by looking at the rconf object. """ self.log(u"Selecting TTS engine...") requested_tts_engine = self.rconf[RuntimeConfiguration.TTS] if requested_tts_engine == self.CUSTOM: self.log(u"TTS engin...
python
def _select_tts_engine(self): self.log(u"Selecting TTS engine...") requested_tts_engine = self.rconf[RuntimeConfiguration.TTS] if requested_tts_engine == self.CUSTOM: self.log(u"TTS engine: custom") tts_path = self.rconf[RuntimeConfiguration.TTS_PATH] if tts_p...
[ "def", "_select_tts_engine", "(", "self", ")", ":", "self", ".", "log", "(", "u\"Selecting TTS engine...\"", ")", "requested_tts_engine", "=", "self", ".", "rconf", "[", "RuntimeConfiguration", ".", "TTS", "]", "if", "requested_tts_engine", "==", "self", ".", "C...
Select the TTS engine to be used by looking at the rconf object.
[ "Select", "the", "TTS", "engine", "to", "be", "used", "by", "looking", "at", "the", "rconf", "object", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/synthesizer.py#L98-L150
245,952
readbeyond/aeneas
aeneas/diagnostics.py
Diagnostics.check_shell_encoding
def check_shell_encoding(cls): """ Check whether ``sys.stdin`` and ``sys.stdout`` are UTF-8 encoded. Return ``True`` on failure and ``False`` on success. :rtype: bool """ is_in_utf8 = True is_out_utf8 = True if sys.stdin.encoding not in ["UTF-8", "UTF8"]...
python
def check_shell_encoding(cls): is_in_utf8 = True is_out_utf8 = True if sys.stdin.encoding not in ["UTF-8", "UTF8"]: is_in_utf8 = False if sys.stdout.encoding not in ["UTF-8", "UTF8"]: is_out_utf8 = False if (is_in_utf8) and (is_out_utf8): gf.pr...
[ "def", "check_shell_encoding", "(", "cls", ")", ":", "is_in_utf8", "=", "True", "is_out_utf8", "=", "True", "if", "sys", ".", "stdin", ".", "encoding", "not", "in", "[", "\"UTF-8\"", ",", "\"UTF8\"", "]", ":", "is_in_utf8", "=", "False", "if", "sys", "."...
Check whether ``sys.stdin`` and ``sys.stdout`` are UTF-8 encoded. Return ``True`` on failure and ``False`` on success. :rtype: bool
[ "Check", "whether", "sys", ".", "stdin", "and", "sys", ".", "stdout", "are", "UTF", "-", "8", "encoded", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/diagnostics.py#L49-L77
245,953
readbeyond/aeneas
aeneas/diagnostics.py
Diagnostics.check_ffprobe
def check_ffprobe(cls): """ Check whether ``ffprobe`` can be called. Return ``True`` on failure and ``False`` on success. :rtype: bool """ try: from aeneas.ffprobewrapper import FFPROBEWrapper file_path = gf.absolute_path(u"tools/res/audio.mp3", ...
python
def check_ffprobe(cls): try: from aeneas.ffprobewrapper import FFPROBEWrapper file_path = gf.absolute_path(u"tools/res/audio.mp3", __file__) prober = FFPROBEWrapper() properties = prober.read_properties(file_path) gf.print_success(u"ffprobe OK")...
[ "def", "check_ffprobe", "(", "cls", ")", ":", "try", ":", "from", "aeneas", ".", "ffprobewrapper", "import", "FFPROBEWrapper", "file_path", "=", "gf", ".", "absolute_path", "(", "u\"tools/res/audio.mp3\"", ",", "__file__", ")", "prober", "=", "FFPROBEWrapper", "...
Check whether ``ffprobe`` can be called. Return ``True`` on failure and ``False`` on success. :rtype: bool
[ "Check", "whether", "ffprobe", "can", "be", "called", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/diagnostics.py#L80-L101
245,954
readbeyond/aeneas
aeneas/diagnostics.py
Diagnostics.check_ffmpeg
def check_ffmpeg(cls): """ Check whether ``ffmpeg`` can be called. Return ``True`` on failure and ``False`` on success. :rtype: bool """ try: from aeneas.ffmpegwrapper import FFMPEGWrapper input_file_path = gf.absolute_path(u"tools/res/audio.mp3"...
python
def check_ffmpeg(cls): try: from aeneas.ffmpegwrapper import FFMPEGWrapper input_file_path = gf.absolute_path(u"tools/res/audio.mp3", __file__) handler, output_file_path = gf.tmp_file(suffix=u".wav") converter = FFMPEGWrapper() result = converter.conve...
[ "def", "check_ffmpeg", "(", "cls", ")", ":", "try", ":", "from", "aeneas", ".", "ffmpegwrapper", "import", "FFMPEGWrapper", "input_file_path", "=", "gf", ".", "absolute_path", "(", "u\"tools/res/audio.mp3\"", ",", "__file__", ")", "handler", ",", "output_file_path...
Check whether ``ffmpeg`` can be called. Return ``True`` on failure and ``False`` on success. :rtype: bool
[ "Check", "whether", "ffmpeg", "can", "be", "called", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/diagnostics.py#L104-L127
245,955
readbeyond/aeneas
aeneas/diagnostics.py
Diagnostics.check_espeak
def check_espeak(cls): """ Check whether ``espeak`` can be called. Return ``True`` on failure and ``False`` on success. :rtype: bool """ try: from aeneas.textfile import TextFile from aeneas.textfile import TextFragment from aeneas.tt...
python
def check_espeak(cls): try: from aeneas.textfile import TextFile from aeneas.textfile import TextFragment from aeneas.ttswrappers.espeakttswrapper import ESPEAKTTSWrapper text = u"From fairest creatures we desire increase," text_file = TextFile() ...
[ "def", "check_espeak", "(", "cls", ")", ":", "try", ":", "from", "aeneas", ".", "textfile", "import", "TextFile", "from", "aeneas", ".", "textfile", "import", "TextFragment", "from", "aeneas", ".", "ttswrappers", ".", "espeakttswrapper", "import", "ESPEAKTTSWrap...
Check whether ``espeak`` can be called. Return ``True`` on failure and ``False`` on success. :rtype: bool
[ "Check", "whether", "espeak", "can", "be", "called", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/diagnostics.py#L130-L157
245,956
readbeyond/aeneas
aeneas/diagnostics.py
Diagnostics.check_cdtw
def check_cdtw(cls): """ Check whether Python C extension ``cdtw`` can be imported. Return ``True`` on failure and ``False`` on success. :rtype: bool """ if gf.can_run_c_extension("cdtw"): gf.print_success(u"aeneas.cdtw AVAILABLE") return Fals...
python
def check_cdtw(cls): if gf.can_run_c_extension("cdtw"): gf.print_success(u"aeneas.cdtw AVAILABLE") return False gf.print_warning(u"aeneas.cdtw NOT AVAILABLE") gf.print_info(u" You can still run aeneas but it will be significantly slower") gf.print_info(u" ...
[ "def", "check_cdtw", "(", "cls", ")", ":", "if", "gf", ".", "can_run_c_extension", "(", "\"cdtw\"", ")", ":", "gf", ".", "print_success", "(", "u\"aeneas.cdtw AVAILABLE\"", ")", "return", "False", "gf", ".", "print_warning", "(", "u\"aeneas.cdtw NOT AVAILABL...
Check whether Python C extension ``cdtw`` can be imported. Return ``True`` on failure and ``False`` on success. :rtype: bool
[ "Check", "whether", "Python", "C", "extension", "cdtw", "can", "be", "imported", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/diagnostics.py#L195-L209
245,957
readbeyond/aeneas
aeneas/diagnostics.py
Diagnostics.check_cmfcc
def check_cmfcc(cls): """ Check whether Python C extension ``cmfcc`` can be imported. Return ``True`` on failure and ``False`` on success. :rtype: bool """ if gf.can_run_c_extension("cmfcc"): gf.print_success(u"aeneas.cmfcc AVAILABLE") return F...
python
def check_cmfcc(cls): if gf.can_run_c_extension("cmfcc"): gf.print_success(u"aeneas.cmfcc AVAILABLE") return False gf.print_warning(u"aeneas.cmfcc NOT AVAILABLE") gf.print_info(u" You can still run aeneas but it will be significantly slower") gf.print_info(u"...
[ "def", "check_cmfcc", "(", "cls", ")", ":", "if", "gf", ".", "can_run_c_extension", "(", "\"cmfcc\"", ")", ":", "gf", ".", "print_success", "(", "u\"aeneas.cmfcc AVAILABLE\"", ")", "return", "False", "gf", ".", "print_warning", "(", "u\"aeneas.cmfcc NOT AVAILA...
Check whether Python C extension ``cmfcc`` can be imported. Return ``True`` on failure and ``False`` on success. :rtype: bool
[ "Check", "whether", "Python", "C", "extension", "cmfcc", "can", "be", "imported", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/diagnostics.py#L212-L226
245,958
readbeyond/aeneas
aeneas/diagnostics.py
Diagnostics.check_cew
def check_cew(cls): """ Check whether Python C extension ``cew`` can be imported. Return ``True`` on failure and ``False`` on success. :rtype: bool """ if gf.can_run_c_extension("cew"): gf.print_success(u"aeneas.cew AVAILABLE") return False ...
python
def check_cew(cls): if gf.can_run_c_extension("cew"): gf.print_success(u"aeneas.cew AVAILABLE") return False gf.print_warning(u"aeneas.cew NOT AVAILABLE") gf.print_info(u" You can still run aeneas but it will be a bit slower") gf.print_info(u" Please ref...
[ "def", "check_cew", "(", "cls", ")", ":", "if", "gf", ".", "can_run_c_extension", "(", "\"cew\"", ")", ":", "gf", ".", "print_success", "(", "u\"aeneas.cew AVAILABLE\"", ")", "return", "False", "gf", ".", "print_warning", "(", "u\"aeneas.cew NOT AVAILABLE\...
Check whether Python C extension ``cew`` can be imported. Return ``True`` on failure and ``False`` on success. :rtype: bool
[ "Check", "whether", "Python", "C", "extension", "cew", "can", "be", "imported", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/diagnostics.py#L229-L243
245,959
readbeyond/aeneas
aeneas/diagnostics.py
Diagnostics.check_all
def check_all(cls, tools=True, encoding=True, c_ext=True): """ Perform all checks. Return a tuple of booleans ``(errors, warnings, c_ext_warnings)``. :param bool tools: if ``True``, check aeneas tools :param bool encoding: if ``True``, check shell encoding :param bool c...
python
def check_all(cls, tools=True, encoding=True, c_ext=True): # errors are fatal if cls.check_ffprobe(): return (True, False, False) if cls.check_ffmpeg(): return (True, False, False) if cls.check_espeak(): return (True, False, False) if (tools) a...
[ "def", "check_all", "(", "cls", ",", "tools", "=", "True", ",", "encoding", "=", "True", ",", "c_ext", "=", "True", ")", ":", "# errors are fatal", "if", "cls", ".", "check_ffprobe", "(", ")", ":", "return", "(", "True", ",", "False", ",", "False", "...
Perform all checks. Return a tuple of booleans ``(errors, warnings, c_ext_warnings)``. :param bool tools: if ``True``, check aeneas tools :param bool encoding: if ``True``, check shell encoding :param bool c_ext: if ``True``, check Python C extensions :rtype: (bool, bool, bool)
[ "Perform", "all", "checks", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/diagnostics.py#L246-L277
245,960
readbeyond/aeneas
aeneas/configuration.py
Configuration.config_string
def config_string(self): """ Build the storable string corresponding to this configuration object. :rtype: string """ return (gc.CONFIG_STRING_SEPARATOR_SYMBOL).join( [u"%s%s%s" % (fn, gc.CONFIG_STRING_ASSIGNMENT_SYMBOL, self.data[fn]) for fn in sorted(self.d...
python
def config_string(self): return (gc.CONFIG_STRING_SEPARATOR_SYMBOL).join( [u"%s%s%s" % (fn, gc.CONFIG_STRING_ASSIGNMENT_SYMBOL, self.data[fn]) for fn in sorted(self.data.keys()) if self.data[fn] is not None] )
[ "def", "config_string", "(", "self", ")", ":", "return", "(", "gc", ".", "CONFIG_STRING_SEPARATOR_SYMBOL", ")", ".", "join", "(", "[", "u\"%s%s%s\"", "%", "(", "fn", ",", "gc", ".", "CONFIG_STRING_ASSIGNMENT_SYMBOL", ",", "self", ".", "data", "[", "fn", "]...
Build the storable string corresponding to this configuration object. :rtype: string
[ "Build", "the", "storable", "string", "corresponding", "to", "this", "configuration", "object", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/configuration.py#L169-L178
245,961
readbeyond/aeneas
aeneas/exacttiming.py
TimeValue.geq_multiple
def geq_multiple(self, other): """ Return the next multiple of this time value, greater than or equal to ``other``. If ``other`` is zero, return this time value. :rtype: :class:`~aeneas.exacttiming.TimeValue` """ if other == TimeValue("0.000"): return...
python
def geq_multiple(self, other): if other == TimeValue("0.000"): return self return int(math.ceil(other / self)) * self
[ "def", "geq_multiple", "(", "self", ",", "other", ")", ":", "if", "other", "==", "TimeValue", "(", "\"0.000\"", ")", ":", "return", "self", "return", "int", "(", "math", ".", "ceil", "(", "other", "/", "self", ")", ")", "*", "self" ]
Return the next multiple of this time value, greater than or equal to ``other``. If ``other`` is zero, return this time value. :rtype: :class:`~aeneas.exacttiming.TimeValue`
[ "Return", "the", "next", "multiple", "of", "this", "time", "value", "greater", "than", "or", "equal", "to", "other", ".", "If", "other", "is", "zero", "return", "this", "time", "value", "." ]
9d95535ad63eef4a98530cfdff033b8c35315ee1
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/exacttiming.py#L67-L77
245,962
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): if not isinstance(time_point, TimeValue): raise TypeError(u"time_point is not an instance of TimeValue") return self.begin == time_point
[ "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
245,963
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): if not isinstance(time_point, TimeValue): raise TypeError(u"time_point is not an instance of TimeValue") return self.end == time_point
[ "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
245,964
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): if not isinstance(percent, Decimal): raise TypeError(u"percent is not an instance of Decimal") percent = Decimal(max(min(percent, 100), 0) / 100) return self.begin + self.length * percent
[ "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
245,965
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): if not isinstance(offset, TimeValue): raise TypeError(u"offset is not an instance of TimeValue") self.begin += offset self.end += offset if not allow_negative: self.begin = m...
[ "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
245,966
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): relative_position = self.relative_position_of(other) if relative_position in [ self.RELATIVE_POSITION_PP_C, self.RELATIVE_POSITION_PI_LC, self.RELATIVE_POSITION_PI_LG, self.RELATIVE_POSITION_PI_CG, self.RELATIVE_P...
[ "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
245,967
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 self.is_adjacent_before(other) and (not self.has_zero_length) and (not other.has_zero_length)
[ "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
245,968
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): if not isinstance(other, TimeInterval): raise TypeError(u"other is not an instance of TimeInterval") return (self.end == other.begin)
[ "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
245,969
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): if sm_format not in SyncMapFormat.ALLOWED_VALUES: self.print_error(u"Sync map format '%s' is not allowed" % (sm_format)) self.print_info(u"Allowed formats:") self.print_generic(u" ".join(SyncMapFormat.ALLOWED_VALUES)) return Fals...
[ "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
245,970
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): syncmap.add_fragment( SyncMapFragment( text_fragment=TextFragment( identifier=identifier, lines=lines, language=language ), ...
[ "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
245,971
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): self.log_exc(u"%s is abstract and cannot be called directly" % (self.TAG), None, True, NotImplementedError)
[ "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
245,972
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): self.log_exc(u"%s is abstract and cannot be called directly" % (self.TAG), None, True, NotImplementedError)
[ "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
245,973
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): msg = [] i = 1 for key in sorted(self.DEMOS.keys()): example = self.DEMOS[key] if full or example["show"]: msg.append(u"Example %d (%s)" % (i, example[u"description"])) msg.append(u" $ %s %s" % (self.i...
[ "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
245,974
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): if parameter in self.VALUES: self.print_info(u"Available values for parameter '%s':" % parameter) self.print_generic(u"\n".join(self.VALUES[parameter])) return self.HELP_EXIT_CODE if parameter not in [u"?", u""]: self.pri...
[ "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
245,975
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(): try: # copy espeak_sapi.dll to C:\Windows\System32\espeak.dll 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", ...
[ "def", "prepare_cew_for_windows", "(", ")", ":", "try", ":", "# copy espeak_sapi.dll to C:\\Windows\\System32\\espeak.dll", "espeak_dll_win_path", "=", "\"C:\\\\Windows\\\\System32\\\\espeak.dll\"", "espeak_dll_dst_path", "=", "\"aeneas\\\\cew\\\\espeak.dll\"", "espeak_dll_src_paths", ...
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
245,976
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): self.log([u"Checking encoding of file '%s'", input_file_path]) self.result = ValidatorResult() if self._are_safety_checks_disabled(u"check_file_encoding"): return self.result if not gf.file_can_be_read(input_file_path): ...
[ "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
245,977
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): self.log(u"Checking contents XML config file") self.result = ValidatorResult() if self._are_safety_checks_disabled(u"check_config_xml"): return self.result contents = gf.safe_bytes(contents) self.log(u"Checking that contents is we...
[ "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
245,978
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): self.log([u"Checking container '%s'", container_path]) self.result = ValidatorResult() if self._are_safety_checks_disabled(u"check_container"): return self.result if not (gf.file_exists(co...
[ "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
245,979
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"): if self.rconf.safety_checks: return False self.log_warn([u"Safety checks disabled => %s passed", caller]) return True
[ "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
245,980
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): 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
245,981
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): if not gf.is_bytes(bstring): self._failed(u"The given string is not a sequence of bytes") return if not gf.is_utf8_encoded(bstring): self._failed(u"The given string is not encoded in UTF-8.")
[ "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
245,982
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): forbidden = [c for c in gc.CONFIG_RESERVED_CHARACTERS if c in ustring] if len(forbidden) > 0: self._failed(u"The given string contains the reserved characters '%s'." % u" ".join(forbidden))
[ "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
245,983
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): for key, allowed_values in self.ALLOWED_VALUES: self.log([u"Checking allowed values for parameter '%s'", key]) if key in parameters: value = parameters[key] if value not in allowed_values: se...
[ "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
245,984
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): for key, values, implied_keys in self.IMPLIED_PARAMETERS: self.log([u"Checking implied parameters by '%s'='%s'", key, values]) if (key in parameters) and (parameters[key] in values): found = False for implie...
[ "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
245,985
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 ): self.log([u"Checking required parameters '%s'", required_parameters]) self.log(u"Checking input parameters are not empty") if (parameters is None) or (len(parameters) == 0): ...
[ "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
245,986
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): self.log(u"Checking the Job object generated from container") self.log(u"Checking that the Job is not None") if job is None: self._failed(u"Unable to create a Job from the container.") return self.log(u"Checking tha...
[ "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
245,987
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): msg = [] if (warnings) and (len(self.warnings) > 0): msg.append(u"Warnings:") for warning in self.warnings: msg.append(u" %s" % warning) if len(self.errors) > 0: msg.append(u"Errors:") for er...
[ "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
245,988
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 ): # test if we can read the input file if not gf.file_can_be_read(input_file_path): self.log_exc(u"Input file '%s' cannot be read" % (i...
[ "def", "convert", "(", "self", ",", "input_file_path", ",", "output_file_path", ",", "head_length", "=", "None", ",", "process_length", "=", "None", ")", ":", "# test if we can read the input file", "if", "not", "gf", ".", "file_can_be_read", "(", "input_file_path",...
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
245,989
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): if self.fragment_type == self.REGULAR: return self.chars / max_rate - self.length return TimeValue("0.000")
[ "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
245,990
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): if self.fragment_type == self.REGULAR: return -self.rate_lack(max_rate) elif self.fragment_type == self.NONSPEECH: return self.length else: return TimeValue("0.000")
[ "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
245,991
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): msg = [template % (interval) for interval in intervals] if output_file_path is None: self.print_info(u"Intervals detected:") for line in msg: self.print_generic(line) else: with io...
[ "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
245,992
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): 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
245,993
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(): # 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") return 1 # read parameters c_quit_after = float(sys.argv[1]) # NOTE: cew needs float, not TimeValue c_b...
[ "def", "main", "(", ")", ":", "# 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\"", ")", "return", "1", "# re...
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
245,994
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): from lxml import etree smil_ns = "{http://www.w3.org/ns/SMIL}" root = etree.fromstring(gf.safe_bytes(input_text)) for par in root.iter(smil_ns + "par"): for child in par: if child.tag == (smil_ns + "text"): ...
[ "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
245,995
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): if isinstance(index, int): return (index >= 0) and (index < len(self)) if isinstance(index, list): valid = True for i in index: valid = valid or self._is_valid_index(i) return valid return False
[ "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
245,996
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): if not isinstance(fragment, SyncMapFragment): raise TypeError(u"fragment is not an instance of SyncMapFragment") interval = fragment.interval if not isinstance(interval, TimeInterval): raise TypeError(u"interval is not an instance of...
[ "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
245,997
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): if not self._is_valid_index(indices): self.log_exc(u"The given list of indices is not valid", None, True, ValueError) new_fragments = [] sorted_indices = sorted(indices) i = 0 j = 0 while (i < len(self)) and (j < len(sorted_indices))...
[ "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
245,998
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): if self.is_guaranteed_sorted: self.log(u"Already sorted, returning") return self.log(u"Sorting...") self.__fragments = sorted(self.__fragments) self.log(u"Sorting... done") self.log(u"Checking relative positions...") for i in range(...
[ "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
245,999
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): self.log(u"Removing nonspeech fragments...") nonspeech = list(self.nonspeech_fragments) if zero_length_only: nonspeech = [(i, f) for i, f in nonspeech if f.has_zero_length] nonspeech_indices = [i for i, f in nonspe...
[ "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