Festival TTS
There are two very easy to install Text To Speech engines for Raspberry Pi - Festival and espeak.
The following explores the Festival engine.
=== install the Festival Text-To-Speech package ==
sudo apt-get install festival
=== Test it
$ echo "Hello. What's for dinner?" | festival --tts
=== Prepare a file of text for Festival to read
$ nano tts_text.txt
This is a line of text to speak with the Festival TTS engine.
And this is the last line of the file tts under score text dot t x t.
press ctl-o
press enter
press ctl-x
=== Read file of text with Festival
$ festival --tts tts_text.txt
=== Use festival to create a wav file of TTS from a text file
$ text2wave tts_text.txt -o tts_text.wav
$ aplay tts_text.wav
=== Use Festival interactive mode to see default voice(s)
$ festival
Festival Speech Synthesis System 2.1: release November 2010
Copyright (C) University of Edinburgh, 1996-2000. All rights reserved.
...
festival> (voice.list)
(kal_diphone)
festival> ^D (ctrl-d to exit Festival)
$
=== Festival Default Voice
Default voice included with the festival distribution package:
(voice_kal_diphone): An American English male speaker.
=== Festival default installation location
BTW: Festival is installed to /usr/share/festival
=== Festival can use SABLE TTS markup language ===
--create sable file
$ nano example.sable
type:
<?xml version="1.0"?>
<!DOCTYPE SABLE PUBLIC "-//SABLE//DTD SABLE speech mark up//EN"
"Sable.v0_2.dtd"
[]>
<SABLE>
<SPEAKER NAME="male1">
The boy saw the girl in the park <BREAK/> with the telescope.
The boy saw the girl <BREAK/> in the park with the telescope.
Good morning <BREAK /> My name is Stuart, which is spelled
<RATE SPEED="-40%">
<SAYAS MODE="literal">stuart</SAYAS> </RATE>
though some people pronounce it
<PRON SUB="stoo art">stuart</PRON>. My telephone number
is <SAYAS MODE="literal">2787</SAYAS>.
I used to work in <PRON SUB="Buckloo">Buccleuch</PRON> Place,
but no one can pronounce that.
</SPEAKER>
</SABLE>
press Ctrl-o
press Enter
press Ctrl-X
-- play the sable marked up file:
$ festival --tts example.sable
=== To make festival tts command line friendly
$ nano ~/.bashrc
Ctrl-w Ctrl-v (go to bottom of file)
type:
ftts() {
#make festival TTS command line friendly
echo $1 | festival --tts
}
press Ctrl-o
press Enter
press Ctrl-X
Back at the pi command line, type: (instead of logout, log back in)
. .bashrc
Now (and whenever logged in with same user...) you can type:
ftts "hello world"
=== calling festival from python
-- create python program
$ nano festival.py
type:
import subprocess
text = '"Hello from a python program"'
filename = 'python_text.txt'
file=open(filename,'w')
file.write(text)
file.close()
subprocess.call('festival --tts '+filename, shell=True)
subprocess.call('rm -f '+filename, shell=True)
press ctrl-o
press enter
press ctrl-x
-- run the python program
$ python festival.py
======== OPTIONAL!!! adding other/more voices =====
Other available voices: sudo apt-get install festvox-<desired_voice_pkg>
voice_rab_diphone: A British English male RP speaker, Roger. festvox-rablpc16k
voice_ked_diphone: An American English male speaker, Kurt. festvox-kdlpc16k
voice_don_diphone: LPC based diphone synthesizer, Donovan (fast) festvox-don
voice_el_diphone: A male Castilian Spanish speaker festvox-ellpc11k
festival> (voice.list)
(el_diphone ked_diphone kal_diphone rab_diphone don_diphone)
festival>
festival> (voice_ked_diphone)
ked_diphone
festival> (SayText "Hi, this is an American voice.")
festival> (voice_rab_diphone)
rab_diphone
festival> (SayText "Hi, this is a British voice.")
festival> (voice_el_diphone)
el_diphone
festival> (SayText "Hola, amigos")
festival>
For command line voice selection:
you can use text2wave
echo 'hello world' | text2wave -eval '(voice_ked_diphone)' > _tmp.wav; aplay _tmp.wav ;rm -f _tmp.wav
or
festival '(voice_ked_diphone)' '(SayText "hello world")' '(exit)'
=== to change default voice ====
$ cp /usr/share/festival/siteinit.scm /usr/share/festival/siteinit.scm.bak
$ nano /usr/share/festival/siteinit.scm
add (set! voice_default 'voice_rab_diphone) before the (provide 'siteinit) line
==== "Thaaaat's all folks" for now ========
Top Comments