Created
December 16, 2025 11:16
-
-
Save vielhuber/76f7830c8879a3dd1cd5a6e22a732c1f to your computer and use it in GitHub Desktop.
tts text to speech browser native #js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // list voices | |
| speechSynthesis.getVoices().forEach(speech => { console.log(speech); }); | |
| // speak | |
| let message = new SpeechSynthesisUtterance('Verteidigungsminister Boris Pistorius hat die Berliner Ukraine-Gespräche mit Europäern und den USA gelobt.'); | |
| message.lang = 'de-DE'; | |
| message.voice = speechSynthesis.getVoices().filter(voice => voice.name === 'Google Deutsch')[0]; | |
| window.speechSynthesis.speak(message); | |
| // stop | |
| setTimeout(() => { | |
| window.speechSynthesis.cancel(); | |
| },2000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment