Play Audio TTS via 3.5 mm audio out on Raspberry Pi

Hi,
I have been struggling with this and I am lost. What I am trying to do is to play audio (TTS) via 3.5 mm audio out. Below is the flow:

[{"id":"61406ded.bf2fa4","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"f3c6efeb.301f7","type":"ui_tab","z":"","name":"Home","icon":"Test","disabled":false,"hidden":false},{"id":"e33c79e7.f1ae18","type":"ui_group","z":"","name":"Default","tab":"f3c6efeb.301f7","order":1,"disp":true,"width":"6","collapse":false},{"id":"2ed2dec5.7d7032","type":"ui_group","z":"","name":"Default","tab":"62cf268d.74cc58","order":1,"disp":true,"width":"6"},{"id":"62cf268d.74cc58","type":"ui_tab","z":"","name":"Home","icon":"home","order":1},{"id":"df183d5a.4c8af","type":"ui_button","z":"61406ded.bf2fa4","name":"","group":"e33c79e7.f1ae18","order":2,"width":0,"height":0,"passthru":false,"label":"Test TTS","tooltip":"","color":"","bgcolor":"","icon":"","payload":"Test TTS","payloadType":"str","topic":"","x":240,"y":360,"wires":[["11125f44.382901"]]},{"id":"ebf6014f.ebc82","type":"http request","z":"61406ded.bf2fa4","name":"Download m3","method":"GET","ret":"bin","paytoqs":false,"url":"https://www.thesoundarchive.com/email/mp_grail.mp3","tls":"","persist":false,"proxy":"","authType":"","x":420,"y":480,"wires":[["3037146a.3f480c"]]},{"id":"ef76a8cc.b020a8","type":"inject","z":"61406ded.bf2fa4","name":"Audio OUT","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":480,"wires":[["ebf6014f.ebc82"]]},{"id":"3037146a.3f480c","type":"ui_audio","z":"61406ded.bf2fa4","name":"","group":"2ed2dec5.7d7032","voice":"0","always":true,"x":620,"y":480,"wires":[]},{"id":"23f607fa.4bb3d8","type":"comment","z":"61406ded.bf2fa4","name":"Play mp3 in dashboard","info":"","x":260,"y":440,"wires":[]},{"id":"ee88affa.a4e25","type":"http request","z":"61406ded.bf2fa4","name":"Download m3","method":"GET","ret":"bin","url":"https://www.thesoundarchive.com/email/mp_grail.mp3","tls":"","x":420,"y":580,"wires":[["22fb830b.a1314c"]]},{"id":"2f325bc5.69f824","type":"inject","z":"61406ded.bf2fa4","name":"Play Audio","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":580,"wires":[["ee88affa.a4e25"]]},{"id":"7880c572.fc226c","type":"comment","z":"61406ded.bf2fa4","name":"Play mp3 in flow editor","info":"","x":260,"y":540,"wires":[]},{"id":"22fb830b.a1314c","type":"play audio","z":"61406ded.bf2fa4","name":"","voice":"0","x":630,"y":580,"wires":[]},{"id":"3a764a9f.dcffe6","type":"inject","z":"61406ded.bf2fa4","name":"","topic":"","payload":"Test Inject","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":300,"wires":[["11125f44.382901"]]},{"id":"11125f44.382901","type":"play audio","z":"61406ded.bf2fa4","name":"","voice":"3","x":470,"y":320,"wires":[]},{"id":"f45cdd91.30c3d","type":"comment","z":"61406ded.bf2fa4","name":"Play Audio TTS","info":"","x":260,"y":240,"wires":[]}]

When I start the "Play MP3 in dashboard" flow I can hear output via 3.5 mm audio out directly from Raspberry Pi. When I do the same for "Play mp3 in flow editor", I can hear it on the computer that I use to edit the flow, nothing in audio out of the raspberry pi. Same when I use "Play Audio TSS" flow. So, my goal is to make the "Play Audio TTS" flow to output to 3.5 mm audio out in raspberry pi.
Thanks for your help
Robert

Using:
Node-RED ver : v1.0.6
Raspberry Pi 4 Model B Rev 1.1

Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster

This can’t work. The audio node you are using is only ment for playing audio in the browser. That’s why it says that the editor webpage has to be open in the Browser in the node info. For tts it uses the browsers inbuilt tts functionality and doesn’t actually do anything on the machine node-red is running on.
So for local text to speech it will just not work. You will have to use a different solution. You can install node-red-contrib-pico2wave which I just released this week. Just install the node from the palette and follow the instructions in the nodes readme to install the Svox pico tts libraries (this is the former tts engine that was used in android) on Raspberry Pi OS.
Once both the node and the libraries are installed you can generate a tts wav audio file or buffer locally on the machine nodered is running on. Now you can use a node like node-red-contrib-play-sound or something with more advanced features like node-red-contrib-sox-utils (also my node but still in beta so needs to be installed manually) to play the sound locally to the 3.5 mm output.
Hope this helps.

Johannes

1 Like

Thanks, Johannes
the way I have my set up is Raspberry Pi with a 7inch touch screen. On startup, Node-RED starts and the browser opens localhost:1880/ui. Still when I run it in this setting PlayAudio does not play via audio out. Let me try pico2wave and see what I can do with that, Thanks for the idea.
Robert

Thats why the dashboard audio node works. It plays the audio in the browser showing the dashboard which runs on the raspberry pi.