Text-to-Speech
Broadsign Control Player offers the Text-to-Speech (TTS) functionality via the BroadSignObject.
You must do the following to use TTS on Ubuntu:
- Install the
speech-dispatcher
package. - Ensure that the
libspeechd2
library is installed.
There are no prerequisites on Windows.
In an HTML page, you can use the following:
Object | Description |
BroadSignObject.speechResume();
|
Resumes speech after speechPause() has been called. |
BroadSignObject.speechPause();
|
Pauses the current speech. |
BroadSignObject.speechStop();
|
Stops the current speech. |
BroadSignObject.speechSay(text, locale, voice, volume, pitch, rate);
|
Starts the speech.
|
When the ad copy is changed (for example, you leave the HTML page that generates the TTS), the TTS is stopped.
Finding Voices and Locales
To get the voices
and locales
, use the tts_lister
tool to check what is available on the system. This tool is installed in the /opt/broadsign/suite/bsp/bin/tts_lister folder.
The following is an example of tts_lister
on Ubuntu:
someuser@someuser-lin:/opt/broadsign/suite/bsp/bin$ ./tts_lister --locales
da_DK
de_DE
en_US
The following are the voices on en_US
:
someuser@someuser-lin:/opt/broadsign/suite/bsp/bin$ ./tts_lister --voices en_US
serena
samantha
English_(America)
English_(Caribbean)
en-westindies
english-us
english_wmids
english_rp
english-north
default
The following is a JavaScript sample with the BroadSignObject function:
<script>
function speak() {
var text = "Some text to say";
var locale = "en_US";
var voice = "english-us";
// Make sure these values are stored as floating-point
var volume = 1.0;
var pitch = 1.0;
var rate = 1.0;
BroadSignObject.speechSay(text, locale, voice, volume, pitch, rate);
}
function speechPlay() { BroadSignObject.speechResume(); }
function speechPause() { BroadSignObject.speechPause(); }
function speechStop() { BroadSignObject.speechStop(); }
</script>
This section describes how to install a custom Text-to-Speech module on Ubuntu 18.04+ and how to configure speech-dispatcher
to use a different engine.
The following engines have been tested with the Broadsign Control Player TTS implementation:
- espeak (default engine used by
speech-dispatcher
on Ubuntu) - espeak-ng
- festival
Usually, some "ready-to-go" packages are available via the package management system. On Ubuntu, you can use apt
to search for speech-dispatcher
compatible packages, output modules, or engines.
someuser@someuser-lin$ apt-cache search speech-dispatcher
speech-dispatcher - Common interface to speech synthesizers
speech-dispatcher-audio-plugins - Speech Dispatcher: Audio output plugins
speech-dispatcher-espeak-ng - Speech Dispatcher: Espeak-ng output module
jovie - text-to-speech system
speech-dispatcher-cicero - Speech Dispatcher: Cicero output module
speech-dispatcher-doc-cs - Speech Dispatcher documentation in Czech
speech-dispatcher-espeak - Speech Dispatcher: Espeak output module
speech-dispatcher-festival - Festival support for Speech Dispatcher
speech-dispatcher-flite - Speech Dispatcher: Flite output module
speech-dispatcher-pico - Speech Dispatcher: Pico output module
Note: Festival is different from espeak
style of engines since it is server-based, and requires more steps to set up.
Install the basic packages
The following command installs festival
output engine, speech-dispatcher
with festival
support, and mbrola voice packs.
someuser@someuser-lin$ sudo apt-get install mbrola-us1 mbrola-us2 mbrola-us3 \
festival speech-dispatcher speech-dispatcher-festival
Update global speech-dispatcher configuration to add the module
- Open the speechd.conf file:
- In that file, make the following changes:
- Look up and uncomment
AddModule "festival"
- Look up and change
DefaultModule
to"festival"
sudo vim /etc/speech-dispatcher/speechd.conf
Start festival upon system reboot
This step is necessary because festival
is conceptually very different from espeak
and other typical engines, and therefore requires a server running in the background (just like speech-dispatcher
).
To start festival upon system reboot:
- Use
cron
to set up the server. - At the end of the open file, insert the following directive:
- Once the edit is saved, reboot the system:
sudo crontab -e
@reboot /usr/bin/festival --server
Note: Make sure that this is the right location for the festival
executable and adjust accordingly if you need.
sudo reboot -n
Verify that festival is properly detected through the admin user
So far, all the steps have been done through the admin user. Let’s make sure that the admin can see festival
before continuing.
someuser@someuser-lin$ spd-say -O
OUTPUT MODULES
espeak-ng
generic
dummy
espeak
pico
festival # Woohoo ! It detected our new engine
Confirm that it plays correctly with these two commands:
someuser@someuser-lin$ echo "Are we attending a festival today ?" | festival --tts
# Should be hearing the sentence
someuser@someuser-lin$ spd-say "Are we attending a festival today ?" -o festival
# Should be hearing the sentence in festival voice.
Make festival the default engine for speech-dispatcher
Now that festival
is correctly installed, you must make it the default for speech-dispatcher
, otherwise Broadsign Control Player will not use it properly. This can be fixed by modifying the following configuration files:
-
/etc/speech-dispatcher/speechd.conf
-
/home/<SOME_USER>/.config/speech-dispatcher/speechd.conf
This one is used by your overall system, but not the bsp
user.
Required for the bsp
user and can be used by your admin user.
Note: It is recommended to use the speech-dispatcher
tool spd-conf
to do those modifications since it will create the proper file and folder structure inside the user configuration folder.
To make festival the default engine:
- Start the
spd-conf
tool: - Set the output module / speech engine to
festival
. - Redo the same thing for the
user
configuration (located at/home/<SOME_USER>/.config/speech-dispatcher/speechd.conf
). - Copy this configuration to the
bsp
user configuration folder: - Double-check that the folder structure looks the same and that the configuration file values are fine (
DefaultModule
,AddModule
), then assign the ownership tobsp
:
sudo spd-conf
sudo cp -R ~/.config/speech-dispatcher /home/bsp/.config/
sudo chown -R bsp /home/bsp/.config/speech-dispatcher
Final Steps
-
Reboot the system:
-
Test Broadsign Control Player in dedicated mode with a TTS test ad copy.
-
Confirm that Broadsign Control Player uses the
festival
engine (by default, it uses thekal_diphone
voice) -
For a smoother and more natural voice, we suggest to lower the pitch and maybe the rate compared to Broadsign’s provided default values.
sudo reboot -n