Ivona example (plays on Windows),

Acknowledgement goes to Peter Scargill for publishing this on his blog for a raspberry PI. His original work is here http://tech.scargill.net/speech-the-final-frontier/ From which the code has been adapted to work with Windows using Videolan.

[{"id":"968e878c.595b5","type":"ivona-credentials","name":"ivona","api_key":"GDNAIZON36CJ3Z2LPLWQ","password":"sxpMBamnL1bpKf/epIcP/qF/40m2mibFiNs430R4"},{"id":"82e23eae.e1dbe","type":"inject","name":"Warning plus text","topic":"alert","payload":"Attention Humans, this is your computer speaking","payloadType":"string","repeat":"","crontab":"","once":false,"x":108,"y":132,"z":"570731d5.58809","wires":[["246f940e.610014"]]},{"id":"c754d72a.f83578","type":"inject","name":"Just text","topic":"","payload":"Set phasers on stun","payloadType":"string","repeat":"","crontab":"","once":false,"x":115,"y":189,"z":"570731d5.58809","wires":[["246f940e.610014"]]},{"id":"7a3d9309.b169cc","type":"ivona-tts","name":"","message":"{{payload}}","voice":"6","exec":"del C:\\Users\\Public\\Documents\\dummy.mp3","dir":"C:\\Users\\Public\\Documents\\ivona.mp3","broker":"968e878c.595b5","x":130,"y":477,"z":"570731d5.58809","wires":[["4c4fa474.6895b4"]]},{"id":"4c4fa474.6895b4","type":"function","name":"copy file to payload","func":"msg.payload=msg.file;\nreturn msg; ","outputs":1,"noerr":0,"x":321,"y":477,"z":"570731d5.58809","wires":[["40bbd537.4a1494"]]},{"id":"f48c8d8a.033088","type":"function","name":"Clear Busy Flag","func":"context.global.speech_busy=0;\nmsg.payload=\"\"; \nreturn msg; ","outputs":1,"noerr":0,"x":587,"y":481,"z":"570731d5.58809","wires":[["246f940e.610014"]]},{"id":"40bbd537.4a1494","type":"exec","command":"\"C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe\" --one-instance --intf dummy ","addpay":true,"append":"","useSpawn":"","name":"VLC","x":460,"y":345,"z":"570731d5.58809","wires":[["98496409.a08c2"],[],[]]},{"id":"98496409.a08c2","type":"exec","command":"del C:\\Users\\public\\documents\\ivona.mp3","addpay":true,"append":"","useSpawn":"","name":"Delete","x":626,"y":332,"z":"570731d5.58809","wires":[["f48c8d8a.033088"],[],[]]},{"id":"246f940e.610014","type":"function","name":"Process Text and Alarm","func":"var frompush=0;\nif (typeof context.arr == \"undefined\" || !(context.arr instanceof Array)) context.arr = [];\nif (typeof context.global.speech_busy == \"undefined\") context.global.speech_busy=0;\nif ((msg.payload===\"\")&&(context.global.speech_busy===0))\n    if (context.arr.length)\n        {\n            frompush=1;\n            msg.payload=context.arr.shift(); \n        }\n\nif (msg.payload !== \"\")\n    {\n\t\t// just push but not recursively\n    if (frompush === 0)\n        {\n            if (msg.topic.indexOf(\"alert\") != -1)  context.arr.push(\"*alert*\");\n            context.arr.push(msg.payload);\n            return;\n        }\n       \n    // either from the stack or urgent.\n    if (msg.payload.indexOf(\".mp3\")!=-1) { context.global.speech_busy=1; return [null,msg]; }\n\n    // if payload is an mp3 just play it, nothing otherwise check for alert\n\n    if (msg.payload.indexOf(\"*alert*\")!=-1)\n    {\n        var msg2 = {\n                payload : \"\",\n                topic : \"\"\n                };\n        msg2.topic=msg.topic;\n//        msg2.payload='/usr/audio/alert02.mp3';\n         msg2.payload='C:\\\\Users\\\\Public\\\\Documents\\\\alert01.mp3';\n        context.global.speech_busy=1;\n        node.send([null,msg2]); // possibly play an alert\n        return;\n    }\n    context.global.speech_busy=1;\n    node.send([msg,null]); // synth it           \n    };","outputs":"2","noerr":0,"x":224,"y":337,"z":"570731d5.58809","wires":[["7a3d9309.b169cc"],["40bbd537.4a1494"]]},{"id":"59d6fd91.14776c","type":"inject","name":"Empty text every 1 second ","topic":"","payload":"","payloadType":"string","repeat":"1","crontab":"","once":true,"x":171,"y":571,"z":"570731d5.58809","wires":[["246f940e.610014"]]},{"id":"3013e559.607532","type":"comment","name":"Things to do to set up ","info":"**1) Install the IVONA node**\n\nInstall in node-red using *npm install node-red-contrib-ivona*\n\n**2) Install VideoLAN media player** \n\nDownload and install from *http://www.videolan.org/index.html*\n\n**3) Add Warning sound** \n\nAdd a warning sound as *C:\\Users\\Public\\Documents\\alert01.mp3*","x":387,"y":136,"z":"570731d5.58809","wires":[]},{"id":"15d58939.3cbfcf","type":"inject","name":"Just play an MP3 sound file","topic":"","payload":"alert01.mp3","payloadType":"string","repeat":"","crontab":"","once":false,"x":139,"y":75,"z":"570731d5.58809","wires":[["246f940e.610014"]]}]
CurlyWurly-1

Flow Info

created 2 years ago

Node Types

Core
  • comment (x1)
  • exec (x2)
  • function (x3)
  • inject (x4)
Other

Tags

  • Ivona
  • TTS
  • Text
  • Speech
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option