SpeechSynthesisVoice:default 属性
default 是 SpeechSynthesisVoice 接口的一个只读属性,它返回一个布尔值,表示该语音是否为当前应用程序的默认语音(true),否则为 false。
注意: 对于某些设备来说,它可能是该语音语言的默认语音。规范中并未明确规定它应该是哪种情况,因此有些实现可能会有所不同。
值
一个布尔值。
示例
js
for (const voice of voices) {
const option = document.createElement("option");
option.textContent = `${voice.name} (${voice.lang})`;
if (voice.default) {
option.textContent += " — DEFAULT";
}
option.setAttribute("data-lang", voice.lang);
option.setAttribute("data-name", voice.name);
voiceSelect.appendChild(option);
}
规范
| 规范 |
|---|
| Web Speech API # dom-speechsynthesisvoice-default |
浏览器兼容性
加载中…