How to to convert received telegram voice message in a format my vto can play

Hi all, I found this flow on the net and adapted it. The part that receives the text message works perfectly, while the part that receives the audio doesn't, I wanted the audio received, in .oga format, to be directly converted and then played by my vto. What am I doing wrong? Thank you.

[{"id":"1b09da8f0822414c","type":"tab","label":"Telegram legge il testo del bot","disabled":false,"info":"","env":[]},{"id":"66fac65b9f255c2b","type":"http request","z":"1b09da8f0822414c","name":"HTTP Request to Doorbell","method":"PUT","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.111/cgi-bin/audio.cgi?action=postAudio&httptype=singlepart&channel=1","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"basic","senderr":false,"headers":[],"x":980,"y":560,"wires":[[]]},{"id":"01496b2029831626","type":"telegram receiver","z":"1b09da8f0822414c","name":"","bot":"35f43d5f7e1032c3","saveDataDir":"","filterCommands":false,"x":110,"y":220,"wires":[["907d197834c48248","c449c2abcc3dd37b"],[]]},{"id":"8b280b44d6305844","type":"change","z":"1b09da8f0822414c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.content","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":200,"wires":[["1ea2580b.913478"]]},{"id":"a9292bc3e3b8853d","type":"ttsultimate","z":"1b09da8f0822414c","name":"","voice":"it-IT","ssml":false,"sonosipaddress":"192.168.1.158","sonosvolume":"75","sonoshailing":"0","config":"e05dc2be35faa69b","property":"payload","propertyType":{},"rules":[],"playertype":"noplayer","speakingrate":"1","speakingpitch":"0","unmuteIfMuted":true,"x":530,"y":400,"wires":[["3575dc1db9165504","3c06927b352e6a99"],[]]},{"id":"75a9fe0974a682a7","type":"function","z":"1b09da8f0822414c","name":"Parse Filename","func":"msg.filename = String(msg.filesArray[0].file);\nconst ffmpegIn = String(msg.filename);\nconst ffmpegOut = ffmpegIn.split('.').slice(0, -1).join('.');\nconst ffmpeg = \"-y -i \" + ffmpegIn +\" -c:a pcm_alaw -ac 1 -ar 8000 -sample_fmt s16 \" + ffmpegOut + \".wav\";\nmsg.ffmpegIn = ffmpegIn;\nmsg.ffmpegOut = ffmpegOut;\nmsg.ffmpeg = ffmpeg;\nmsg.filename = msg.ffmpegOut+\".wav\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":900,"y":480,"wires":[["fb2029e2b6613325","709cce66ed74f220"]]},{"id":"fb2029e2b6613325","type":"exec","z":"1b09da8f0822414c","command":"/usr/bin/ffmpeg","addpay":"ffmpeg","append":"","useSpawn":"false","timer":"15","winHide":false,"oldrc":false,"name":"Convert Audio","x":1100,"y":480,"wires":[["8088f134238662ea"],[],[]]},{"id":"383c7b0d5210da42","type":"function","z":"1b09da8f0822414c","name":"Build http payload","func":"msg.headers = {};\nmsg.headers['Content-Length'] = \"9999999\"\nmsg.headers['Content-Type'] = \"Audio/G.711A\"\nmsg.headers['User-Agent'] = \"NodeRed\"\nmsg.requestTimeout = 5000\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":650,"y":560,"wires":[["66fac65b9f255c2b"]]},{"id":"8088f134238662ea","type":"file in","z":"1b09da8f0822414c","name":"Read Converted File","filename":"filename","filenameType":"msg","format":"","chunk":false,"sendError":false,"allProps":false,"x":400,"y":560,"wires":[["383c7b0d5210da42"]]},{"id":"3575dc1db9165504","type":"switch","z":"1b09da8f0822414c","name":"Finished Processing","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":740,"y":400,"wires":[["75a9fe0974a682a7"]]},{"id":"85acd2f01fdf1618","type":"link in","z":"1b09da8f0822414c","name":"TTS VTO","links":["1d740cd4495e90ea","d3ba7455514dbb78"],"x":595,"y":140,"wires":[["1ea2580b.913478"]]},{"id":"1ea2580b.913478","type":"function","z":"1b09da8f0822414c","name":"Command remover /","func":"// This function processes the incoming text and tries to determine if it is a \n// specific \"single word\" command like the ones below in the list or\n// other free English commands like \"turn on the garden light\"\n\n// These are the commands (\"reserved words\") that execute a function without parameters\nvar commands = [\"help\",\"camera\",\"me\",\"userlist\",\"loglevel\",\"logmute\",\"weather\",\"youtube\",\"solar\",\"miflora\",\"systeminfo\",\"rain\"];\n\nvar temp = msg.payload;\n\n\n\n// removing rubbish\n//temp = temp.replace(\"\",\"\");\n\n\n\n\n// se è un comando lo annullo\nif (temp.indexOf(\"/\")>-1) {\n    msg = \"\";\n}\n\n\nreturn msg;","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":220,"wires":[["a9292bc3e3b8853d"],[]]},{"id":"c44c702c5ae1e10b","type":"change","z":"1b09da8f0822414c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":460,"wires":[[]]},{"id":"907d197834c48248","type":"switch","z":"1b09da8f0822414c","name":"","property":"payload.type","propertyType":"msg","rules":[{"t":"eq","v":"voice","vt":"str"},{"t":"eq","v":"message","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":220,"wires":[["4747f8bc1b12a1a8"],["8b280b44d6305844"]]},{"id":"c449c2abcc3dd37b","type":"debug","z":"1b09da8f0822414c","name":"debug 11","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":320,"y":320,"wires":[]},{"id":"dbb6d173449d8fcf","type":"debug","z":"1b09da8f0822414c","name":"debug 12","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1520,"y":260,"wires":[]},{"id":"709cce66ed74f220","type":"debug","z":"1b09da8f0822414c","name":"debug 13","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":940,"y":720,"wires":[]},{"id":"3c06927b352e6a99","type":"debug","z":"1b09da8f0822414c","name":"debug 14","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":900,"y":340,"wires":[]},{"id":"af689a244cf2fe43","type":"function","z":"1b09da8f0822414c","name":"Parse Filename","func":"msg.filename = \"prova.wav\";\nconst ffmpegIn = String(msg.filename);\nconst ffmpegOut = ffmpegIn.split('.').slice(0, -1).join('.');\nconst ffmpeg = \"-y -i \" + ffmpegIn +\" -c:a pcm_alaw -ac 1 -ar 8000 -sample_fmt s16 \" + ffmpegOut + \".wav\";\nmsg.ffmpegIn = ffmpegIn;\nmsg.ffmpegOut = ffmpegOut;\nmsg.ffmpeg = ffmpeg;\nmsg.filename = msg.ffmpegOut+\".wav\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1200,"y":360,"wires":[["fb2029e2b6613325"]]},{"id":"4747f8bc1b12a1a8","type":"change","z":"1b09da8f0822414c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.content.filename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":280,"wires":[["75a9fe0974a682a7"]]},{"id":"35f43d5f7e1032c3","type":"telegram bot","botname":"HomeAssistantBot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksprotocol":"socks5","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false},{"id":"e05dc2be35faa69b","type":"ttsultimate-config","name":"TTS Service","noderedipaddress":"192.168.1.138","noderedport":"1980","purgediratrestart":"purge","ttsservice":"googletranslate","TTSRootFolderPath":""}]


image

TypeError: Cannot read properties of undefined (reading '0')

Welcome to the Forum,

I do not use Node-RED for this type of thing, so I have no experience. But, I would suggest you look at the input to the 'Parse Filename node, your error message appears to be coming from there. The debug message suggest the error is coming from there.

Your post reads that you might be a new user, if you aren't I apologise, but if you are, you might gain a lot of knowledge quickly going through this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

  1. care to explain what VTO is? Not everyone knows (me for one)
  2. you state you want to convert the .ohs format but you done say what you want to convert it too.

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