# Change the TTS voice in a function based on the contents of the message?

**URL:** <https://discourse.nodered.org/t/change-the-tts-voice-in-a-function-based-on-the-contents-of-the-message/87898>\
**Category:** General\
**Tags:** function-node\
**Created:** [12 May 2024 19:49 UTC](https://discourse.nodered.org/t/change-the-tts-voice-in-a-function-based-on-the-contents-of-the-message/87898 "2024-05-12T19:49:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bob](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@Bob](https://discourse.nodered.org/u/Bob)\
**Post date:** [12 May 2024 19:49 UTC](https://discourse.nodered.org/t/change-the-tts-voice-in-a-function-based-on-the-contents-of-the-message/87898/1 "2024-05-12T19:49:19Z")

</div>

I am new to Node-RED and experimenting with functions

What I would like to do is to change the voice used by TTS depending on the content of the message. I can parse the message and determine whether the voice should be changed but how do I change it ?

I am currently using the play audio node but the only way that I can see to change the voice is from the node properties but, of course, this sets the voice for all messages, which is not what I want. I suspect that there may be other nodes available that can do what I want but I can't find one

EDIT : I am experimenting with the switch node which seems to allow me to do what I want

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [13 May 2024 01:23 UTC](https://discourse.nodered.org/t/change-the-tts-voice-in-a-function-based-on-the-contents-of-the-message/87898/2 "2024-05-13T01:23:25Z")

</div>

I also use the switch node to channel the messages to different audio out nodes to play in different voices based on message content.

---

<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:** [11 August 2024 01:24 UTC](https://discourse.nodered.org/t/change-the-tts-voice-in-a-function-based-on-the-contents-of-the-message/87898/3 "2024-08-11T01:24:14Z")

</div>

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