■今回作成したソースコード
今回作成したソースコードは、以下のとおりです。Node-REDは、開発環境の右上メニュー→Import→Clipboardからソースコードを貼り付けられます。
[
{
"id":"e1ab11f8.20f9d",
"type":"debug",
"z":"cd506b08.32af98",
"name":"Text",
"active":true,
"console":"false",
"complete":"transcription",
"x":901,
"y":520,
"wires":[
]
},
{
"id":"13acbb8d.ec5344",
"type":"inject",
"z":"cd506b08.32af98",
"name":"Run",
"topic":"",
"payload":"",
"payloadType":"date",
"repeat":"",
"crontab":"",
"once":false,
"x":218,
"y":461,
"wires":[
[
"4ecad5e1.2d6c2c"
]
]
},
{
"id":"6f7fa92d.b7467",
"type":"rpi-gpio out",
"z":"cd506b08.32af98",
"name":"Relay",
"pin":"12",
"set":"",
"level":"0",
"out":"out",
"x":897,
"y":610,
"wires":[
]
},
{
"id":"4ecad5e1.2d6c2c",
"type":"exec",
"z":"cd506b08.32af98",
"command":"ffmpeg -y -f alsa -i pulse -t 5 -ar 44100 /home/pi/tmp.wav",
"addpay":false,
"append":"",
"useSpawn":"",
"name":"Record voice",
"x":285,
"y":532.5,
"wires":[
[
"73ee56ec.774728"
],
[
"24839754.b2c82"
],
[
"24839754.b2c82"
]
]
},
{
"id":"cd81575e.7535d",
"type":"switch",
"z":"cd506b08.32af98",
"name":"hot?",
"property":"transcription",
"propertyType":"msg",
"rules":[
{
"t":"cont",
"v":"hot",
"vt":"str"
},
{
"t":"else"
}
],
"checkall":"true",
"outputs":2,
"x":629,
"y":613,
"wires":[
[
"3cbccfa.14aa03"
],
[
"c4695fe9.2d6f98"
]
]
},
{
"id":"c4695fe9.2d6f98",
"type":"template",
"z":"cd506b08.32af98",
"name":"OFF",
"field":"payload",
"fieldType":"msg",
"format":"handlebars",
"template":"0",
"x":760,
"y":632,
"wires":[
[
"6f7fa92d.b7467"
]
]
},
{
"id":"3cbccfa.14aa03",
"type":"template",
"z":"cd506b08.32af98",
"name":"ON",
"field":"payload",
"fieldType":"msg",
"format":"handlebars",
"template":"1",
"x":762,
"y":592,
"wires":[
[
"6f7fa92d.b7467"
]
]
},
{
"id":"73ee56ec.774728",
"type":"file in",
"z":"cd506b08.32af98",
"name":"Read voice file",
"filename":"/home/pi/tmp.wav",
"format":"",
"x":470,
"y":520,
"wires":[
[
"ef6dacd9.cac6d8"
]
]
},
{
"id":"24839754.b2c82",
"type":"debug",
"z":"cd506b08.32af98",
"name":"Error",
"active":false,
"console":"false",
"complete":"payload",
"x":464,
"y":569,
"wires":[
]
},
{
"id":"ef6dacd9.cac6d8",
"type":"watson-speech-to-text",
"z":"cd506b08.32af98",
"name":"Watson Speech to Text",
"lang":"en-US",
"band":"BroadbandModel",
"x":689,
"y":519,
"wires":[
[
"e1ab11f8.20f9d",
"cd81575e.7535d"
]
]
}
]