Last active
December 12, 2023 08:03
-
-
Save kawaz/b68c0efc87dc074ef27be3ed01bf84d0 to your computer and use it in GitHub Desktop.
読み上げAPIのテスト
This file contains 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
// 日本語の声をランダムに1つ選ぶ | |
const voices = speechSynthesis.getVoices().filter(v=>/^ja-/.test(v.lang)) | |
const voice = voices[Math.floor(voices.length*100000*Math.random())%voices.length] | |
const ssu = new SpeechSynthesisUtterance() | |
ssu.lang = 'ja-JP' // 言語 | |
ssu.voice = voice // 発話に使用する音声(未設定の場合lang設定を見て適切な音声が選ばれる | |
ssu.volume = 1 // 発話の音量 0~1、default=1 | |
ssu.rate = 1 // 発話の速度 0.1~10、default=1 | |
ssu.pitch = 1 // 発話の音程 0~2、default=1 | |
ssu.text = 'こんにちは' // 発話合成したいテキストそのものまたはSSML | |
window.speechSynthesis.speak(ssu) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
音声認識のサンプルはこちら
https://gist.github.com/kawaz/ece40ab50d2ae0c1f888bb7c6f6cef72
音声合成のサンプルはこちら
https://gist.github.com/kawaz/b68c0efc87dc074ef27be3ed01bf84d0