/    Sign up×
Community /Pin to ProfileBookmark

Choose Sex in Text to Speech

Different browsers output different sexes in text to speech, some male some female. Same code. I would like to know how to choose the sex of the voice, please. speech.gender=”female”; does not work, some browsers it still comes out male.

Here is a list of language codes, []https://cloud.google.com/text-to-speech/docs/voices), but the voice names do not work such as en-US-Standard-F. en-US or lv-LV works though.

“`
function textToAudio() {

let speech = new SpeechSynthesisUtterance();

speech.lang = “en-US”;
//speech.gender=”female”;
speech.text = (“Hello”);
speech.volume = 1;
speech.rate = 1;
speech.pitch = 1;
window.speechSynthesis.speak(speech);
}
“`

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @zamber spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...