Exporting an MP3 Audio file

About Exporting an mp3 speech file using Ubuntu 20.04 LTS or 22.04 LTS

You can save audio data in a compressed file format that many portable sound players can play. For example, you could use Read Text Extension to convert written course notes to a sound file on a portable player to listen to while travelling.

These instructions are for a version of LibreOffice managed by the apt-get package manager. If you are using a "self-contained" version of LibreOffice like the ones managed by flatpak or snap, or these instructions won't work, because their default security settings prevent LibreOffice extensions from accessing most third-party programs.

Install a speech synthesis program

  • If you haven't installed a speech synthesis program, install it. For example, to install pico, enter the following command in a terminal window:
    sudo apt-get install libttspico0 libttspico-utils libttspico-data

  • To install the pico speech synthesis program using Debian Linux or distributions derived from Debian, first enable the non-free repository. Then follow the instructions for Ubuntu. For other distributions that are derived from Ubuntu, you can simply follow the Ubuntu instructions.

Default mp3 export

With the most recent version of the extension and a version of Linux that includes support for the gstreamer platform, you can export mp3 files that include album, title, artist and genre metadata.

Install lame mp3 encoder

For use with AppImage versions of LibreOffice or to include complete metadata information with exported mp3 files, use lame, a command line program that can convert sound files to the mp3 media format. Once you have installed the program, Read Text Extension will use it to export mp3 files.

  • Quit LibreOffice.

  • Make sure your distribution files are current. Open a terminal and enter:
    sudo apt-get update
    sudo apt-get upgrade

  • Install lame with:
    sudo apt-get install lame

Install ffmpeg

For more complete metadata and more export options, use ffmpeg, a command line program that can convert sound files to and from many media formats. Once you have installed the program, Read Text Extension will use it to export mp3 files.

  • Quit LibreOffice.

  • Make sure your distribution files are current. Open a terminal and enter:
    sudo apt-get update
    sudo apt-get upgrade

  • If you haven't installed the ffmpeg mp3 converter program, install it with:
    sudo apt-get install ffmpeg

  • You can check the version of ffmpeg with:
    ffmpeg -version | grep ffmpeg

  • You can find out about ffmpeg options with:
    info ffmpeg

Configure Read Text

  • Open LibreOffice.

  • Select some text.

  • Tools - Add-Ons - Read Text...

  • External program (default):
    /usr/bin/python3

  • Command line options: (save as an .mp3 audio file in the home directory):
    "(PICO_READ_TEXT_PY)" --language=(SELECTION_LANGUAGE_CODE) --output "(HOME)(NOW).mp3" "(TMP)"

  • Command line options (default read aloud):
    "(PICO_READ_TEXT_PY)" --language=(SELECTION_LANGUAGE_COUNTRY_CODE) --visible=False "(TMP)"

Other MP3 creator options

If you plan to edit your sound files or add them to other audiovisual projects, you might need to save audio files as uncompressed .wav files and convert them later using an external program.

VLC


VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files. It can display, stream and save media in many different formats, including mp3 audio files.

  • sudo apt-get install vlc

  • Open LibreOffice.

  • Select some text.

  • Tools - Add-Ons - Read Text...

  • External program (default):
    /usr/bin/python3

  • Command line options: (save as an .wav audio file in the home directory):
    "(PICO_READ_TEXT_PY)" --language=(SELECTION_LANGUAGE_CODE) --output "(HOME)(NOW).mp3" "(TMP)"

VLC Container (Snap)

The Linux snap version of VLC might not be able to browse to removable or restricted directories. The default security settings might also restrict the application from running scripts or playlists generated by an external program. For more information, check out "How to snap: introducing classic confinement" on the Ubuntu.com blog.

  • sudo snap install vlc

  • Open LibreOffice.

  • Select some text.

  • Tools - Add-Ons - Read Text...

  • External program (default):
    /usr/bin/python3

  • Command line options: (save as an .wav audio file in the home directory):
    "(PICO_READ_TEXT_PY)" --language=(SELECTION_LANGUAGE_CODE) --output "(HOME)(NOW).wav" "(TMP)"

  • Open VLC

  • Media - Convert/Save...

  • Click the File tab.

  • Click the Add button.

  • Select the new .wav file and click Open.

  • Click the Convert/Save button.

  • Select the Profile to export: Audio - MP3.

  • Click the Browse button and enter a name for the export file.

  • Click the Start button.

Audacity

  • Audacity is a cross-platform audio editor for music, voice and effects that can combine audio files and then export the edited work to various audio formats. You can read more about Audacity in the Audacity manual.

  • The specific audio formats that you can use with Audacity might vary depending on the software packages that are installed on your computer.