Node "Play Audio" and "Text-to-Speech" on a Raspberry Pi

Hello Guys.
I discovered Node-RED days ago and I just love it !

I want to read some strings with the node "Play audio" but it's not possible. If I understand correctly, the text to speech will work only if "browser has native support for Text-to-Speech".

So, how could I do the Text to Speech on a Raspberry Pi ?
Should I use another browser ? Which one ?

(I use the last Operative System Raspbian available)


Omar C

To generate speech locally on a pi for some languages you could have a look at pico2wave (disclaimer: im the maintainer of that node). Just follow the instructions to install the libraries and install the node from the palette.
Do you have a speaker connected to your pi? To play the generated audio set the pico2wave node to output to a file than connect an exec node to it with append msg.payload selected and aplay as the command.


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.

Found this topic while doing a text to speech search on the forum and it's just what I needed :slight_smile:

Having installed the libraries on my Pi4, I just used the play audio node on the output of your node and it works great :slight_smile:


1 Like

Just for information for others who want to use this on older Pi hardware

If you go thru normal installation process and end up with an error showing in the pico2wave node - you'll need to compile it.

Unfortunately, the compilations instructions don't quite work and you need to install further dependencies

So before following the compilation instructions do this (this is from going back thru my bash history so I hope I haven't missed anything off!)

sudo apt-get install autotools-dev
sudo apt-get install libtool
sudo apt-get install libpopt-dev

I then git cloned the repository so that I had a new folder
and then cd to pico and ran the compile instructions from there

Unfortunately, the last of the instructions on the GitHub site say
make install
but this didn't work for me
neither did
sudo make install
(The sudo one appears to do the job but I still got an illegal instruction error if i ran pico2wave)

However, there is a working pico2wave in /home/pi/picotts/pico

At this point, my Linux skills ran out so to make the node use the new compiled version I manually edited

and replaced line 65
node.pico2waveCommand = "pico2wave -w " + node.filePath + " -l " + node.language;

node.pico2waveCommand = "/home/pi/picotts/pico/pico2wave -w " + node.filePath + " -l " + node.language;

and restarted Node-RED and it all worked

It was a LOT of faffing around but it lets me use an old Pi to act as a standalone text to speech device to issue commands to my Alexa dot :slight_smile:


Note on how to hear it when running Node-RED as a service

And a top tip :slight_smile:
Change orange to oranj if you want an Alexa to recognise the colour :slight_smile:
This is using English(GB) as language setting