How to use more than one voice in a TTS JavaScript snippet

PerryHS 10 Reputation points
2023-01-13T18:23:23.7933333+00:00

The TTS javascript project I am currently working on needs to use two voices with the ability to be able to switch between these two. However, as far as I can see, I can only configure the synthesizer engine with one voice using speechConfig.speechSynthesisVoiceName = "voice to be used".   Can I configure this for more than one voice, or do I have to create two instances of the synthesizer and call each each one separately? I imagine something like using two different “phraseDiv”s (based on the demo code provided by Azure) for this with possibly an IF statement, but there’s still the issue with the voice assignment.

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,411 questions
Azure AI Language
Azure AI Language
An Azure service that provides natural language capabilities including sentiment analysis, entity extraction, and automated question answering.
359 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. PerryHS 10 Reputation points
    2023-01-23T16:08:20.0133333+00:00

    I solved the problem by creating two separate voice instances in two different modules and calling each of them in turn.

    2 people found this answer helpful.