SpeechSynthesisEvent: charIndex property

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 charIndex của giao diện SpeechSynthesisUtterance trả về vị trí chỉ mục của ký tự trong SpeechSynthesisUtterance.text đang được nói khi sự kiện được kích hoạt.

Giá trị

Một số.

Ví dụ

js
utterThis.onpause = (event) => {
  const char = event.utterance.text.charAt(event.charIndex);
  console.log(
    `Speech paused at character ${event.charIndex} of "${event.utterance.text}", which is "${char}".`,
  );
};

Thông số kỹ thuật

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

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

Xem thêm