27.7 openai translate


ml translate openai [-l LANGUAGE] [-o OUTPUT_FILE] [FILENAME]

The whisper package provides the functionality for the translate command. We expose the command through the MLHub package which conforms to other translate commands from other packages.

The input media file can be any of wav, mp4, mp3, flac. The default output is to stdout as text with out formats also supported: json, srt, tsv, txt, and vtt. The format can be chosen with -f srt or --format=srt for example. The output can also be saved to file with -o jokowi.srt or --output=jokowi.srt, where the output format is indicated by the file name extension.

We can try this out with Indonesia’s President Jokowi’s speech. Download a sample from Togaware:

wget https://access.togaware.com/jokowi.wav

Then translate it to English with output to stdout:

ml translate openai jokowi.wav
Assalamu'alaikum warahmatullahi wabarakatuh, Selamat pagi, ...
Hari ini saya dengan delegasi terbatas akan berangkat ke Melbourne, ...
KTT ini disenggarakan untuk memperingati 50 tahun kemitraan ASEAN dan Australia.
Tema yang diangkat adalah a partnership for the future.
Membahas bagaimana kemitraan strategis, comprehensive ASEAN Australia ...

If needed (it was not in the above example) we can specify the language of the input using -lm with id for Indonesian:

ml translate openai -l id jokowi.wav

An output file can be specified with the format determined from the file name extension.

ml translate openai -o jokowi.srt -l id jokowi.wav

The default output is a text file with one line per sentence. We can choose the output to be in subtitle format srt using -f srt, for example, as explained in Section 27.6.

Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0