gpt4 book ai didi

javascript - web speech api语音合成-获取语音列表

转载 作者:数据小太阳 更新时间:2023-10-29 04:42:39 25 4
gpt4 key购买 nike

我在使用网络语音 API 时遇到了一个奇怪的问题。我已经设置了一些代码来说出一串文本——很少,它会用正常的声音说出来(Mac OS X 中听写和语音设置中的“Alex”)。但通常情况下,它会用“Albert”的声音说话。

我正在查看此处列出的 w3c 网络语音 API:

https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html#dfn-ttsgetvoices

还有一个接口(interface)叫做

SpeechSynthesisVoiceList{}

我正在尝试访问此功能,但我不能。

我如何访问此语音列表?我正在使用 chrome canary,我已经尝试了很多方法来做到这一点。我期望的工作是:

var u = new SpeechSynthesisUtterance();
console.log(u.getVoices());

var u = new SpeechSynthesisVoiceList();
console.log(u);

我也跑过:

console.log(window)

我看到很多关于网络语音 API 和语音合成的东西,但没有看到关于语音的东西。

最佳答案

您应该使用 speechSynthesis.getVoices() 来获取所有声音的列表。这是 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"
}]

关于javascript - web speech api语音合成-获取语音列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17224540/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com