lego - "I read" in Latin.
Also, lego is a lightweight CLI utility that can:
- synthesize audiobooks from .txt files and bind them into .m4b books with chapters and (optional) cover;
- translate EPUB books from one language to another.
Assuming you have Go installed, run go install github.com/beauxarts/lego
and you'll get lego
binary in your $GOPATH/bin
.
Lego allows a choice of local and cloud neural voices supported by providers in https://github.com/beauxarts/tts_integration:
acs
- Azure Cognitive Services Text to Speechgcp
- Google Cloud Text to Speechsay
- (macOS only) any locally installed voices supported by the 'say' command
Run the following command:
lego voices -locale LOCALE -provider PROVIDER [additional provider specific parameters]
Additional parameters for gcp
provider:
key-file
orkey-value
- path to a file containing secret key or literal key value
Additional parameters for acs
provider:
key-file
orkey-value
- path to a file containing secret key or literal key valueregion
- ACS region for your resource (e.g.eastus
)
Run the following command:
lego create-audiobook -text-filename PATH-TO-TXT-FILE -output-directory PATH-TO-DIRECTORY -provider PROVIDER [provider specific parameters] -voice-params [name, locale, gender] -title TITLE -author AUTHOR -cover-filename PATH-TO-COVER-IMAGE
lego
uses divido
to break down text files into chapters and paragraphs. Basically the chapter title is separated from paragraphs by at least 3 new lines, and everything with less new lines separators are paragraphs under that chapter. That seems to match text files converted by calibre
from EPUB. You can validate chapters with lego info
command.
Creating audiobook requires ffmpeg
to bind individual audio files into a single .mp4 file. Optionally, if cover image is provided, mp4art
(included in the mp4v2
tools) is needed. In most cases you don't need to specify the path to those binaries, however you can with the ffmpeg-cmd
and mp4art-cmd
parameters.
Optionally, you can provide all audiobook metadata in a single text file in wits format. The most important metadata parameters are author
and title
, which you can also specify with parameters. Note: lego
can use metadata exported by fedorov.
Note: lego
synthesis can be interrupted and continued. When restarting synthesis existing files will be skipped (to avoid paying unnecessary costs). You can force overwriting with an overwrite
parameter.
create-audiobook
is a sequence of individual command that you can use individually. You can use lego help COMMAND
to learn more about each command.
Most users don't need that and would be better served by create-audiobook
command.
Lego allows a choice of cloud neural translation models supported by providers in https://github.com/beauxarts/polyglot:
acs
- Azure Cognitive Services Text to Speechgcp
- Google Cloud Text to Speech
There doesn't seem to be a local translator available (at least on macOS). When one appears - I'm hoping to support it.
Run the following command:
lego languages -language LANGUAGE -provider PROVIDER [additional provider specific parameters]
Additional parameters for gcp
, acs
providers:
key-file
orkey-value
- path to a file containing secret key or literal key value
Run the following command:
lego translate -filename PATH-TO-EPUB-FILE -provider PROVIDER [provider specific parameters] -from LANGUAGE -to LANGUAGE
lego
will unpack EPUB into a temporary directory, translate each XHTML/HTML file in that folder and then pack EPUB back, so you'll get a new file with the target language suffix in the same location, where the original is. For example, when translating my_great_book.epub
file into fr
language, you'll get my_great_book_fr.epub
as a result.
Note: lego
translation can be interrupted and continued. When restarting translation already translated files (.xhtml.translated or .html.translated) will be skipped (to avoid paying unnecessary costs). If you want to redo those files - delete .translate files and run translate
command again.