just do `window.speechSynthesis.getVoices()` to get the list of supported languages by the browser.
const supportedVoices = window.speechSynthesis.getVoices().map((voice) => {
return voice.lang
})
in react you can do
useEffect(() => {
if ('speechSynthesis' in window) {
window.speechSynthesis.onvoiceschanged = () => {
const supportedVoices = window.speechSynthesis.getVoices().map((voice) => {
return voice.lang
})
setSupportedLanguages(supportedVoices)
}
}
}, [])
just do `window.speechSynthesis.getVoices()` to get the list of supported languages by the browser.
const supportedVoices = window.speechSynthesis.getVoices().map((voice) => {
return voice.lang
})
in react you can do
useEffect(() => {
if ('speechSynthesis' in window) {
window.speechSynthesis.onvoiceschanged = () => {
const supportedVoices = window.speechSynthesis.getVoices().map((voice) => {
return voice.lang
})
setSupportedLanguages(supportedVoices)
}
}
}, [])