Skip to content

Instantly share code, notes, and snippets.

@VeronicaM
Created April 15, 2019 23:56
Show Gist options
  • Save VeronicaM/33cdf823a9f0177c8a87c9128eca620e to your computer and use it in GitHub Desktop.
Save VeronicaM/33cdf823a9f0177c8a87c9128eca620e to your computer and use it in GitHub Desktop.
Utter word in course language with Web Speech API
const courseLang = CurrentUserService.getLangCourseCode();
const voice = SpeechSynthesisService.getVoices().find((voice) => voice.lang.indexOf(courseLang) > -1);
SpeechSynthesisService.speak(this.props.value, {
lang: courseLang,
voice: voice.name,
rate: 1.0,
pitch: 1.0,
volume: 1.0
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment