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

**URL:** <https://discourse.nodered.org/t/node-play-audio-and-text-to-speech-on-a-raspberry-pi/40401>\
**Category:** General\
**Created:** [4 February 2021 21:18 UTC](https://discourse.nodered.org/t/node-play-audio-and-text-to-speech-on-a-raspberry-pi/40401 "2021-02-04T21:18:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![omarecd](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/omarecd/32/36259_2.png) [@omarecd](https://discourse.nodered.org/u/omarecd)\
**Post date:** [4 February 2021 21:18 UTC](https://discourse.nodered.org/t/node-play-audio-and-text-to-speech-on-a-raspberry-pi/40401/1 "2021-02-04T21:18:38Z")

</div>

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)

Thanks,

Omar C

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [5 February 2021 08:02 UTC](https://discourse.nodered.org/t/node-play-audio-and-text-to-speech-on-a-raspberry-pi/40401/2 "2021-02-05T08:02:53Z")

</div>

Hello,  
To generate speech locally on a pi for some languages you could have a look at [pico2wave](https://flows.nodered.org/node/node-red-contrib-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.

Johannes

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [6 April 2021 08:03 UTC](https://discourse.nodered.org/t/node-play-audio-and-text-to-speech-on-a-raspberry-pi/40401/3 "2021-04-06T08:03:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [27 October 2021 08:53 UTC](https://discourse.nodered.org/t/node-play-audio-and-text-to-speech-on-a-raspberry-pi/40401/4 "2021-10-27T08:53:05Z")

</div>



---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [27 October 2021 08:56 UTC](https://discourse.nodered.org/t/node-play-audio-and-text-to-speech-on-a-raspberry-pi/40401/5 "2021-10-27T08:56:05Z")

</div>

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

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/f/0fd1867c0b4afd80b7728afe2a26ece5f8a3ba44.png)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [28 October 2021 13:41 UTC](https://discourse.nodered.org/t/node-play-audio-and-text-to-speech-on-a-raspberry-pi/40401/6 "2021-10-28T13:41:53Z")

</div>

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!)

```auto
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  
/home/pi/picotts  
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  
`/home/pi/.node-red/node-modules/node-red-contrib-pico2wave/pico2wave.js`

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

`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 🙂

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/8/e86999ae15eb8fe6e9b38c1e7687e101b98e0ed1.png)

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

> [@\[SOLVED\]Not hearing sound using aplay via exec when running as service](https://discourse.nodered.org/t/solved-not-hearing-sound-using-aplay-via-exec-when-running-as-service/52924):
>
> Following on from how to get Node-RED to run as a service on a Pi I'm having trouble playing a sound via exec node So I'm trying to play a wav file out thru the Pi audio jack It works fine when I run Node-RED directly from a terminal As I was typing this I suddenly thought that the sound is probably defaulting to going out thru HDMI and with a bit of googling and experimenting I came up with this as my solution [image] which tells it to explicitly use the audio jack and all good …

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [30 October 2021 07:46 UTC](https://discourse.nodered.org/t/node-play-audio-and-text-to-speech-on-a-raspberry-pi/40401/7 "2021-10-30T07:46:36Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/8/681290f959770e6ceccfb20bda07f9d57d6a6567.png)
