wikipedia2speech

wikipedia2speech.php is a PHP-script for converting an article from the german or english wikipedia to speech. This is done with the help by two TTS-engines (Text To Speech-engines). One of them is used for the conversion of german texts and the other one for english texts. Another requirement is the availabilty of the program sox.

Installation of the TTS-engine for german texts

The source for the information presented in this chapter is http://de.gentoo-wiki.com/Mbrola.

Start the installation by typing the following commands:

mkdir -p /opt/mbrola/sources/
cd mbrola/sources/
wget http://tcts.fpms.ac.be/synthesis/mbrola/bin/pclinux/mbr301h.zip
wget http://tcts.fpms.ac.be/synthesis/mbrola/dba/de2/de2-990106.zip
unzip mbr301h.zip
cp ./mbrola-linux-i386 ../mbrola
unzip de2-990106.zip -d /opt/mbrola/
wget http://www.ikp.uni-bonn.de/dt/forsch/phonetik/hadifix/txt2pho.zip
unzip txt2pho.zip
mv txt2pho/txt2phorc /etc/txt2pho

The Variables DATAPATH and INVPATH in the file /etc/txt2pho must have the following values:

DATAPATH=/opt/mbrola/data/
INVPATH=/opt/mbrola/data/

Continue the installation by typing the folling commands:

cd /opt/mbrola/sources/txt2pho
cp -r data /opt/mbrola/
cp txt2pho /opt/mbrola/
chmod 755 /opt/mbrola/txt2pho
cd pipefilt/
g++ pipefilt.cc -o pipefilt
cp pipefilt /opt/mbrola/
cd ../preproc/
make
cp preproc /opt/mbrola/
cp Rules.lst /opt/mbrola/
cp Hadifix.abk /opt/mbrola/

Create a file named pipe-text-to-audio-file in the directory /opt/mbrola with the following content (and read the comment in the file).

#!/bin/bash
#
# This shellscript converts a textfile into speech. Please note
# that text piped to this script must be ISO-8859-1 encoded. If
# the textfile is encoded in UTF-8 then use recode in the pipe:
#
# cat datei.txt | recode UTF-8..ISO-8859-1 | pipe-text-to-audio-file /tmp/datei.wav
#
# 

ROOT=/opt/mbrola          # Where are the needed files?
VOICE=$ROOT/de2/de2             # Path to the mbrola-voice
SEX=f                           # m/f Which sex has your voice?
eval "sed 's/@/ ät /g' |\
$ROOT/pipefilt |\
$ROOT/preproc $ROOT/Rules.lst $ROOT/Hadifix.abk |\
$ROOT/txt2pho -$SEX -p $ROOT/data/ |\
$ROOT/mbrola $VOICE - -.au |\
sox -t au - -r 8000 -c 1 $1"

Finish the installation with the following commands:

chmod +x /opt/mbrola/pipe-text-to-audio-file
ln -s /opt/mbrola/pipe-text-to-audio-file /usr/bin/

Optionally you can now remove the sources with the command rm -rf /opt/mbrola/sources. Now you should check if the conversion actually works by using the command in the comment in the file /opt/mbrola/pipe-text-to-audio-file.

Installation of the TTS-engine for english texts

The following commands should give you a working installation of the TTS-engine.

cd /usr/local/src
wget http://festvox.org/packed/festival/1.96/festival-1.96-beta.tar.gz
wget http://festvox.org/packed/festival/1.96/speech_tools-1.2.96-beta.tar.gz
wget http://festvox.org/packed/festival/1.96/festlex_CMU.tar.gz
wget http://festvox.org/packed/festival/1.96/festlex_POSLEX.tar.gz
wget http://festvox.org/packed/festival/1.96/festvox_kallpc16k.tar.gz
tar xvzf festival-1.96-beta.tar.gz && tar xzvf speech_tools-1.2.96-beta.tar.gz
cd speech_tools
./configure
make
make test
cd ../festival/
./configure
make
cd ..
tar xzvf festlex_CMU.tar.gz && tar xzvf festlex_POSLEX.tar.gz
tar xvzf festvox_kallpc16k.tar.gz
export PATH=$PATH:/usr/local/src/festival/bin

We make three tests to check if everything works as expected.

  1. festival
    Festival Speech Synthesis System 1.96:beta July 2004
    Copyright (C) University of Edinburgh, 1996-2004. All rights reserved.
    For details type `(festival_warranty)'
    festival> (SayText "hello you people")
    #
    festival> 
    

    The entered command (SayText "hello you people") should say "hello you people".

  2. The command
    echo "hello you people" | festival --tts
    

    should say "hello you people".

  3. Create a file called english-text with a content like this:
    This is some kind of english text. But actually my problem is that I don't speak english.
    

    Convert this file with the command

    text2wave english-text > english-audio.wav
    

    into a wav file which should contain the spoken text.

Usage examples for wikipedia2speech.php

The command

wikipedia2speech.php --lang=de --search=staubsauger --file=/tmp/staubsauger.wav

searches for the article about "staubsauger" in the german wikipedia http://de.wikipedia.org, converts it into speech and saves the speech in the file /tmp/staubsauger.wav.

The command

wikipedia2speech.php --lang=en --search=Calling_party --file=/tmp/calling_party.wav

looks up the article about "Calling_party" in the english wikipedia http://en.wikipedia.org, converts it into speech and saves the speech in the file /tmp/calling_party.wav.