Created
October 23, 2015 13:09
-
-
Save osowski/dc9c9d7d42c68e3717f5 to your computer and use it in GitHub Desktop.
Node-RED flow to use GitHub web hooks to play audio when code is pushed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"id":"d014cd72.2feb3","type":"websocket-listener","path":"/ws/audio","wholemsg":"false"},{"id":"ed3b7433.12c488","type":"watson-text-to-speech","name":"","lang":"english","voice":"en-US_MichaelVoice","x":460,"y":263.9999933242798,"z":"2df11d26.d20ee2","wires":[["1c671986.e398e6"]]},{"id":"4a98cccf.b56734","type":"inject","name":"","topic":"","payload":"Hello my name is James","payloadType":"string","repeat":"","crontab":"","once":false,"x":149.09091186523438,"y":140.72726440429688,"z":"2df11d26.d20ee2","wires":[["9cc01711.633fe8"]]},{"id":"de94b273.216b5","type":"websocket out","name":"","server":"d014cd72.2feb3","client":"","x":811.0908813476562,"y":325.72725772857666,"z":"2df11d26.d20ee2","wires":[]},{"id":"301d54b3.cfe2ac","type":"http in","name":"","url":"/audio","method":"get","swaggerDoc":"","x":190.81817626953125,"y":383.36363220214844,"z":"2df11d26.d20ee2","wires":[["67b82a64.9847d4"]]},{"id":"d7b2d215.284d3","type":"http response","name":"","x":613.3636646270752,"y":391.63634872436523,"z":"2df11d26.d20ee2","wires":[]},{"id":"67b82a64.9847d4","type":"template","name":"","field":"","template":"<!DOCTYPE html>\n<html>\n<head>\n <title>IBM Watson - Text To Speech</title>\n <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js\"></script>\n \n <script type=\"text/javascript\">\n var socketaddy = \"ws://\" + window.location.host + \"/ws/audio\";\n\n $(document).ready(function(){\n var output = document.getElementById('output')\n $('#output').on('playing', function () {\n $('#text').text('Playing audio.')\n \n });\n $('#output').on('ended', function () {\n $('#text').text('Waiting for audio...')\n \n });\n sock = new WebSocket(socketaddy);\n sock.onopen = function(){\n $('#text').text('Waiting for audio...');\n console.log(\"Connected websocket\");\n };\n sock.onerror = function(){ \n console.log(\"Websocket error\"); \n };\n sock.onclose = function () {\n $('#text').text('Not connected. Refresh the page?')\n }\n sock.onmessage = function(evt){\n console.log(\"Websocket message\", evt); \n output.src = window.URL.createObjectURL(evt.data);\n output.play();\n };\n });\n </script>\n \n</head>\n<body style=\"font-size: 56px; font-family: helvetica; text-align: center; margin-top: 100px;\">\n <div id=\"text\">Connecting...</div>\n <audio id=\"output\"></audio>\n</body>\n</html>","x":407.81817626953125,"y":390.36363220214844,"z":"2df11d26.d20ee2","wires":[["d7b2d215.284d3"]]},{"id":"1c671986.e398e6","type":"function","name":"","func":"msg.payload = msg.speech;\nreturn msg;","outputs":1,"noerr":0,"x":649.8181762695312,"y":322.545449256897,"z":"2df11d26.d20ee2","wires":[["de94b273.216b5","a87373a.f578c9"]]},{"id":"73b281.ff8c4d8","type":"http in","name":"","url":"/speak","method":"post","swaggerDoc":"","x":122,"y":48,"z":"2df11d26.d20ee2","wires":[["9cc01711.633fe8"]]},{"id":"a66ced21.59931","type":"function","name":"","func":"msg.payload = \"Push it. Push it real good.\";\nconsole.log(\"push received\");\nreturn msg;","outputs":1,"noerr":0,"x":252,"y":305.9999933242798,"z":"2df11d26.d20ee2","wires":[["ed3b7433.12c488"]]},{"id":"a87373a.f578c9","type":"http response","name":"","x":850,"y":262.9999933242798,"z":"2df11d26.d20ee2","wires":[]},{"id":"e8304d45.17cfb","type":"mqlight in","name":"","service":"MQ Light-rd","topic":"innovation/pushit","share":"","x":127,"y":243,"z":"2df11d26.d20ee2","wires":[["a66ced21.59931"]]},{"id":"d492076b.2b6df8","type":"mqlight out","name":"Publish","service":"MQ Light-rd","topic":"innovation/pushit","x":645,"y":111,"z":"2df11d26.d20ee2","wires":[]},{"id":"82448488.7dbb78","type":"http response","name":"","x":646,"y":161,"z":"2df11d26.d20ee2","wires":[]},{"id":"cbb3dff7.344c2","type":"function","name":"","func":"msg.statusCode = 200;\n\nif(msg.req){\n msg.payload = msg.req.body;\n}\nreturn msg;","outputs":1,"noerr":0,"x":427,"y":165,"z":"2df11d26.d20ee2","wires":[["82448488.7dbb78"]]},{"id":"9cc01711.633fe8","type":"function","name":"","func":"\nreturn msg;","outputs":"1","noerr":0,"x":353,"y":69,"z":"2df11d26.d20ee2","wires":[["d492076b.2b6df8","cbb3dff7.344c2"]]}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Rick
I´m novice using Node-RED. can ypu explain me how the flows works? Thanks a lot!