diff --git a/src/components/VoiceDropdown.jsx b/src/components/VoiceDropdown.jsx index 8ac51ec..2384610 100644 --- a/src/components/VoiceDropdown.jsx +++ b/src/components/VoiceDropdown.jsx @@ -19,6 +19,12 @@ const VoiceDropdown = () => { }) voices.then((voices) => { + // Sort voices by language + voices.sort((a, b) => a.lang.localeCompare(b.lang)); + + // Limit number of voices shown to 250 + voices = voices.slice(0, 250); + setVoices(voices); }) }, []); @@ -28,21 +34,38 @@ const VoiceDropdown = () => { setSelectedVoice(event.target.value); setVoice(voices.find(voice => voice.name === event.target.value)); }; + + const handleLanguageChange = (event) => { + setSelectedLanguage(event.target.value); + // Filter voices by selected language + const filteredVoices = voices.filter(voice => voice.lang === event.target.value); + + // Set selected voice to the first voice in the filtered voices + setSelectedVoice(filteredVoices[0].name); + setVoice(filteredVoices[0]); + }; return (
- + {voices.map((voice) => ( + + ))} + +
); }; -export default VoiceDropdown ; \ No newline at end of file +export default VoiceDropdown ;