Hi there guys,
I'm trying to setup a simple text-to-speech function in Windows using powershell, but i'm somehow failing miserably.
I've managed to create a flow that works:
[
{
"id": "8fc0ac7099b7175f",
"type": "change",
"z": "73264e222aeaf471",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "\"powershell -NoProfile -command \\\"Add-Type -AssemblyName System.speech; $speak = New-Object System.Speech.Synthesis.SpeechSynthesizer; $speak.SpeakSsml(\" & $.payload & \")\\\"\"",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 520,
"y": 320,
"wires": [
[
"d0814fabfbee02ef"
]
]
},
{
"id": "d0814fabfbee02ef",
"type": "exec",
"z": "73264e222aeaf471",
"command": "",
"addpay": "payload",
"append": "",
"useSpawn": "",
"timer": "",
"winHide": false,
"name": "TTS",
"x": 750,
"y": 320,
"wires": [
[
"ef75f9ba76381361"
],
[
"ef75f9ba76381361"
],
[
"ef75f9ba76381361"
]
]
},
{
"id": "ef75f9ba76381361",
"type": "debug",
"z": "73264e222aeaf471",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 950,
"y": 320,
"wires": []
},
{
"id": "84d2cfb3f19d50b9",
"type": "inject",
"z": "73264e222aeaf471",
"name": "",
"props": [
{
"p": "payload",
"v": "",
"vt": "str"
},
{
"p": "topic",
"v": "",
"vt": "string"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "str",
"x": 170,
"y": 320,
"wires": [
[
"ca096792549bd376"
]
]
},
{
"id": "ca096792549bd376",
"type": "template",
"z": "73264e222aeaf471",
"name": "set payload",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "plain",
"template": "'<speak version=\\\"1.0\\\" xmlns=\\\"http://www.w3.org/2001/10/synthesis\\\" xml:lang=\\\"pt-BR\\\"><voice name=\\\"pt-BR-FranciscaNeural\\\"><prosody rate=\\\"1\\\"><p><prosody pitch=\\\"x-high\\\"> Testing TTS </prosody></p></prosody></voice></speak>'",
"output": "str",
"x": 330,
"y": 320,
"wires": [
[
"8fc0ac7099b7175f"
]
]
}
]
But this has the message built inside the payload. I want to inject the message from another node, like an inject node, for example, but then the command fails:
[
{
"id": "ac2b24e822dd8318",
"type": "exec",
"z": "73264e222aeaf471",
"command": "",
"addpay": "payload",
"append": "",
"useSpawn": "",
"timer": "",
"winHide": false,
"name": "TTS",
"x": 750,
"y": 440,
"wires": [
[
"d22a6033c7d23a0f"
],
[
"d22a6033c7d23a0f"
],
[
"d22a6033c7d23a0f"
]
]
},
{
"id": "d22a6033c7d23a0f",
"type": "debug",
"z": "73264e222aeaf471",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 930,
"y": 440,
"wires": []
},
{
"id": "ef038e214b8a2065",
"type": "change",
"z": "73264e222aeaf471",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "\"'<speak version=\\\"1.0\\\" xmlns=\\\"http://www.w3.org/2001/10/synthesis\\\" xml:lang=\\\"pt-BR\\\"><voice name=\\\"pt-BR-FranciscaNeural\\\"><prosody rate=\\\"1\\\"><p><prosody pitch=\\\"x-high\\\"> \" & $.payload & \"</prosody></p></prosody></voice></speak>'\"",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 380,
"y": 440,
"wires": [
[
"ab199d7bb8d6aec8"
]
]
},
{
"id": "7cf28b0fe0bda564",
"type": "inject",
"z": "73264e222aeaf471",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "Testing TTS",
"payloadType": "str",
"x": 190,
"y": 440,
"wires": [
[
"ef038e214b8a2065"
]
]
},
{
"id": "ab199d7bb8d6aec8",
"type": "change",
"z": "73264e222aeaf471",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "\"powershell -NoProfile -command \\\"Add-Type -AssemblyName System.speech; $speak = New-Object System.Speech.Synthesis.SpeechSynthesizer; $speak.SpeakSsml(\" & $.payload & \")\\\"\"",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 580,
"y": 440,
"wires": [
[
"ac2b24e822dd8318"
]
]
}
]
When executing this flow, it shows in the debug panel:
Exception calling "SpeakSsml" with "1" argument(s): "XML content not valid."
At line:1 char:102
+ ... ynthesizer; $speak.SpeakSsml('<speak version=1.0 xmlns=http://www.w3. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FormatException
and also:
Command failed: powershell -NoProfile -command "Add-Type -AssemblyName System.speech; $speak = New-Object System.Speech.Synthesis.SpeechSynthesizer; $speak.SpeakSsml('<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="pt-BR"><voice name="pt-BR-FranciscaNeural"><prosody rate="1"><p><prosody pitch="x-high"> Testing TTS</prosody></p></prosody></voice></speak>')"
Exception calling "SpeakSsml" with "1" argument(s): "XML content not valid."
At line:1 char:102
+ ... ynthesizer; $speak.SpeakSsml('<speak version=1.0 xmlns=http://www.w3. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FormatException
What am i doing wrong?