doug
Posts: 28
Joined: Wed Nov 16, 2011 3:51 pm
Location: Llanharan, Wales

New text-to-speech (TTS) engine

Wed Feb 05, 2014 11:19 pm

For anyone who is interested I've ported a text-to-speech engine to the Raspberry Pi. Google's Android project includes an offline TTS engine called Pico TTS that they licensed from a company called SVOX but open sourced under the Apache 2 license. It is a good quality, well documented product and is designed to run efficiently on embedded platforms like the Raspberry Pi and your smart phone.

I had to do a little hacking to exact it fully from Android and also write a simple demo application to show how it is used so it might be a little rough around the edges but it works and supports several different languages. It is also far nicer to listen to than eSpeak :-)

I made a rather poor quality video/presentation to demo it in action which you can see here:

http://www.youtube.com/watch?v=CY8udTlrBXk

You can find the source code on GitHub here:

https://github.com/DougGore/picopi

It would be good for someone to try it out and let me know if it works for you. I'm sure many projects could benefit from it.

I've also left the code for the Java bindings in (untouched) just in case it could be incorporated into something like Scratch.

Doug

User avatar
AutoStatic
Posts: 326
Joined: Tue Jan 01, 2013 10:27 pm
Contact: Website

Re: New text-to-speech (TTS) engine

Thu Feb 06, 2014 4:24 pm

Cool but isn't Pico TTS already in Raspbian?
RPi and real-time, low-latency audio: http://wiki.linuxaudio.org/wiki/raspberrypi
RPi audio repository: http://rpi.autostatic.com/
RPi and audio blog: https://autostatic.com/tag/raspberrypi/

User avatar
DougieLawson
Posts: 35823
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: New text-to-speech (TTS) engine

Thu Feb 06, 2014 8:01 pm

doug wrote:
It would be good for someone to try it out and let me know if it works for you. I'm sure many projects could benefit from it.
There's no Makefile in ../pico/lib
If I try to make in ../pico/tts it fails with

Code: Select all

[email protected] /tmp/picopi/pico/tts # make
g++ -L../lib/ strdup16to8.c strdup8to16.c svox_ssml_parser.cpp com_svox_picottsengine.cpp main.cpp -lexpat -lsvoxpico -I../compat/include/ -I../lib/ -fpermissive -o testtts
strdup16to8.c: In function ‘char* strndup16to8(const char16_t*, size_t)’:
strdup16to8.c:163:25: warning: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]
     ret = malloc(len + 1);
                         ^
main.cpp: In function ‘int main(int, char**)’:
main.cpp:125:83: warning: invalid conversion from ‘uint8_t* {aka unsigned char*}’ to ‘int8_t* {aka signed char*}’ [-fpermissive]
  result = ttsEngine->synthesizeText(argv[1], synthBuffer, OUTPUT_BUFFER_SIZE, NULL);
                                                                                   ^
In file included from main.cpp:7:0:
../compat/include/TtsEngine.h:235:24: warning:   initializing argument 2 of ‘virtual android::tts_result android::TtsEngine::synthesizeText(const char*, int8_t*, size_t, void*)’ [-fpermissive]
     virtual tts_result synthesizeText(const char *text, int8_t *buffer,
                        ^
/usr/bin/ld: cannot find -lsvoxpico
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
[email protected] /tmp/picopi/pico/tts #
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Yggdrasil
Posts: 138
Joined: Sun Aug 26, 2012 8:45 pm

Re: New text-to-speech (TTS) engine

Thu Feb 06, 2014 10:01 pm

Wow, many thanks for this hint and port of the pico speech engine. :)
It's also compilable on other systems and I really like the quality (compared with espeak and festival ).
Edit: Ok, this engine isn't better in all cases. I like the voice in short sequences. Long sequences/sentences sounds quite monotone.

doug
Posts: 28
Joined: Wed Nov 16, 2011 3:51 pm
Location: Llanharan, Wales

Re: New text-to-speech (TTS) engine

Sat Feb 08, 2014 9:08 am

There should be a Makefile in the pico/lib directory, you need to do a make then a make install so it gets put in a system library directory.
DougieLawson wrote:
doug wrote:
It would be good for someone to try it out and let me know if it works for you. I'm sure many projects could benefit from it.
There's no Makefile in ../pico/lib
If I try to make in ../pico/tts it fails with

Code: Select all

[email protected] /tmp/picopi/pico/tts # make
g++ -L../lib/ strdup16to8.c strdup8to16.c svox_ssml_parser.cpp com_svox_picottsengine.cpp main.cpp -lexpat -lsvoxpico -I../compat/include/ -I../lib/ -fpermissive -o testtts
strdup16to8.c: In function ‘char* strndup16to8(const char16_t*, size_t)’:
strdup16to8.c:163:25: warning: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]
     ret = malloc(len + 1);
                         ^
main.cpp: In function ‘int main(int, char**)’:
main.cpp:125:83: warning: invalid conversion from ‘uint8_t* {aka unsigned char*}’ to ‘int8_t* {aka signed char*}’ [-fpermissive]
  result = ttsEngine->synthesizeText(argv[1], synthBuffer, OUTPUT_BUFFER_SIZE, NULL);
                                                                                   ^
In file included from main.cpp:7:0:
../compat/include/TtsEngine.h:235:24: warning:   initializing argument 2 of ‘virtual android::tts_result android::TtsEngine::synthesizeText(const char*, int8_t*, size_t, void*)’ [-fpermissive]
     virtual tts_result synthesizeText(const char *text, int8_t *buffer,
                        ^
/usr/bin/ld: cannot find -lsvoxpico
collect2: error: ld returned 1 exit status
make: *** [all] Error 1
[email protected] /tmp/picopi/pico/tts #

doug
Posts: 28
Joined: Wed Nov 16, 2011 3:51 pm
Location: Llanharan, Wales

Re: New text-to-speech (TTS) engine

Sat Feb 08, 2014 9:43 am

AutoStatic wrote:Cool but isn't Pico TTS already in Raspbian?
I couldn't find any mention of it anywhere online or on this page:
http://elinux.org/RPi_Text_to_Speech_(Speech_Synthesis)

So I assume it hasn't already been ported but I could be wrong :-)
Yggdrasil wrote:Wow, many thanks for this hint and port of the pico speech engine. :)
It's also compilable on other systems and I really like the quality (compared with espeak and festival ).
Edit: Ok, this engine isn't better in all cases. I like the voice in short sequences. Long sequences/sentences sounds quite monotone.
It is very portable I noticed the core library in the pico/lib directory required exactly zero changes to build for the Raspberry Pi. The additional C++ bits that wrap around it and extend it took some work but it adds the SSML features. I also added a sample program so there is an example of how to use it.

I agree the speech isn't perfect to get the very best results you usually need a huge data file with lots of pre-recorded words and phrases which can be hundreds of megabytes if not gigabytes in size.

Doug

User avatar
DougieLawson
Posts: 35823
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: New text-to-speech (TTS) engine

Sat Feb 08, 2014 12:55 pm

doug wrote:There should be a Makefile in the pico/lib directory, you need to do a make then a make install so it gets put in a system library directory.
Ah ha, it's there now.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

NickE
Posts: 3
Joined: Sun Sep 09, 2012 5:50 pm

Re: New text-to-speech (TTS) engine

Sat Feb 08, 2014 2:57 pm

I compiled and installed this with the instructions on github, but the testtts program is doing this:

Code: Select all

pi$ testtts "Hello"
Pico TTS Test App
Input string: "Hello"
Failed to load language
Synthesising text...
Failed to synth text
and then hangs.

Any ideas of what could be wrong?

doug
Posts: 28
Joined: Wed Nov 16, 2011 3:51 pm
Location: Llanharan, Wales

Re: New text-to-speech (TTS) engine

Sat Feb 08, 2014 3:22 pm

NickE wrote:I compiled and installed this with the instructions on github, but the testtts program is doing this:

Code: Select all

pi$ testtts "Hello"
Pico TTS Test App
Input string: "Hello"
Failed to load language
Synthesising text...
Failed to synth text
and then hangs.

Any ideas of what could be wrong?
Sorry about that, I realised I hard coded to the language data path to "../lang/" on line 103 of main.cpp. If you are running it in the pico/tts subdirectory where it is built you should be ok otherwise you might need to modify the path and copy the language data. The test program is hard coded to use the UK English so you will need the en-GB_kh0_sg.bin and en-GB_ta.bin files.

I realise that isn't very convenient, I might look into having a system wide path to install the voice data to allow multiple applications to find and use the same voice data.

Doug

darrepac
Posts: 16
Joined: Mon Feb 10, 2014 11:33 am

Re: New text-to-speech (TTS) engine

Mon Feb 10, 2014 12:23 pm

Indeed, I could be interested to know how to build french langage...

doug
Posts: 28
Joined: Wed Nov 16, 2011 3:51 pm
Location: Llanharan, Wales

Re: New text-to-speech (TTS) engine

Mon Feb 10, 2014 1:36 pm

darrepac wrote:Indeed, I could be interested to know how to build french langage...
Line 113 of main.cpp:

Code: Select all

result = ttsEngine->setLanguage("eng", "GBR", "");
Change that to:

Code: Select all

result = ttsEngine->setLanguage("fra", "FRA", "");
Hopefully that should switch it to French. I should really make that a command line switch.

Here is a list of all the supported language settings:
  • UK English - eng / GBR
  • US English - eng / USA
  • French - fra / FRA
  • German - deu / DEU
  • Spanish - spa / SPA
  • Italian - ita / ITA
Doug

User avatar
AutoStatic
Posts: 326
Joined: Tue Jan 01, 2013 10:27 pm
Contact: Website

Re: New text-to-speech (TTS) engine

Mon Feb 10, 2014 8:33 pm

doug wrote:
AutoStatic wrote:Cool but isn't Pico TTS already in Raspbian?
I couldn't find any mention of it anywhere online or on this page:
http://elinux.org/RPi_Text_to_Speech_(Speech_Synthesis)

So I assume it hasn't already been ported but I could be wrong :-)
Added it to the elinux.org Wiki: http://elinux.org/RPi_Text_to_Speech_(S ... _to_Speech
RPi and real-time, low-latency audio: http://wiki.linuxaudio.org/wiki/raspberrypi
RPi audio repository: http://rpi.autostatic.com/
RPi and audio blog: https://autostatic.com/tag/raspberrypi/

doug
Posts: 28
Joined: Wed Nov 16, 2011 3:51 pm
Location: Llanharan, Wales

Re: New text-to-speech (TTS) engine

Mon Feb 10, 2014 8:59 pm

AutoStatic wrote:
doug wrote:
AutoStatic wrote:Cool but isn't Pico TTS already in Raspbian?
I couldn't find any mention of it anywhere online or on this page:
http://elinux.org/RPi_Text_to_Speech_(Speech_Synthesis)

So I assume it hasn't already been ported but I could be wrong :-)
Added it to the elinux.org Wiki: http://elinux.org/RPi_Text_to_Speech_(S ... _to_Speech
Doh I completely failed to spot that it already existed as a package :oops:

pico2wave is easier to use to generate some speech in a file but I'm not sure you can pump the output straight into aplay like my little sample application does. In addition I've ported across the SSML parser and C++ wrapper which might be handy for some people.

I think the sample app is still useful but rather than build the core library yourself you could just install the libttspico-utils package :-)

Doug

Yggdrasil
Posts: 138
Joined: Sun Aug 26, 2012 8:45 pm

Re: New text-to-speech (TTS) engine

Fri Feb 14, 2014 5:21 pm

I've added a parameter for testts to select the used language, but do not want fork the project on Github. Feel free do add this :)
http://pastebin.com/FEcZwSYr

positron
Posts: 1
Joined: Fri Feb 21, 2014 10:03 am

Re: New text-to-speech (TTS) engine

Fri Feb 21, 2014 10:05 am

Hello there everyone! I've tried to install pico from repository as descibed in http://elinux.org/RPi_Text_to_Speech_(Speech_Synthesis), but there is no such package in raspbian repo (No

Code: Select all

libttspico-utils
, no

Code: Select all

libttspico0
, but there is a

Code: Select all

libttspico-data
). Anyone has the same problem?

doug
Posts: 28
Joined: Wed Nov 16, 2011 3:51 pm
Location: Llanharan, Wales

Re: New text-to-speech (TTS) engine

Fri Feb 21, 2014 11:02 am

Yggdrasil wrote:I've added a parameter for testts to select the used language, but do not want fork the project on Github. Feel free do add this :)
http://pastebin.com/FEcZwSYr
Thanks I'll add this in to the code in my git repo when I get a chance :-)

Doug

RamonV
Posts: 8
Joined: Mon Feb 11, 2013 4:47 pm

Re: New text-to-speech (TTS) engine

Fri Feb 21, 2014 7:21 pm

positron wrote:Hello there everyone! I've tried to install pico from repository as descibed in http://elinux.org/RPi_Text_to_Speech_(Speech_Synthesis), but there is no such package in raspbian repo (No

Code: Select all

libttspico-utils
, no

Code: Select all

libttspico0
, but there is a

Code: Select all

libttspico-data
). Anyone has the same problem?
It looks like the package got removed at some point, according to this link we have to build it ourselves (page 23 of the doc below)

http://www.mon-club-elec.fr/mes_downloa ... e_base.pdf

gkreidl
Posts: 6053
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: New text-to-speech (TTS) engine

Fri Feb 21, 2014 10:12 pm

I checked it with Synaptic when this thread was opened and it was definitely there; now I can only find libttspico-data. Really strange ....
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

hippy
Posts: 5795
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: New text-to-speech (TTS) engine

Fri Sep 12, 2014 10:50 pm

RamonV wrote:It looks like the package got removed at some point, according to this link we have to build it ourselves (page 23 of the doc below)

http://www.mon-club-elec.fr/mes_downloa ... e_base.pdf
Just a note to say that I got it to compile and install following those instructions - Thanks for that link. The only tricky part was installing the *.deb packages at the end which needed to be in a different order, or I misunderstood the instructions.

Google TTS is of superb quality but does require an internet connection. I would rate pico as just bearably tolerable, espeak too robotic, festival even more robotic.

For anyone requiring TTS in an app, I would say it would be best to use Google or grab samples of words and phrases from Google and then string them together as needed.

DazzlingDukeOfLazers
Posts: 1
Joined: Sat Feb 14, 2015 9:06 pm

Re: New text-to-speech (TTS) engine

Sat Feb 14, 2015 9:09 pm

It looks like there is a DMCA on:
https://github.com/DougGore/picopi

More:
https://github.com/github/dmca/blob/mas ... -Mobile.md

Hopefully this can be rectified.

doug
Posts: 28
Joined: Wed Nov 16, 2011 3:51 pm
Location: Llanharan, Wales

Re: New text-to-speech (TTS) engine

Tue Feb 17, 2015 9:18 pm

DazzlingDukeOfLazers wrote:It looks like there is a DMCA on:
https://github.com/DougGore/picopi

More:
https://github.com/github/dmca/blob/mas ... -Mobile.md

Hopefully this can be rectified.
The DMCA notice came as a bit of a surprise but I'm far from the only person to receive such as notice, I see CyanogenMod is in the same situation. I'm working on trying to rectify this but it will likely mean I cannot distribute the complete Android TTS engine to comply with this request.

Out of interest and to help with finding the best solution to the problem who here was using picopi? If so did you just use the library or did you use the command line tool as well?

snowblind
Posts: 1
Joined: Sun Feb 22, 2015 11:28 pm

Re: New text-to-speech (TTS) engine

Sun Feb 22, 2015 11:31 pm

I had my github copy of your pico TTS code blocked also

I use the testtts command line in some scripts

User avatar
mascal
Posts: 17
Joined: Thu Feb 21, 2013 8:09 am
Contact: Website

Re: New text-to-speech (TTS) engine

Thu Feb 26, 2015 9:19 am

I succesfully compiled the repository sources for svox pico engine and it works quite well. I put all the steps (in english) in a post on my blog, just in case someone needs them:

http://rpihome.blogspot.com/2015/02/ins ... o-tts.html
Mascal
http://rpihome.blogspot.com

doug
Posts: 28
Joined: Wed Nov 16, 2011 3:51 pm
Location: Llanharan, Wales

Re: New text-to-speech (TTS) engine

Fri Feb 27, 2015 11:28 pm

Good news everyone, I might have my repository back online. I've removed the offending file (hopefully) and realised it wasn't essential to the project anyway. I think it was just part of the Java API interface which I hadn't integrated.

Hopefully the repository will now stay up but I'll have to wait and see if I've managed to comply correctly with the DMCA request.

obra
Posts: 1
Joined: Thu Jun 25, 2015 6:49 pm

Re: New text-to-speech (TTS) engine

Thu Jun 25, 2015 6:53 pm

Hi Doug,

It seems that now that com_svox has been removed, the tts does not compile. I get the following error:

Code: Select all

/pico/tts $ make
g++ -L../lib/ strdup16to8.c strdup8to16.c svox_ssml_parser.cpp com_svox_picottsengine.cpp main.cpp -lexpat -lsvoxpico -I../compat/include/ -I../lib/ -fpermissive -o testtts
g++-4.6.real: error: com_svox_picottsengine.cpp: No such file or directory
make: *** [all] Error 1
Editing Makefile to remove reference to com_svox does not solve the problem, apparently this code is used elsewhere.

Any suggestions?

Thank you

Return to “Graphics, sound and multimedia”