> For the complete documentation index, see [llms.txt](https://easonwang.gitbook.io/web_advance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://easonwang.gitbook.io/web_advance/google_speech_api/speech-api.md).

# speech api

```
var msg = new SpeechSynthesisUtterance();
```

```
msg.text = 'Hello World';

var voices = window.speechSynthesis.getVoices();

msg.voice = voices[19]; //設定語言

speechSynthesis.speak(msg);
```

參考至\
<https://developers.google.com/web/updates/2014/01/Web-apps-that-talk-Introduction-to-the-Speech-Synthesis-API?hl=en>
