Voice Selector Example
Three tabs, one preview pane. Pick a voice by exact name, by RegExp pattern, or by VoiceQuery — the snippet at the bottom rewrites itself as you switch, so you can see what each form looks like at the speak() call site.
Why three modes
Section titled “Why three modes”The Voice Selection guide explains that the second argument to speak() accepts three shapes — string, RegExp, or VoiceQuery. The advantage of each isn't obvious from prose alone; this example makes it tangible by letting you express the same intent ("an English female voice") three different ways and watch the call site change.
What you'll see
Section titled “What you'll see”- By Name is a filterable list. Pick a row, hit Speak, and the call is
responsiveVoice.speak(text, "Voice Name")— the exact name you clicked. - By Pattern lets you type a regular expression. The example shows every voice whose name matches and highlights the first one — that's the voice the engine will use, since the resolver picks the first match.
- By Query is a structured filter. Set
lang,gender,provider, orisByokand only voices matching every field you set will play.langis a BCP-47 prefix match, soenmatchesen-GB,en-US, and so on. This same JSON-serializable shape is what the Python, Go, PHP, and Java SDKs send to the API. providerandisByok: trueboth find premium voices. Premium voices are voices that play through BYOK (bring-your-own-keys) services like Google Cloud WaveNet, Microsoft Azure Speech, or OpenAI TTS, using API keys you supply. The standard (free) tier has no provider value, so neither field will match a free voice.mulis the language code for multilingual voices. OpenAI TTS voices speak many languages and usemulinstead of a specific code likeen-GB. The language dropdown displays this entry asmul (multilingual)so it's recognizable, but the value passed tospeak()is still the literal"mul".- Bad regex patterns are caught immediately. If you type an invalid pattern, the example shows the syntax error and disables Speak until you fix it.
Next Steps
Section titled “Next Steps”- Voice Selection Guide — the full reference for each selector form
- Voice Resolver Hook — intercept and transform selectors before resolution
- Extended Example — voice selection alongside speech parameter controls