element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Adding Festival Text-To-Speech (TTS) to Raspbian-lite on RPi 3
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: alanmcdonley
  • Date Created: 1 May 2016 6:57 PM Date Created
  • Views 2230 views
  • Likes 4 likes
  • Comments 2 comments
Related
Recommended

Adding Festival Text-To-Speech (TTS) to Raspbian-lite on RPi 3

alanmcdonley
alanmcdonley
1 May 2016

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 ========

  • Sign in to reply

Top Comments

  • dougw
    dougw over 9 years ago +1
    looks useful - thanks for posting
  • clem57
    clem57 over 9 years ago +1
    I like how Python can be used here!
Parents
  • clem57
    clem57 over 9 years ago

    I like how Python can be used here!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • clem57
    clem57 over 9 years ago

    I like how Python can be used here!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube