Spaces:
Running
Running
Download src/components/Sections/voiceUtils.js from STAR-GROUP/model-test-react: direct link, hf CLI and curl.
- Browser
- Download file 851 Bytes
-
https://huggingface.co/spaces/STAR-GROUP/model-test-react/resolve/main/src/components/Sections/voiceUtils.js
- Command line
-
hf download hf://spaces/STAR-GROUP/model-test-react/src/components/Sections/voiceUtils.js
-
curl -L -o voiceUtils.js https://huggingface.co/spaces/STAR-GROUP/model-test-react/resolve/main/src/components/Sections/voiceUtils.js
851 Bytes
| // convomate/src/components/Sections/voiceUtils.js | |
| export const loadVoices = () => { | |
| return new Promise((resolve) => { | |
| const voices = window.speechSynthesis.getVoices(); | |
| if (voices.length > 0) { | |
| resolve(voices); | |
| } else { | |
| window.speechSynthesis.onvoiceschanged = () => { | |
| resolve(window.speechSynthesis.getVoices()); | |
| }; | |
| } | |
| }); | |
| }; | |
| export const getDefaultVoice = (voices) => { | |
| // Try to find Google US English first | |
| const googleUS = voices.find( | |
| (voice) => | |
| voice.name.includes("Google US English") || | |
| voice.name.includes("English United States"), | |
| ); | |
| // Fallback to first English voice | |
| const englishVoice = voices.find( | |
| (voice) => voice.lang.includes("en-US") || voice.lang.includes("en_GB"), | |
| ); | |
| return googleUS || englishVoice || voices[0]; | |
| }; | |