0

The SpeechSynthesisUtterance interface provides two options for setting what voice gets used: voice and lang.

lang takes a language code like en-US or es-ES.

voice takes in a SpeechSynthesisVoice object that you get from speechSynthesis.getVoices().

If both are unset, then the browser's default is used. If lang is unset, it just uses the voice provided. If voice is unset, it finds a SpeechSynthesisVoice that matches lang.

If both are set, but differ in what voice gets played. The lang setting seems to be the overriding factor.

Do I need to have both set? Will something go wrong if I only set the voice setting?

Merlin -they-them-
  • 2,731
  • 3
  • 22
  • 39
  • Is the behaviour not proving constant when you set `none`, `one` or `both`? – brandall Sep 19 '16 at 22:31
  • Behaviour is constant so far. But I guess I'm wondering why they have `lang` and `voice` when `voice` encompasses `lang` – Merlin -they-them- Sep 19 '16 at 23:31
  • It gives you the choice as to whether to define a specific synthesis voice service, or simply use the language tag, if you're not interested in the voices that are available. – brandall Sep 20 '16 at 12:19

0 Answers0