Read Text

(2 votes)
happyface_0.png

This add-on lets an external program read text from the OpenOffice.org application. If you use it with an external text-to-speech program, it can help you to edit your writing or to compare your document's text with a printed document. It can help you to learn a new language or to find out how to say words you do not know. To use it, highlight some text. If you are using writer or web writer you can highlight several selections by holding down the Control key. When you have highlighted some text, select Tools → Add-Ons → Read Selection or click the Read Selection button on the tool bar.

If you have difficulties reading the screen, you might prefer to use a system-wide accessibility solution like Orca for the Gnome desktop or KTTS for the KDE desktop. If you have installed a system-wide accessibility solution, and it is activated, then this Add-On is not needed, and probably will not work properly.

The add-on uses the temporary text files with an external program. Depending on the security set up of your computer, the contents of the text files may be readable by other users or programs. If you are concerned about privacy, launch this add-on again with no text selected to replace the temporary files that contain the text you want to remain confidential. The path and names of the temporary files are shown in the Command and Script areas of the About... dialog.

Festival
If you are using a Linux distribution that includes a package manager like Synaptic or apt-get, you can use it to install the necessary programs, lexicons and voices. If you want to hear English with Festival, and your distribution includes apt-get, use this command while connected to the Internet:
sudo apt-get install festival festlex-poslex festlex-cmu \
festlex-oald festvox-kallpc16k festvox-rablpc16k festvox-kdlpc16k

Festival text to speech is available for Czech, English, Finnish, Hindi, Italian, Marathi, Spanish, Russian and Telugu. With Festival, custom voices will only work if they are installed. If you try to use a voice that is not installed, Festival will be silent.

Your package manager may not be able to install all the voices listed in the Read Selection script dialog. Voices that include “mbrola” in the name may need to be installed manually if you want to use them. If you are using Festival, see the Festival web page or the Ubuntu forum for instructions how to install voices from the mbrola project.

The Festival package includes a tool for converting text to a wave sound file called text2wav. To use text2wav:
Select some text in OpenOffice.org.
Show the Read Selection dialog with Tools → Add-Ons → Read Selection...
Select Read the Selection with another program
Browse to the path to text2wave - in Ubuntu Linux, the location is /usr/bin/text2wave
In the command box, enter (TMP) -o (HOME)ooo_festival_(NOW).wav
Click OK to create a wave file in the OpenOffice.org document directory.

Instructions for compiling Festival for Windows are available at http://www.cstr.ed.ac.uk/projects/festival/download.html

eSpeak
eSpeak is a free text-to-speech alternative to the Festival speech synthesizer. It includes languages that are not installed by default with Festival. It is available for Windows and Linux. It includes espeak - a speech program that can run from a command line or called from an Openoffice.org Add-On like this one. eSpeak can be used with the Mbrola program to generate speech using high quality Mbrola voices.

If you want to try eSpeak with Linux, and your distribution includes apt-get, use these commands to install it:
sudo apt-get install espeak espeak-data lib-espeak1

Languages supported by eSpeak include Afrikaans, Albanian, Armenian, Bosnian, Catalan, Croatian, Czech, English, Esperanto, Finnish, French, German, Greek, Hungarian, Italian, Kurdish, Latin, Latvian, Mandarin, Polish, Romanian, Serbian, Slovak, Spanish, Swedish, Tamil, and Turkish. Versions of eSpeak for other operating platforms are available at http://espeak.sourceforge.net/.

Use different languages and voices with Linux
If you are using Linux, you can use eSpeak with Mbrola and aplay to read different languages. This is explained on the Mbrola page at the eSpeak web site. For this add-on, you need to get an Mbrola voice and create a bash script that uses pipes to pass information between the programs.

To get the add-on to speak in French, make sure you have installed Mbrola, eSpeak and aplay.
sudo apt-get install mbrola espeak espeak-data lib-espeak1 alsa-utils

Download the fr1: French Male (4.4Mb) voice from the Mbrola web site. With administrator privileges, extract the contents into a directory accessible to all users and set the permissions of the subdirectories and files to allow read access for all. To use the example script below, extract the zip file to /usr/share/festival/voices/fr/, which creates a directory /usr/share/festival/voices/fr/fr1. The bash script below reads a plain text file in French, and will work as long as there are no spaces in the file name or file path. Name this script read_in_french.sh and save it to ~/.gnome2/nautilus-scripts. Be sure to set the file permissions to allow the script to execute. (chmod a+rx ~/.gnome2/nautilus-scripts/read_in_french.sh)

#!/bin/sh
# Says the contents of a text file in French.
espeak -v mb-fr1 -f $1 | mbrola -e /usr/share/festival/voices/fr/fr1/fr1 - - | aplay -r16000 -fS16

Select some text in OpenOffice.org.
Show the Read Selection dialog with Tools → Add-Ons → Read Selection...
Select Read the Selection with another program
Browse to the path to the script – for example, ~/.gnome2/nautilus-scripts/read_in_french.sh. Note that if the file path includes a period as the first character, it is normally hidden in the file browser. You can either enable showing hidden files, or type the file path in the location bar.
In the command box, enter (TMP)
Click OK.

Use different languages and voices with Windows
The Mbrola page at the eSpeak web site explains how to install and use eSpeak and Mbrola in Windows. Install at least one Mbrola voice file for each language you want to use. For French, download the fr1: French Male (4.4Mb) voice from the Mbrola web site and install it as shown on the Mbrola page at the eSpeak web site.

Select some text in OpenOffice.org.
Show the Read Selection dialog with Tools → Add-Ons → Read Selection...
Select Read the Selection with another program
Browse to the path to the Espeak application - C:\\Program Files\eSpeak\command_line\espeak.exe
In the command box, enter -v espeak-MB-FR1 -f (TMP)
Click OK.

Other Linux voice synthesizers
A list of languages and additional information about text to speech is available at the KTTS configuration page. If you are using a different speech synthesizer, you can create a script using the read_in_french.sh script as a model.

Download extension
Operating System: Windows | Linux
Official release: 0.2.8
Date: 2009-Nov-12
Size: 31.3 KB
License: opensource | Read license
Further product information: Product details

Comments

Ubuntu 9.10 - If festival doesn't work

If you update to Ubuntu 9.10, and festival stops working, try the following:
The first time you run the updated distribution, the sound system may not work. Turn off your computer and restart it.
Configure festival to use ESD or PulseAudio. See the Ubuntu community help page for text to speech.

Configuration for ESD or PulseAudio

If you want festival to always use ESD or PulseAudio for output, you can configure this globally, for all users, or on a per-user basis. To configure globally use the configuration file /etc/festival.scm. To configure locally use the configuration file ~/.festivalrc.

1. Open the configuration file by typing, gksudo gedit /etc/festival.scm or gedit ~/.festivalrc in a terminal.
2. Add the following lines at the end of the file: (Parameter.set 'Audio_Method 'esdaudio)
3. Save the file.

This is the recommended method for playing audio in Ubuntu.

Linux - make an audio file for a podcast or your portable player

Use mbrola, eSpeak and lame to create an mp3 player compatible audio file with Linux

With the espeak, mbrola and lame packages, you can convert selected text to a mp3 compatible sound file using a script. Name this script french_recorder.sh and save it to ~/.gnome2/nautilus-scripts. Be sure to set the file permissions to allow the script to execute. (chmod a+rx ~/.gnome2/nautilus-scripts/french_recorder.sh).

#!/bin/sh
# Reads or creates mp3 audio file of the contents of a text file in French.
if [ $# = 1 ]; then
# Read it aloud now
espeak -v mb-fr1 -f $1 | mbrola -e /usr/share/festival/voices/fr/fr1/fr1 - - | aplay -r16000 -fS16
else
# Save it as a temporary wave file, then convert to a mp3 file; then remove wav file
espeak -v mb-fr1 -f $1 | mbrola -e /usr/share/festival/voices/fr/fr1/fr1 - $HOME/.temp-44044o03.wav
lame $HOME/.temp-44044o03.wav $2
rm $HOME/.temp-44044o03.wav
totem $2
fi

Select some text in OpenOffice.org.
Show the Read Selection dialog with Tools → Add-Ons → Read Selection...
Select Read the Selection with another program
Browse to the path to the script – for example, ~/.gnome2/nautilus-scripts/french_recorder.sh. Note that if the file path includes a period as the first character, it is normally hidden in the file browser. You can either enable showing hidden files, or type the file path in the location bar.
If you want the script to create an MP3 audio file, in the command box, enter (TMP) (HOME)ooo_espeak_(NOW).mp3
If you want the script to read the text aloud, in the command box, enter (TMP)
Click OK.

Read Text

Wow! espeak with mbrolla en1 is really fantastic - allows checking of large documents

Thanks for your comment! About maximum string length

Thanks for your comment! According to the OpenOffice.org Wiki, the maximum length of a string in OpenOffice.org BASIC is 65535 characters. If you want to read an even longer selection, save your selection as a text file (i. e.: ~/test.txt) then use your system's command line or a script like the Linux bash script shown above to play the selection aloud. If you are using Linux with a Gnome desktop, and you saved your script to ~/.gnome2/nautilus-scripts, you can play the plain text file by right-clicking it and choosing your script from the scripts menu.

I have only tried the English and French mbrola voices. They are easy to understand. It is too bad that the set up is a little time consuming.