SpeechSynthesis:speaking 属性

基线 广泛可用

此功能已经成熟,并在许多设备和浏览器版本上运行。它自 2018 年 9 月.

报告反馈

SpeechSynthesis 接口的只读属性 speaking 是一个布尔值,如果当前正在朗读句子,则返回 true - 即使 SpeechSynthesis 处于 paused 状态。

示例

一个布尔值。
const synth = window.speechSynthesis;

const utterance1 = new SpeechSynthesisUtterance(
  "How about we say this now? This is quite a long sentence to say.",
);
const utterance2 = new SpeechSynthesisUtterance(
  "We should say another sentence too, just to be on the safe side.",
);

synth.speak(utterance1);
synth.speak(utterance2);

const amISpeaking = synth.speaking; // will return true if utterance 1 or utterance 2 are currently being spoken

规范

js
Web 语音 API
# 规范

浏览器兼容性

dom-speechsynthesis-speaking

另请参阅