SpeechSynthesisVoice: thuộc tính localService

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2018.

Thuộc tính chỉ đọc localService của giao diện SpeechSynthesisVoice trả về một giá trị boolean cho biết liệu giọng nói có được cung cấp bởi dịch vụ tổng hợp giọng nói cục bộ (true) hay dịch vụ tổng hợp giọng nói từ xa (false).

Thuộc tính này được cung cấp để cho phép phân biệt trong trường hợp một số tùy chọn giọng nói được cung cấp bởi dịch vụ từ xa; có thể các giọng nói từ xa có độ trễ, băng thông hoặc chi phí thêm liên quan, vì vậy sự phân biệt đó có thể hữu ích.

Giá trị

Một giá trị boolean.

Ví dụ

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);
}

Thông số kỹ thuật

Thông số kỹ thuật
Web Speech API
# dom-speechsynthesisvoice-localservice

Tương thích trình duyệt

Xem thêm