# Help with TEMPLATE node

**URL:** <https://discourse.nodered.org/t/help-with-template-node/83262>\
**Category:** General\
**Created:** [28 November 2023 20:56 UTC](https://discourse.nodered.org/t/help-with-template-node/83262 "2023-11-28T20:56:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 November 2023 20:56 UTC](https://discourse.nodered.org/t/help-with-template-node/83262/1 "2023-11-28T20:56:36Z")

</div>

I am wanting to inject something like this:

`volume=-12dB`

When it is put through the `template` node I am getting this (extract)  
`-af "volume&#x3D;0db"`

The `-` is replaced with `&#x3D'`  
(or is it the `=-` that is messing things up?)

Not really wanted.

Sorry, but I can't find/remember how to do this exactly.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [28 November 2023 21:03 UTC](https://discourse.nodered.org/t/help-with-template-node/83262/2 "2023-11-28T21:03:57Z")

</div>

Hi @Trying_to_learn

Without seeing the template content, I think you need to use 3 brackets, instead of 2

`{{payload}}` vs `{{{payload}}}`

3 brackets stops it from escaping special characters

I could be wrong of course

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 November 2023 21:06 UTC](https://discourse.nodered.org/t/help-with-template-node/83262/3 "2023-11-28T21:06:31Z")

</div>

(Guess on what I am working.) 😉

I'm nearly there now.

But still not sure it will work.

I am only at getting the template correct.

What the `exec` node will make of it is an entirely different/new thing.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [28 November 2023 21:25 UTC](https://discourse.nodered.org/t/help-with-template-node/83262/4 "2023-11-28T21:25:32Z")

</div>

(_This isn't fair_)

Not you.

But how it all works.

I am stuck between a rock and hard place.

Arcing back to my `TTS` problem.

I've found the command options to control the volume of `ffmpeg` when playing a file.  
(I hope)  
So the command looks _sound_ (pardon the pun) but I am not getting it to work.  
Putting a `debug` node on the output it looks alright.  
But I don't hear anything.

I can't really (or don't know how to) test it from the `terminal` of the remote (headless) machine.

This is what I have now.

```auto
[{"id":"5c18a1879c3fb946","type":"ttsultimate","z":"235f16ee6e459f2c","name":"","voice":"en-AU","ssml":false,"sonosipaddress":"192.168.1.109","sonosvolume":"30","sonoshailing":"0","config":"557d8082.eb5a8","property":"payload","propertyType":{},"rules":[],"playertype":"noplayer","speakingrate":"","speakingpitch":"","unmuteIfMuted":false,"elevenlabsStability":"","elevenlabsSimilarity_boost":"","x":3350,"y":1150,"wires":[["e0d1d13cca74b4e5"],[]]},{"id":"49fe9520d7455acf","type":"inject","z":"235f16ee6e459f2c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello there","payloadType":"str","x":3280,"y":1220,"wires":[["5c18a1879c3fb946"]]},{"id":"e0d1d13cca74b4e5","type":"switch","z":"235f16ee6e459f2c","name":"","property":"filesArray","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":3500,"y":1150,"wires":[["6dcf944e40d84d7f"]]},{"id":"6dcf944e40d84d7f","type":"change","z":"235f16ee6e459f2c","name":"-12","rules":[{"t":"set","p":"volume","pt":"msg","to":"-12","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":3630,"y":1150,"wires":[["180cac7d01f18109"]]},{"id":"180cac7d01f18109","type":"function","z":"235f16ee6e459f2c","name":"function 15","func":"msg.payload = msg.filesArray[0].file;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3800,"y":1040,"wires":[["aeb8a5ea2cedced4","89ae14c79347b072"]]},{"id":"dc5b0685e89a38fd","type":"change","z":"235f16ee6e459f2c","name":"0db","rules":[{"t":"set","p":"volume","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":3640,"y":1060,"wires":[["180cac7d01f18109"]]},{"id":"e4ad0d971cae4654","type":"change","z":"235f16ee6e459f2c","name":"+3","rules":[{"t":"set","p":"volume","pt":"msg","to":"3","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":3630,"y":1260,"wires":[["180cac7d01f18109"]]},{"id":"aeb8a5ea2cedced4","type":"template","z":"235f16ee6e459f2c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}} -af \"volume={{volume}}dB\" -f wav - | DISPLAY=:0 aplay","output":"str","x":3970,"y":1020,"wires":[["8629bda419932c92"]]},{"id":"89ae14c79347b072","type":"exec","z":"235f16ee6e459f2c","command":"ffmpeg -i","addpay":"payload","append":"-f wav - | DISPLAY=:0 aplay ","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":3980,"y":1110,"wires":[[],[],[]]},{"id":"fcf61de15ab84c8e","type":"switch","z":"235f16ee6e459f2c","name":"","property":"filesArray","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":3510,"y":1040,"wires":[["dc5b0685e89a38fd"]]},{"id":"ef63e2bf8cb30c92","type":"switch","z":"235f16ee6e459f2c","name":"","property":"filesArray","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":3500,"y":1260,"wires":[["e4ad0d971cae4654"]]},{"id":"8629bda419932c92","type":"debug","z":"235f16ee6e459f2c","name":"debug 9","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":4140,"y":1020,"wires":[]},{"id":"4fd53652fa2a7941","type":"ttsultimate","z":"235f16ee6e459f2c","name":"","voice":"en-AU","ssml":false,"sonosipaddress":"192.168.1.109","sonosvolume":"30","sonoshailing":"0","config":"557d8082.eb5a8","property":"payload","propertyType":{},"rules":[],"playertype":"noplayer","speakingrate":"","speakingpitch":"","unmuteIfMuted":false,"elevenlabsStability":"","elevenlabsSimilarity_boost":"","x":3360,"y":1040,"wires":[["fcf61de15ab84c8e"],[]]},{"id":"922d332ef377b798","type":"ttsultimate","z":"235f16ee6e459f2c","name":"","voice":"en-AU","ssml":false,"sonosipaddress":"192.168.1.109","sonosvolume":"30","sonoshailing":"0","config":"557d8082.eb5a8","property":"payload","propertyType":{},"rules":[],"playertype":"noplayer","speakingrate":"","speakingpitch":"","unmuteIfMuted":false,"elevenlabsStability":"","elevenlabsSimilarity_boost":"","x":3350,"y":1260,"wires":[["ef63e2bf8cb30c92"],[]]},{"id":"c41a891876e7e97d","type":"inject","z":"235f16ee6e459f2c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello there","payloadType":"str","x":3290,"y":1110,"wires":[["4fd53652fa2a7941"]]},{"id":"7f3abb61038637e5","type":"inject","z":"235f16ee6e459f2c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello there","payloadType":"str","x":3280,"y":1330,"wires":[["922d332ef377b798"]]},{"id":"0966946ed06cc3f8","type":"exec","z":"235f16ee6e459f2c","command":"ffmpeg -i","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":4140,"y":1070,"wires":[[],[],[]]},{"id":"bf61456b0ab0b571","type":"inject","z":"235f16ee6e459f2c","name":"","props":[{"p":"payload"},{"p":"something","v":"-12","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"payload","payloadType":"str","x":3850,"y":1290,"wires":[["bb8467bab5e8a033"]]},{"id":"bb8467bab5e8a033","type":"template","z":"235f16ee6e459f2c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{{payload}}} -af \"volume={{something}}dB\"","output":"str","x":4050,"y":1290,"wires":[["1d75070cea065d29"]]},{"id":"1d75070cea065d29","type":"debug","z":"235f16ee6e459f2c","name":"debug 10","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":4290,"y":1290,"wires":[]},{"id":"afa186a13b1df202","type":"inject","z":"235f16ee6e459f2c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello there","payloadType":"str","x":3300,"y":990,"wires":[["23ca465dc505edb7"]]},{"id":"23ca465dc505edb7","type":"ttsultimate","z":"235f16ee6e459f2c","name":"","voice":"en-AU","ssml":false,"sonosipaddress":"192.168.1.109","sonosvolume":"30","sonoshailing":"0","config":"557d8082.eb5a8","property":"payload","propertyType":{},"rules":[],"playertype":"noplayer","speakingrate":"","speakingpitch":"","unmuteIfMuted":false,"elevenlabsStability":"","elevenlabsSimilarity_boost":"","x":3370,"y":920,"wires":[["b5987bbb64a341d2"],[]]},{"id":"b5987bbb64a341d2","type":"switch","z":"235f16ee6e459f2c","name":"","property":"filesArray","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":3520,"y":920,"wires":[["3dcee35ef0f08cb1"]]},{"id":"3dcee35ef0f08cb1","type":"function","z":"235f16ee6e459f2c","name":"function 14","func":"msg.payload = msg.filesArray[0].file;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3660,"y":920,"wires":[["9ef912cce16e2209"]]},{"id":"9ef912cce16e2209","type":"exec","z":"235f16ee6e459f2c","command":"ffmpeg -i","addpay":"payload","append":"-af \"volume=-12dB\" -f wav - | DISPLAY=:0 aplay ","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":3830,"y":920,"wires":[[],[],[]]},{"id":"557d8082.eb5a8","type":"ttsultimate-config","name":"googletranslate","noderedipaddress":"127.0.0.1","noderedport":"1980","purgediratrestart":"leave","ttsservice":"googletranslate","TTSRootFolderPath":""}]

```

Picture:

 ![Screenshot from 2023-11-29 08-17-35](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/28c8947ab6d4e2a1cd870080e1e40aea8a51a567.png)

The _base line_ works. But no sound/volume control.  
Quick trip to the YELLOW nodes.  
This modifies the command and includes the `volume` part. (See outputs in `debug`)  
But when I change the `exec` node from the working one to the RED one, I hear silence.

I don't know how to PROVE the new command structure/syntax works, but see:

> **[How to Adjust Volume Using FFmpeg (Volume, DRC, Normalization included) -...](https://ottverse.com/how-to-adjust-volume-using-ffmpeg-drc-normalization/)**
>
> In this blog post, we will explain the concept of volume, how to adjust volume using FFmpeg, and some of the problems that you may encounter while doing so.

It maybe nice if I know how to invoke the `TTS` from the other machine's CLI and make sure it works at that level.

Sorry if this is getting _OFF TOPIC_ for the thread, but as I said: I'm stuck between a rock and hard place as I know SFA about what I am doing.

# SORRY!

I just found the mistake.

I forgot to the the 3 `{}` around the `payload.`

Working now.

SO SORRY @marcus-j-davies.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [28 November 2023 21:30 UTC](https://discourse.nodered.org/t/help-with-template-node/83262/5 "2023-11-28T21:30:33Z")

</div>

Sadly, I don’t do much (anything) with ffmpeg.

So my attempt at understanding it, will be an all in bet of making it worse.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [12 December 2023 21:30 UTC](https://discourse.nodered.org/t/help-with-template-node/83262/6 "2023-12-12T21:30:36Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
