iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🚀

Japanese Text-to-Speech with Web Speech API

に公開

You can check whether it is available in the browser via the window object

> 'speechSynthesis' in window
true

Let's try performing the speech synthesis. This can also be executed in Chrome DevTools.

const uttr = new SpeechSynthesisUtterance();
uttr.lang = "ja-JP";
uttr.text = "こんにちは";
speechSynthesis.speak(uttr);

You can choose various voices through speechSynthesis.getVoices

const uttr = new SpeechSynthesisUtterance();
uttr.text = "こんにちは";
voices = speechSynthesis.getVoices().filter((v) => v.lang === 'ja-JP');
uttr.voice = voices[0];
speechSynthesis.speak(uttr);

On Chromebooks, 13 types of Japanese voices are available

Discussion