Speech

From Navit's Wiki
Jump to: navigation, search

eSpeak[edit]

First, install espeak either via apt-get or manually. The advantage of the manual installation is that from 1.45-28 onwards the -a parameter for volume works as well. This is useful, because mbrola voices are generally a bit quiter than the default espeak voice. Espeak >= 1.44 calls mbrola directly, so make sure your repository version is equal or above 1.44.

repository[edit]

  • apt-get install espeak

manually (done with Ubuntu Natty)[edit]

apt-get remove espeak
apt-get remove espeak-data
apt-get remove libportaudio0
apt-get install portaudio19-dev
apt-get install libportaudio2
apt-get install debhelper
# download the latest version from http://espeak.sourceforge.net/test/latest.html
unzip espeak-*.zip
cd /usr/lib64
ln -s libaudio.so.2 libaudio.so
cd -
cd espeak-*/src/
cp portaudio19.h portaudio.h                    # ReadMe is obsolete for Ubuntu Natty
make
make install
cd -

Mbrola[edit]

install mbrola from the repositories[edit]

apt-get install mbrola

get a mbrola voice[edit]

http://www.tcts.fpms.ac.be/synthesis/mbrola/mbrcopybin.html
http://tcts.fpms.ac.be/synthesis/mbrola.html

create the needed folders[edit]

mkdir /usr/share/mbrola/
mkdir /usr/share/mbrola/voices/

unzip the voice package and put the binary! file (e.g. en1) to /usr/share/mbrola/voices/[edit]

Mbrola on Raspbian[edit]

  • tested under Raspbian Jessie on a Raspberry Pi 3

get mbrola working on Raspbian Jessie[edit]

  • found in the Raspberry Pi Forum

(https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=148096)

wget http://steinerdatenbank.de/software/mbrola3.0.1h_armhf.deb
sudo dpkg -i mbrola3.0.1h_armhf.deb

unzip the voice package and put the binary! file (e.g. en1) to /usr/share/mbrola/en1/[edit]

  • Now you should give the Mbrola Voice a try
espeak -v mb/mb-en1 "This is mbrola voice english 1"

Speech output[edit]

  • If you want to use several arguments, e.g. to play an acoustic tone prior to every speech output or if you use an eSpeak version lower than 1.44 and as a consequence a double pipe, you need to put the speechline in a script and add the path to the speech line of navit.xml .
<speech type="cmdline" data="/home/CHANGEME/.navit/speech.sh %s" cps="10" />
  • Speech.sh could have the following entry: (don't forget to chmod u+x the script!)
#!/bin/bash/
aplay -r 44100 /home/CHANGEME/.navit/sound.wav 
espeak -vmb-en1 -s 150 -a 150 -p 50 "$1"
  • Note that espeak will take 1-2 seconds to start if you put the command in a new line. For an instant play use:
#!/bin/bash/
aplay -r 44100 /home/CHANGEME/.navit/sound.wav & espeak -vmb-en1 -s 150 -a 150 -p 50 "$1"
  • For an eSpeak version below 1.44 (repository version of lucid) the pipe would look like:
#!/bin/bash/
espeak -vmb-en1 -s 150 -p 45 "$1" | mbrola -e /usr/share/mbrola/voices/en1 - - | aplay -r16550 -fs16 >> /dev/null


  • -s sets the speed
  • -a sets the volume(av. 100)
  • -p sets the pitch(av. 50)

Sounds[edit]

http://www.freesound.org/tagsViewSingle.php?id=1885

More information[edit]

For more information regarding eSpeak go to: http://espeak.sourceforge.net/

Configuring Speech in your language[edit]

To test results and for normal operation you should configure a speech program in navit.xml to listen the sentences, for example in spanish you could substitute the default speech definition:

 <speech type="cmdline" data="echo 'Fix the speech tag in navit.xml to let navit say:' '%s'" />

with an appropiate one, that uses festival:

 <speech type="cmdline" data="/usr/local/bin/speech-wrapper %s spanish">

You will also need following /usr/local/bin/speech-wrapper file wich must have an executable bit set:

 #!/bin/sh
 echo "$1" | festival --tts --language "$2"

Here's how to use espeak:

 <speech type="cmdline" data="espeak -s 150 -v german %s" />

where -s is the "Speed in words per minute" (150 seems to be quite good for german) and -v specifies the language to use. Please refer to espeak to see which languages you can use on your system and which other command-line-options are useful.

The call to external speech command is asynchronus, but it will block if previous phrase is still being speaked. The GUI will freeze while espeak is speaking to you only if it's going to say a new phrase before it end with previous. If you do not want this behaviour, you can try using wrapper script like in festival smaple but with & sign at the end of last line:

 <speech type="cmdline" data="/usr/local/bin/speech-wrapper %s german" />

Script /usr/local/bin/speech-wrapper would be like this (don't forget to set executable bit):

 #!/bin/sh
 espeak -s 150 -v "$2" "$1" &amp;

If you are running multiple programs with audio output, it is possible that /dev/dsp is locked (the default DSP for both festival and espeak). Use the following command to re-route the sound to ALSA. (To be exact, the Wave channel on the default sound card).

 <speech type="cmdline" data="/usr/local/bin/speech-wrapper %s english">

And following /usr/local/bin/speech-wrapper for espeak:

 #!/bin/sh
 espeak -s 150 -v "$2" --stdout "$1" | aplay > /dev/null

Note on the Dutch language[edit]

I had good success with the dutch extensions for festival. nextens

Especially the spoken dutch streetnames are much more clear this way.

It takes a bit of work to compile it, but i think it is worth the effort.

Letting Navit speak through KDEs kttsd in German[edit]

When you get textsynthesis in KDE running with KDEs kttsd, you can also let Navit speak through kttsd. Use this line for it (using german as language):

 <speech type="cmdline" data="dcop kttsd KSpeech sayText %s de" cps="15"/>

When the kttsd is running, Navit will now speak with your configured language/voice from kttsd (run kttsmgr to configure it). Because kttsd can be made to speak german, you can let Navit now speak german, which is quite an improvement when it comes to pronouncing german words.

There is a good howto about setting kttsd up to speak german: deutsche-sprachausgabe-in-kde

Running Debian Lenny, the mbrola-packages can be installed with apt-get (or synaptic, or aptitude, ...). I have just installed all the stuff with "apt-get install kttsd kttsd-contrib-plugins kmouth ksayit mbrola mbrola-de6 mbrola-de7" and installed and configured the "txt2pho" like described in the howto and got a full functioning, german speech synthesis in KDE. Which Navit (with the <speech type="cmdline" data="dcop kttsd KSpeech sayText %s de" cps="15"/>) uses without problems.

Use Google translate (online) to speak directions[edit]

You can let navit speak its directions using the TTS api from Google translate. It wil send the directions to the online service (internetacces is needed) and it generates an MP3 with the spoken directions that you can play using different audioplayers. This script is generated and working in win32, other oss need to be tested and confirmed. First download the VLC portable player from http://portableapps.com/apps/music_video/vlc_portable , extract and put vlc.exe somewhere in you're navit folder. You only need the exe itself.

Open a texteditor and copy the next script in it and save as <batfilename>.bat somewhere in the navit folder.

set ESCAPED=%~1%
wget -q -U Mozilla -O output.mp3 "http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=%ESCAPED%"
FULL-PATH-TO/vlc.exe --qt-start-minimized --play-and-exit -q output.mp3

change the path-to=vlc.exe to the FULL path to the exe.

You can define the language that is spoken by setting the &tl=en to the correct country tag, so for dutch it would be &tl=nl , german would be &tl=de etc.

Download WGET and put it in the same directory as you're .bat file. Download WGET from http://users.ugent.be/~bpuype/wget/ .

Open navit.xml and set the speech command to:

<speech type="cmdline"  data="FULL-PATH-TO/YOURBATFILE.bat '%s'" />

Thats it! This is still a work in progress but works in its simplest form.