-
Notifications
You must be signed in to change notification settings - Fork 2
/
mashup-watson-translator+text-speech.json
1 lines (1 loc) · 3.54 KB
/
mashup-watson-translator+text-speech.json
1
[{"id":"3a08ad8d.17a6e2","type":"http in","z":"91a7801b.eea3f","name":"","url":"/translate_speech","method":"post","swaggerDoc":"","x":123,"y":106,"wires":[["8dcd74a3.895488"]]},{"id":"74173a8d.657a64","type":"watson-translate","z":"91a7801b.eea3f","name":"","action":"translate","basemodel":"ar-en","domain":"conversational","srclang":"en","destlang":"fr","password":"udT15XTbhUAR","custom":"","domainhidden":"conversational","srclanghidden":"en","destlanghidden":"fr","basemodelhidden":"ar-en","customhidden":"","filetype":"forcedglossary","trainid":"","x":330,"y":254,"wires":[["2b18c24.7f4313e","70e0192e.470478"]]},{"id":"8dcd74a3.895488","type":"function","z":"91a7801b.eea3f","name":"","func":"msg.payload = msg.req.body.text;\nmsg.target = msg.req.body.target;\nmsg.source = msg.req.body.source;\nreturn msg;","outputs":1,"noerr":0,"x":237,"y":180,"wires":[["74173a8d.657a64"]]},{"id":"2b18c24.7f4313e","type":"watson-text-to-speech","z":"91a7801b.eea3f","name":"","lang":"french","voice":"fr-FR_ReneeVoice","format":"audio/wav","x":549,"y":344,"wires":[["f2fef09a.34dd"]]},{"id":"54625ae8.d86764","type":"websocket out","z":"91a7801b.eea3f","name":"","server":"28ad337e.a5743c","client":"","x":728.0908813476562,"y":537.727294921875,"wires":[]},{"id":"b1f9738d.f0157","type":"http in","z":"91a7801b.eea3f","name":"","url":"/translate_speech_audio","method":"get","swaggerDoc":"","x":183.81817626953125,"y":736.3636474609375,"wires":[["99e2fa06.f3e5f8"]]},{"id":"552b1e06.0eb0d","type":"http response","z":"91a7801b.eea3f","name":"","x":601.3636474609375,"y":733.6363525390625,"wires":[]},{"id":"99e2fa06.f3e5f8","type":"template","z":"91a7801b.eea3f","name":"","field":"","fieldType":"msg","syntax":"mustache","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":419.81817626953125,"y":737.3636474609375,"wires":[["552b1e06.0eb0d"]]},{"id":"f2fef09a.34dd","type":"function","z":"91a7801b.eea3f","name":"","func":"msg.payload = msg.speech;\nreturn msg;","outputs":1,"noerr":0,"x":617.8181762695312,"y":444.5454406738281,"wires":[["54625ae8.d86764"]]},{"id":"70e0192e.470478","type":"http response","z":"91a7801b.eea3f","name":"","x":581,"y":254,"wires":[]},{"id":"28ad337e.a5743c","type":"websocket-listener","path":"/ws/audio","wholemsg":"false"}]