Skip to content

WEB语音播报

js
const voiceText = new SpeechSynthesisUtterance(`播报文字`);
    //const voices = speechSynthesis.getVoices() 当前设备上所有可用的语音。
    // voiceText.voice = voices[22] 设置语音
    voiceText.pitch = 1  // 表示说话的音高,数值,范围从0(最小)到2(最大)。默认值为1。
    voiceText.rate = 1   // 设置播放语速,范围:0.1 - 10之间    正常为1倍播放
    speechSynthesis.speak(voiceText)