More Related Content Similar to HTML5でteratailが喋った! (20) HTML5でteratailが喋った!12. Speech Synthesis API
var voices = speechSynthesis.getVoices();
var speech = new SpeechSynthesisUtterance();
speech.voice = voices[11]; // Google 日本語(環境依存)
speech.volume = 1; // 声量
speech.rate = 1.1; // 早さ
speech.pitch = 1; // 声の高さ
speech.lang = 'ja-JP'; // 言語
speech.text = 'ハローワールド'; // 喋る内容
speechSynthesis.speak(speech);
13. Speech Synthesis API
● 長い文字列になると最後まで読めない?
○ 正規表現で文を取り出して対応。
● speechSynthesis.getVoices()が取れない?
○ 非同期?タイミングをずらしても何故か初回だけ取れない。
○ speechSynthesis.onvoiceschangedで対応。
15. 最後に
● Web Speech APIで音声入力も可能なので
質問検索を音声入力でできたら面白そう!
● 質問を聞いたら音声で返してくれる、
teratailアシスタントが作れるかも?
17. Credits
Special thanks to all the people who made and
released these awesome resources for free:
✘ Presentation template by SlidesCarnival
✘ Photographs by Unsplash