SpeechSynthesisVoice: thuộc tính name

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 name của giao diện SpeechSynthesisVoice trả về một tên dễ đọc đại diện cho giọng nói.

Giá trị

Một chuỗi đại diện cho tên của giọng nói.

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

  option.setAttribute("data-lang", voice.lang);
  option.setAttribute("data-name", voice.name);
  voiceSelect.appendChild(option);
}

Thông số kỹ thuật

Specification
Web Speech API
# dom-speechsynthesisvoice-name

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

Xem thêm