SpeechSynthesisVoice:localService 属性
localService 是 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";
}
console.log(voice.localService);
option.setAttribute("data-lang", voice.lang);
option.setAttribute("data-name", voice.name);
voiceSelect.appendChild(option);
}
规范
| 规范 |
|---|
| Web Speech API # dom-speechsynthesisvoice-localservice |
浏览器兼容性
加载中…