Skip to content

Instantly share code, notes, and snippets.

@vielhuber
Created December 16, 2025 11:16
Show Gist options
  • Select an option

  • Save vielhuber/76f7830c8879a3dd1cd5a6e22a732c1f to your computer and use it in GitHub Desktop.

Select an option

Save vielhuber/76f7830c8879a3dd1cd5a6e22a732c1f to your computer and use it in GitHub Desktop.
tts text to speech browser native #js
// 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