How to play audio file or tts on analog audio out of rapi?

Node RED runs on my raspi and I want to use the dashboard to play audio files / tts / streams by using the analog output of the raspi and not on the device where the dashboard is running. I could not find nodes for that case. Can you give me a hint ? thx!

Searched for “sound” on flows.nodered.org

thanx... sadly many nodes are undocumented or / and without examples/flows.

I have a flow using node-red-contrib-play-sound, It works fine on the Pi. It is MusicBox, here it is if you want to try it and look at what I did.

[{"id":"7668a1d4.ba0de8","type":"tab","label":"Music Player - v1.0.0","disabled":false,"info":"v1.0.0 - first public release"},{"id":"79bc540c.0c3a9c","type":"tab","label":"Music Engine","disabled":false,"info":""},{"id":"fc9cadf6.aa34","type":"tab","label":"Player Controls","disabled":false,"info":""},{"id":"8f32add9.664b98","type":"tab","label":"shutdown","disabled":false,"info":""},{"id":"8e36ea60.201798","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#0094CE","value":"#0094CE","edited":false},"page-titlebar-backgroundColor":{"value":"#0094CE","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#1bbfff","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#0094ce","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"b6f7fbf2.742828","type":"ui_tab","z":"","name":"Music Controls","icon":"dashboard","order":1,"disabled":false,"hidden":true},{"id":"780b4cec.4bba0c","type":"ui_group","z":"","name":"volume control","tab":"b6f7fbf2.742828","order":2,"disp":false,"width":"6","collapse":false},{"id":"b70b1541.1ae058","type":"ui_group","z":"","name":"now playing","tab":"b6f7fbf2.742828","order":1,"disp":false,"width":"6","collapse":false},{"id":"ba55d933.7a32d","type":"ui_group","z":"","name":"play controls","tab":"b6f7fbf2.742828","order":3,"disp":false,"width":"6","collapse":false},{"id":"e25e5394.01e018","type":"ui_group","z":"","name":"Shutdown Pi control","tab":"b6f7fbf2.742828","order":4,"disp":true,"width":"6","collapse":false},{"id":"d152f33c.443b38","type":"PlaySound","z":"79bc540c.0c3a9c","name":"","playerOptions":"{}","audioURI":"","options":"{}","x":730,"y":300,"wires":[["2cc4d61.08d38aa","4fb73c0c.cd629c"]]},{"id":"2cc4d61.08d38aa","type":"debug","z":"79bc540c.0c3a9c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":910,"y":300,"wires":[]},{"id":"9237e078.b014b8","type":"catch","z":"79bc540c.0c3a9c","name":"","scope":null,"uncaught":false,"x":180,"y":380,"wires":[["be4a39aa.2522a"]]},{"id":"be4a39aa.2522a","type":"debug","z":"79bc540c.0c3a9c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":430,"y":380,"wires":[]},{"id":"6f25a6ca.36ccf","type":"inject","z":"8f32add9.664b98","name":"Press to shutdown the Pi","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":140,"wires":[["2f93c722.c14bd8"]]},{"id":"2f93c722.c14bd8","type":"exec","z":"8f32add9.664b98","command":"sudo poweroff","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"poweroff","x":460,"y":140,"wires":[["64c0ce0f.da421"],["d2478678.1095e8"],["88e34de0.45552"]]},{"id":"64c0ce0f.da421","type":"debug","z":"8f32add9.664b98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":100,"wires":[]},{"id":"d2478678.1095e8","type":"debug","z":"8f32add9.664b98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":140,"wires":[]},{"id":"88e34de0.45552","type":"debug","z":"8f32add9.664b98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":180,"wires":[]},{"id":"740d6ce3.b4bd6c","type":"switch","z":"79bc540c.0c3a9c","name":"Actions","property":"musicobj.action","propertyType":"global","rules":[{"t":"eq","v":"previous","vt":"str"},{"t":"eq","v":"end","vt":"str"},{"t":"eq","v":"next","vt":"str"},{"t":"eq","v":"start","vt":"str"},{"t":"eq","v":"stop","vt":"str"},{"t":"eq","v":"pause","vt":"str"},{"t":"eq","v":"resume","vt":"str"}],"checkall":"true","repair":false,"outputs":7,"x":180,"y":240,"wires":[["4b63585c.8a9a9"],["770d870f.d868c"],["770d870f.d868c"],["770d870f.d868c"],["3f1e62b9.8341d6"],["3f1e62b9.8341d6"],["3f1e62b9.8341d6"]],"outputLabels":["","song ended","","","","",""]},{"id":"7b4c38f.84e9448","type":"ui_text","z":"79bc540c.0c3a9c","group":"b70b1541.1ae058","order":1,"width":"6","height":"1","name":"Display song name on dashboard","label":"Now playing: ","format":"{{msg.payload}}","layout":"col-center","x":800,"y":180,"wires":[]},{"id":"3073566.5ed4b2a","type":"change","z":"79bc540c.0c3a9c","name":"Get song name - strip out \".wav.\"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$globalContext(\"musicobj.songplaying\")","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"$replace(payload, \".wav\", \"\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":240,"wires":[["7b4c38f.84e9448"]]},{"id":"aca8bbef.900008","type":"fs-ops-dir","z":"7668a1d4.ba0de8","name":"Get filenames from /home/pi/songs","path":"/Users/Paul/testmusic","pathType":"str","filter":"*","filterType":"str","dir":"payload","dirType":"msg","x":240,"y":240,"wires":[["b84049d1.83dbe","7629ac65.dd147c"]]},{"id":"1ab0afbb.b9df38","type":"inject","z":"7668a1d4.ba0de8","name":"Enter the path to music folder here","topic":"","payload":"testmusic","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":240,"y":120,"wires":[["3b630f30.6530a8"]]},{"id":"7629ac65.dd147c","type":"function","z":"7668a1d4.ba0de8","name":"Get rid of hidden files and get count of songs","func":"var input = msg.payload;\nvar output = input.filter(item => item[0] == '.' ? null : item);\nmsg.payload = output;\nmsg.song_count = output.length;\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":300,"wires":[["f5755175.eb24e8","e709c796.95b8f8"]]},{"id":"b84049d1.83dbe","type":"debug","z":"7668a1d4.ba0de8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":550,"y":240,"wires":[]},{"id":"700e3050.5d3cd8","type":"debug","z":"7668a1d4.ba0de8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":550,"y":360,"wires":[]},{"id":"f5755175.eb24e8","type":"change","z":"7668a1d4.ba0de8","name":"set up global object","rules":[{"t":"set","p":"musicobj.songcount","pt":"global","to":"song_count","tot":"msg"},{"t":"move","p":"payload","pt":"msg","to":"musicobj.songlist","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":360,"wires":[["700e3050.5d3cd8","874c4a38.3a28a"]]},{"id":"874c4a38.3a28a","type":"change","z":"7668a1d4.ba0de8","name":"set up volume","rules":[{"t":"set","p":"payload","pt":"msg","to":"220","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":420,"wires":[["4a569c3.417c764"]]},{"id":"4a569c3.417c764","type":"link out","z":"7668a1d4.ba0de8","name":"to volume","links":["c63d5f3.936222","db055a05.0b1658"],"x":335,"y":420,"wires":[]},{"id":"91c678c7.70a29","type":"exec","z":"fc9cadf6.aa34","command":"amixer cset numid=1 ","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":440,"y":200,"wires":[["6d752184.004d5"],["88eb9eb8.0d7cd8"],["4d604cda.22709c"]]},{"id":"6d752184.004d5","type":"debug","z":"fc9cadf6.aa34","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":160,"wires":[]},{"id":"88eb9eb8.0d7cd8","type":"debug","z":"fc9cadf6.aa34","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":200,"wires":[]},{"id":"4d604cda.22709c","type":"debug","z":"fc9cadf6.aa34","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":240,"wires":[]},{"id":"619a1a69.46fbb4","type":"ui_slider","z":"fc9cadf6.aa34","name":"Volume","label":"","tooltip":"","group":"780b4cec.4bba0c","order":2,"width":"6","height":"1","passthru":true,"outs":"all","topic":"","min":"118","max":"235","step":1,"x":180,"y":140,"wires":[["dbc4d167.192398"]]},{"id":"dbc4d167.192398","type":"trigger","z":"fc9cadf6.aa34","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"250","extend":true,"units":"ms","reset":"","bytopic":"all","name":"","x":200,"y":200,"wires":[["91c678c7.70a29","619a1a69.46fbb4","778e6df2.e21cf4"]]},{"id":"778e6df2.e21cf4","type":"range","z":"fc9cadf6.aa34","minin":"118","maxin":"235","minout":"0","maxout":"10","action":"clamp","round":true,"property":"payload","name":"","x":170,"y":260,"wires":[["9c1e3a39.24b8e","6d926a60.c0e1ac"]]},{"id":"9c1e3a39.24b8e","type":"ui_level","z":"fc9cadf6.aa34","group":"780b4cec.4bba0c","order":3,"width":"6","height":"2","name":"UI_Level","label":"","colorHi":"#e60000","colorWarn":"#ff9900","colorNormal":"#00b33c","colorOff":"#595959","min":0,"max":"10","segWarn":"","segHigh":"","unit":"","layout":"sh","channelA":"","channelB":"","decimals":0,"animations":"reactive","shape":2,"colorText":"#000000","fontLabel":"","fontValue":"","fontSmall":"","colorFromTheme":true,"x":460,"y":280,"wires":[]},{"id":"5b81ace1.d62984","type":"ui_text","z":"fc9cadf6.aa34","group":"780b4cec.4bba0c","order":1,"width":"6","height":"1","name":"","label":"Volume","format":"","layout":"col-center","x":180,"y":100,"wires":[]},{"id":"db055a05.0b1658","type":"link in","z":"fc9cadf6.aa34","name":"volume","links":["4a569c3.417c764","b4a40821.1094d8"],"x":55,"y":140,"wires":[["619a1a69.46fbb4"]]},{"id":"c63d5f3.936222","type":"link in","z":"79bc540c.0c3a9c","name":"Check Action","links":["2f4f8361.0b5314","a2ff1cfa.cf13b8","ef5d2a88.34d878","4a569c3.417c764","b76d2885.13851","a5b42140.bcd47"],"x":75,"y":240,"wires":[["740d6ce3.b4bd6c"]]},{"id":"2f4f8361.0b5314","type":"link out","z":"79bc540c.0c3a9c","name":"","links":["c63d5f3.936222"],"x":895,"y":380,"wires":[]},{"id":"3b630f30.6530a8","type":"change","z":"7668a1d4.ba0de8","name":"","rules":[{"t":"set","p":"path","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"musicobj","pt":"global","to":"{\t   \"fileURL\"    : msg.fileURL,\t   \"audioURL\"   : msg.audioURL,\t   \"songcount\"  : 0,\t   \"songlist\"   : [],\t   \"songindex\"  : -1,\t   \"songtoplay\" : \"\",\t   \"action\"     : \"start\"     \t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":180,"wires":[["aca8bbef.900008","38848ebe.8f8faa"]]},{"id":"38848ebe.8f8faa","type":"debug","z":"7668a1d4.ba0de8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":550,"y":180,"wires":[]},{"id":"e709c796.95b8f8","type":"debug","z":"7668a1d4.ba0de8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":550,"y":300,"wires":[]},{"id":"82c6f127.50c5c","type":"ui_template","z":"fc9cadf6.aa34","group":"ba55d933.7a32d","name":">>","order":3,"width":"2","height":"2","format":"\n<md-button class=\"vibrate filled touched bigfont rounded\" style=\"background-color:#2980b9\"   ng-click=\"send({payload: 'Hello World big blue'})\"> \n    >>\n</md-button> \n\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":150,"y":620,"wires":[["dfef1196.c89ca8","30c2c3c5.e3113c"]]},{"id":"e6edbe41.9a3a78","type":"ui_template","z":"fc9cadf6.aa34","group":"ba55d933.7a32d","name":"<<","order":1,"width":"2","height":"2","format":"\n<md-button class=\"vibrate filled touched bigfont rounded\" style=\"background-color:#c0392b\" ng-click=\"send({payload: 'Hello World big red'})\"> \n   &lt;&lt;\n</md-button> \n\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":150,"y":460,"wires":[["f6e6fd41.1d1e88","dfef1196.c89ca8"]]},{"id":"d072648a.8ebba8","type":"ui_template","z":"fc9cadf6.aa34","group":"ba55d933.7a32d","name":"Play/Pause","order":2,"width":"2","height":"2","format":"<md-button class=\"filled touched bigfont rounded vibrate\" \n    style=\"background-color:#27ae60\" \n    ng-click=\"send({payload:1})\" > \n   Play/<br/>Pause\n</md-button> \n","storeOutMessages":false,"fwdInMessages":true,"templateScope":"local","x":170,"y":540,"wires":[["38a98dff.91616a"]]},{"id":"80b807a1.c80f5","type":"ui_template","z":"fc9cadf6.aa34","group":"ba55d933.7a32d","name":"Styling for player buttons","order":5,"width":"6","height":"1","format":"<style>\n  .filled { \n      height: 100% !important;\n\n      padding: 0 !important;\n      margin: 0 !important;\n  }\n  .nr-dashboard-template {\n      padding: 0;\n      margin: 0;\n  }\n  \n  .rounded {\n  border-radius: 12px 12px 12px 12px;\n}\n \n   .bigfont {\n  font-size: 18px;\n}\n\n   .smallfont {\n  font-size: 12px;\n}\n  \n</style>\n\n<script>\n$('.vibrate').on('click', function() {\n  navigator.vibrate(100);\n});\n\nfunction restore_bg(x) {\n            $(this).css(\"background-color\", x);\n    };\n\n$('.touched').on('mousedown', function() {\n    \n    var x= $(this).css(\"background-color\");\n    $(this).css(\"background-color\", \"yellow\");\n    \n    setTimeout(restore_bg.bind(this,x),100);\n    navigator.vibrate(80);\n    });\n    \n</script>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":590,"y":420,"wires":[[]]},{"id":"f5766232.46e9a","type":"change","z":"fc9cadf6.aa34","name":"pause","rules":[{"t":"set","p":"musicobj.action","pt":"global","to":"pause","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"pause","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":520,"wires":[["a5b42140.bcd47"]]},{"id":"a5b42140.bcd47","type":"link out","z":"fc9cadf6.aa34","name":"Play/pause","links":["c63d5f3.936222"],"x":675,"y":540,"wires":[]},{"id":"42d4fbae.47ade4","type":"comment","z":"fc9cadf6.aa34","name":"Stop","info":"","x":150,"y":660,"wires":[]},{"id":"af2d5888.7d461","type":"comment","z":"fc9cadf6.aa34","name":"Previous Song","info":"","x":180,"y":420,"wires":[]},{"id":"a4f34f95.9009b","type":"comment","z":"fc9cadf6.aa34","name":"Play/Pause sound","info":"This section handles the Play/Pause switch.\n\nWhen a song is selected (above) the song is started and then\nimmediately paused. Because of this, 'play' is actually 'resume'.\n\nAt startup, the global that holds the play/pause value is empty\nso it defaults to \nWhen the button is pressed, ","x":190,"y":500,"wires":[]},{"id":"6432f2da.1a532c","type":"comment","z":"fc9cadf6.aa34","name":"Next Song","info":"","x":160,"y":580,"wires":[]},{"id":"ab4d5643.c280e","type":"ui_button","z":"fc9cadf6.aa34","name":"","group":"ba55d933.7a32d","order":4,"width":"6","height":"1","passthru":false,"label":"Stop","tooltip":"","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":150,"y":700,"wires":[["dfef1196.c89ca8"]]},{"id":"b76d2885.13851","type":"link out","z":"fc9cadf6.aa34","name":"Stop","links":["c63d5f3.936222"],"x":675,"y":700,"wires":[]},{"id":"dfef1196.c89ca8","type":"change","z":"fc9cadf6.aa34","name":"Stop","rules":[{"t":"set","p":"musicobj.action","pt":"global","to":"stop","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":700,"wires":[["b76d2885.13851"]]},{"id":"c4b3bff.1edba4","type":"change","z":"fc9cadf6.aa34","name":"next","rules":[{"t":"set","p":"musicobj.action","pt":"global","to":"next","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"next","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":620,"wires":[["ef5d2a88.34d878"]]},{"id":"ba420b5f.51384","type":"change","z":"fc9cadf6.aa34","name":"previous","rules":[{"t":"set","p":"musicobj.action","pt":"global","to":"previous","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":460,"wires":[["a2ff1cfa.cf13b8"]]},{"id":"a2ff1cfa.cf13b8","type":"link out","z":"fc9cadf6.aa34","name":"to previous","links":["c63d5f3.936222"],"x":675,"y":460,"wires":[]},{"id":"38a98dff.91616a","type":"switch","z":"fc9cadf6.aa34","name":"Flip","property":"musicobj.action","propertyType":"global","rules":[{"t":"eq","v":"resume","vt":"str"},{"t":"eq","v":"initilize","vt":"str"},{"t":"eq","v":"play","vt":"str"},{"t":"eq","v":"next","vt":"str"},{"t":"eq","v":"previous","vt":"str"},{"t":"eq","v":"pause","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":7,"x":350,"y":540,"wires":[["f5766232.46e9a"],["f5766232.46e9a"],["f5766232.46e9a"],["f5766232.46e9a"],["f5766232.46e9a"],["6a402168.1f4798"],["6a402168.1f4798"]]},{"id":"6a402168.1f4798","type":"change","z":"fc9cadf6.aa34","name":"play (resume)","rules":[{"t":"set","p":"musicobj.action","pt":"global","to":"resume","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"resume","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":560,"wires":[["a5b42140.bcd47"]]},{"id":"30c2c3c5.e3113c","type":"delay","z":"fc9cadf6.aa34","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":360,"y":620,"wires":[["c4b3bff.1edba4"]]},{"id":"ef5d2a88.34d878","type":"link out","z":"fc9cadf6.aa34","name":"to 'song end' check","links":["c63d5f3.936222"],"x":675,"y":620,"wires":[]},{"id":"f6e6fd41.1d1e88","type":"delay","z":"fc9cadf6.aa34","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":360,"y":460,"wires":[["ba420b5f.51384"]]},{"id":"4b63585c.8a9a9","type":"change","z":"79bc540c.0c3a9c","name":"Get prior song ","rules":[{"t":"set","p":"musicobj.songindex","pt":"global","to":"$globalContext(\"musicobj.songindex\") - 1","tot":"jsonata"},{"t":"set","p":"musicobj.songindex","pt":"global","to":"($globalContext(\"musicobj.songindex\")  >= 0)  ?  $globalContext(\"musicobj.songindex\") : $globalContext(\"musicobj.songcount\") - 1\t","tot":"jsonata"},{"t":"set","p":"song_name","pt":"msg","to":"$globalContext(\"musicobj.songlist\")[$globalContext(\"musicobj.songindex\")]","tot":"jsonata"},{"t":"set","p":"musicobj.action","pt":"global","to":"play","tot":"str"},{"t":"set","p":"musicobj.songplaying","pt":"global","to":"song_name","tot":"msg"},{"t":"set","p":"audioURI","pt":"msg","to":"\"/home/pi/songs/\"&song_name","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"start","tot":"str"},{"t":"set","p":"options","pt":"msg","to":"{\"afplay\": [ \"-r\", 0.5, \"-t\", 2.5, \"-v\", 1 ], \"mplayer\": [ \"-volume\", 1 ] }","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":200,"wires":[["3073566.5ed4b2a","d152f33c.443b38"]]},{"id":"f6362be6.01b238","type":"ui_button","z":"8f32add9.664b98","name":"","group":"e25e5394.01e018","order":1,"width":0,"height":0,"passthru":false,"label":"Power off Pi","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":150,"y":80,"wires":[["2f93c722.c14bd8"]]},{"id":"7c4a7eab.70a7c8","type":"comment","z":"7668a1d4.ba0de8","name":"ReadMe Music Player v1.0.0","info":"This music player reads a folder (called 'songs') and will play the songs in alphabetical order. \nOnce all teh songs have been played, it will restart the list. \n\nYou can Pause/Resume play, Skip to the next song, go to the previous song and stop playing any songs.\n\nThere is also a button to power off the Pi.\n\nI designed this to allow it to be controled by an iPhone by turning on\nthe iPhone's Personal hotspot. To access it this way, you need to add teh iPhone Hotspot name\nand password to the wpa_supplicant.config file on the Pi. ","x":200,"y":60,"wires":[]},{"id":"770d870f.d868c","type":"change","z":"79bc540c.0c3a9c","name":"get next song","rules":[{"t":"set","p":"musicobj.songindex","pt":"global","to":"($globalContext(\"musicobj.songindex\")+1) > ($globalContext(\"musicobj.songcount\")-1) ? 0 : $globalContext(\"musicobj.songindex\")+1","tot":"jsonata"},{"t":"set","p":"song_name","pt":"msg","to":"$globalContext(\"musicobj.songlist\")[$globalContext(\"musicobj.songindex\")]","tot":"jsonata"},{"t":"set","p":"musicobj.action","pt":"global","to":"play","tot":"str"},{"t":"set","p":"musicobj.songplaying","pt":"global","to":"song_name","tot":"msg"},{"t":"set","p":"audioURI","pt":"msg","to":"\"/home/pi/songs/\"&song_name\t","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"start","tot":"str"},{"t":"set","p":"options","pt":"msg","to":"{\"afplay\": [ \"-r\", 0.5, \"-t\", 2.5, \"-v\", 1 ], \"mplayer\": [ \"-volume\", 1 ] }","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":240,"wires":[["d152f33c.443b38","3073566.5ed4b2a"]]},{"id":"4fb73c0c.cd629c","type":"change","z":"79bc540c.0c3a9c","name":"set global action","rules":[{"t":"set","p":"musicobj.action","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":380,"wires":[["2f4f8361.0b5314"]]},{"id":"3f1e62b9.8341d6","type":"change","z":"79bc540c.0c3a9c","name":"set action","rules":[{"t":"set","p":"payload","pt":"msg","to":"musicobj.action","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":280,"wires":[["d152f33c.443b38"]]},{"id":"f8a1ca34.14de6","type":"comment","z":"79bc540c.0c3a9c","name":"send response from playsound back to actions","info":"","x":840,"y":340,"wires":[]},{"id":"9565a26d.e41a7","type":"comment","z":"79bc540c.0c3a9c","name":"send response from playsound back to actions","info":"","x":300,"y":160,"wires":[]},{"id":"58a1954.91fb76c","type":"comment","z":"79bc540c.0c3a9c","name":"Watch for unexpected errors","info":"","x":240,"y":340,"wires":[]},{"id":"aa3d0095.3d8728","type":"comment","z":"79bc540c.0c3a9c","name":"This is the music engine processing all the buttons","info":"","x":570,"y":80,"wires":[]},{"id":"c4b3631c.f10ba","type":"comment","z":"fc9cadf6.aa34","name":"This code handles the dashboard volume controls and uses and EXEC to call AMIXER","info":"","x":400,"y":40,"wires":[]},{"id":"5a7cfa43.d79a8c","type":"comment","z":"fc9cadf6.aa34","name":"This code handles the dashboard player controls","info":"","x":280,"y":380,"wires":[]},{"id":"94813c7.350ec4","type":"comment","z":"8f32add9.664b98","name":"Two ways to shutdown the Pi","info":"","x":200,"y":40,"wires":[]},{"id":"6d926a60.c0e1ac","type":"debug","z":"fc9cadf6.aa34","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":290,"y":320,"wires":[]}]
1 Like

danke dir! amazing flow ! I ve much to learn :slight_smile:
... I changed the path and the player seems that it has loaded the my .mp3
but sadly the player doesn t play the song / at least the analog output of the raspi is silence.
picture

Have you checked to make sure amixer is installed and working on the pi?
have you enabled the debug node conne ted to the PlaySound node?
Are you seeing any messages?
What version of NR, and node.js are you using?

amixer is installed.
Node.js is v10.16.2
NR is v0.20.7
playsound is "playing" in the NR view.
I will post debug out later when home :slight_smile:

good, but did you make sure it is working in CLI?

Nice topic!
How can I play a simple TTS audio on another raspi with the Node "play sound"?
In the topic, it seems to me that the audio output is located locally on the raspi.

So you want Pi A to play sounds on Pi B?

Or do you mean you want to play it in the browser connected to the one running node-red?

You're right @zenofmud. I want to play TTS from PI A to Pi B via LAN. The PI B has some speakers connect. I only need to play some TTS. Maybe I need anouther node?

Not sure in what way this is a node-red issue. First you need to find if it is possible to make a pi play sound generated on another pi. Then work out how to implement it on node red.

There is an audio out node for dashboard that can do TTS, but a lot of browsers now don’t allow playback by default so there may be a setting that needs to be set to allow it.

I understood that @Smarty was not trying to play the sound in the browser (I asked that specific question) but on another Pi not running browser or node red.

1 Like

Use the exec node to run a simple script like this:
#!/bin/bash
play /home/pi/Music/ghostbusters.mp3
You may need to install sox first.

1 Like

Now I come back to this :slight_smile:
I still cant get it work... amixer, mplay installed.
no errors on debug node found. It will just stay silent when pressing play button.
aplay in CLI will not work to but "at least" I get some 56k-modem-like noise (no real sound) and this line:

pi@raspberrypi:~ $ aplay /home/pi/Downloads/1.mp3 
Playing raw data '/home/pi/Downloads/1.mp3' : Unsigned 8 bit, Rate 8000 Hz, Mono

The shown mp3-file infos are incorrect. ^^

Hmm I just installed on another pi and I gett no sound either.
However I installed sox and lame
sudo apt install sox
sudo apt install lame
and I can get output using lame --decode songs/horse.mp3 - | play -
Note: I also forced output to the headphone jack using

sudo rapsi-config
7 Advanced Options
A4 Audio Options
1 Force 3.5mm ('headphone') jack

I'll dig into this more as the day goes on, but I have some outside work to do ahead of the snow storm coming later today.

Ok, I think I know why you just hear static/noise like a modem. Aplay will try to read the header of the sound file to determine what to do with it.

You should install mplayer on your Pi, that is what my project tells the Play-Sound node to use.
sudo apt install mplayer
see if that helps.

Thanx for your advise ! I think I found the problem. It is related to the system volume control.
Every time I start a new song by pressing play or the forward/backward button for the next/previous song the system volume level changes to zero or near zero that I hear no sound. - I ve to go to the desktop an pull it up to hear something.