admin管理员组文章数量:1302293
I'm having a weird issue with the web speech api. I've set up some code to speak a string of text - very rarely, it speaks it in a normal voice ("Alex" from Dictation and Speech Settings in Mac OS X). But usually, it speaks in the voice "Albert".
I'm looking at the w3c web speech api listed here:
.html#dfn-ttsgetvoices
and there is an interface called
SpeechSynthesisVoiceList {}
I am trying to access this functionality, but I can't.
How would I access this voice list? I'm using chrome canary, and I've tried numerous methods of doing this. What I would expect to work would be:
var u = new SpeechSynthesisUtterance();
console.log(u.getVoices());
or
var u = new SpeechSynthesisVoiceList();
console.log(u);
I've also run:
console.log(window)
and I see numerous things regarding the web speech api and speech synthesis, but nothing about voices.
I'm having a weird issue with the web speech api. I've set up some code to speak a string of text - very rarely, it speaks it in a normal voice ("Alex" from Dictation and Speech Settings in Mac OS X). But usually, it speaks in the voice "Albert".
I'm looking at the w3c web speech api listed here:
https://dvcs.w3/hg/speech-api/raw-file/tip/speechapi.html#dfn-ttsgetvoices
and there is an interface called
SpeechSynthesisVoiceList {}
I am trying to access this functionality, but I can't.
How would I access this voice list? I'm using chrome canary, and I've tried numerous methods of doing this. What I would expect to work would be:
var u = new SpeechSynthesisUtterance();
console.log(u.getVoices());
or
var u = new SpeechSynthesisVoiceList();
console.log(u);
I've also run:
console.log(window)
and I see numerous things regarding the web speech api and speech synthesis, but nothing about voices.
Share asked Jun 20, 2013 at 21:56 mheaversmheavers 30.2k62 gold badges200 silver badges326 bronze badges1 Answer
Reset to default 7You should use speechSynthesis.getVoices()
to get a list of all voices. This is an output from Google Chrome 33:
[{
"default": true,
"localService": false,
"lang": "en-US",
"name": "Google US English",
"voiceURI": "Google US English"
}, {
"default": false,
"localService": false,
"lang": "en-GB",
"name": "Google UK English Male",
"voiceURI": "Google UK English Male"
}, {
"default": false,
"localService": false,
"lang": "en-GB",
"name": "Google UK English Female",
"voiceURI": "Google UK English Female"
}, {
"default": false,
"localService": false,
"lang": "es-ES",
"name": "Google Español",
"voiceURI": "Google Español"
}, {
"default": false,
"localService": false,
"lang": "fr-FR",
"name": "Google Français",
"voiceURI": "Google Français"
}, {
"default": false,
"localService": false,
"lang": "it-IT",
"name": "Google Italiano",
"voiceURI": "Google Italiano"
}, {
"default": false,
"localService": false,
"lang": "de-DE",
"name": "Google Deutsch",
"voiceURI": "Google Deutsch"
}, {
"default": false,
"localService": false,
"lang": "ja-JP",
"name": "Google 日本人",
"voiceURI": "Google 日本人"
}, {
"default": false,
"localService": false,
"lang": "ko-KR",
"name": "Google 한국의",
"voiceURI": "Google 한국의"
}, {
"default": false,
"localService": false,
"lang": "zh-CN",
"name": "Google 中国的",
"voiceURI": "Google 中国的"
}, {
"default": false,
"localService": true,
"lang": "",
"name": "native",
"voiceURI": "native"
}]
本文标签: javascriptweb speech api speech synthesisgetting voice listStack Overflow
版权声明:本文标题:javascript - web speech api speech synthesis - getting voice list - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741662762a2391136.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论