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 |
瀏覽器相容性
載入中…