aeneas is a Python/C library and a set of tools to automagically synchronize audio and text (aka forced alignment)
aeneas is a Python/C library and a set of tools to automagically synchronize audio and text (aka forced alignment)
aeneas is a Python/C library and a set of tools to automagically synchronize audio and text (aka forced alignment).
aeneas automatically generates a synchronization map between a list of text fragments and an audio file containing the narration of the text. In computer science this task is known as (automatically computing a) forced alignment.
For example, given this text file and this audio file, aeneas determines, for each fragment, the corresponding time interval in the audio file:
…This synchronization map can be output to file in several formats, depending on its application:
BeautifulSoup4, lxml, and numpyaeneas has been developed and tested on Debian 64bit, with Python 2.7 and Python 3.5, which are the only supported platforms at the moment. Nevertheless, aeneas has been confirmed to work on other Linux distributions, Mac OS X, and Windows. See the PLATFORMS file for details.
If installing aeneas natively on your OS proves difficult, you are strongly encouraged to use aeneas-vagrant, which provides aeneas inside a virtualized Debian image running under VirtualBox and Vagrant, which can be installed on any modern OS (Linux, Mac OS X, Windows).
All-in-one installers are available for Mac OS X and Windows, and a Bash script for deb-based Linux distributions (Debian, Ubuntu) is provided in this repository. It is also possible to download a VirtualBox+Vagrant virtual machine. Please see the INSTALL file for detailed, step-by-step installation procedures for different operating systems.
The generic OS-independent procedure is simple:
Make sure the following executables can be called from your shell:
espeak, ffmpeg, ffprobe, pip, and python
First install numpy with pip and then aeneas (this order is important):
pip install numpy
pip install aeneasTo check whether you installed aeneas correctly, run:
python -m aeneas.diagnosticsRun without arguments to get the usage message:
python -m aeneas.tools.execute_task
python -m aeneas.tools.execute_jobYou can also get a list of live examples that you can immediately run on your machine thanks to the included files:
python -m aeneas.tools.execute_task --examples
python -m aeneas.tools.execute_task --examples-allTo compute a synchronization map map.json for a pair
(audio.mp3, text.txt in
plain
text format), you can run:
python -m aeneas.tools.execute_task \
audio.mp3 \
text.txt \
"task_language=eng|os_task_file_format=json|is_text_type=plain" \
map.json(The command has been split into lines with \ for visual clarity;
in production you can have the entire command on a single line
and/or you can use shell variables.)
To compute a synchronization map map.smil for a pair
(audio.mp3,
page.xhtml
containing fragments marked by id attributes like f001),
you can run:
python -m aeneas.tools.execute_task \
audio.mp3 \
page.xhtml \
"task_language=eng|os_task_file_format=smil|os_task_file_smil_audio_ref=audio.mp3|os_task_file_smil_page_ref=page.xhtml|is_text_type=unparsed|is_text_unparsed_id_regex=f[0-9]+|is_text_unparsed_id_sort=numeric" \
map.smilAs you can see, the third argument (the configuration string) specifies the parameters controlling the I/O formats and the processing options for the task. Consult the documentation for details.
If you have several tasks to process, you can create a job container to batch process them:
python -m aeneas.tools.execute_job job.zip output_directoryFile job.zip should contain a config.txt or config.xml
configuration file, providing aeneas
with all the information needed to parse the input assets
and format the output sync map files.
Consult the
documentation
for details.
The documentation contains a highly suggested tutorial which explains how to use the built-in command line tools.
parsed, plain, subtitles, or unparsed (XML) formatmplain and munparsed (XML) formatid and class attributesffmpegfinetuneas project)A significant number of users runs aeneas to align audio and text at word-level (i.e., each fragment is a word). Although aeneas was not designed with word-level alignment in mind and the results might be inferior to ASR-based forced aligners for languages with good ASR models, aeneas offers some options to improve the quality of the alignment at word-level:
If you use the aeneas.tools.execute_task command line tool,
you can add --presets-word switch to enable MFCC nonspeech masking, for example:
$ python -m aeneas.tools.execute_task --example-words --presets-word
$ python -m aeneas.tools.execute_task --example-words-multilevel --presets-wordIf you use aeneas as a library, just set the appropriate
RuntimeConfiguration parameters.
Please see the
command line tutorial
for details.
aeneas is released under the terms of the GNU Affero General Public License Version 3. See the LICENSE file for details.
Licenses for third party code and files included in aeneas can be found in the [licenses](https://g
No open issues yet, or sync has not completed.