V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Latin

Chrome 文本转语音(TTS)语音播放问题

  •  
  •   Latin · Aug 23, 2019 · 4246 views
    This topic created in 2448 days ago, the information mentioned may be changed or developed.

    问题如下

    • 通过 js 模拟点击,刷新页面后老是弹出 M71 禁令
    • 怎样可以不手动触发也可以播放,(因为 chrome 已经禁用了 auto-play)
    • 还有没有更好用的的 JavaScript 离线 TTS (开源不收费的)
    • 目前已知开源的基本不支持中文

    代码如下

        var msg = new SpeechSynthesisUtterance(speakName);
        msg.voice = speechSynthesis.getVoices().filter(
            function (voice) {
                return voice.name == 'Google 普通话(中国大陆)';
            })[0];
        speechSynthesis.speak(msg);
    

    禁令如下

    [Deprecation] speechSynthesis.speak() without user activation is no longer allowed since M71, around December 2018. See https://www.chromestatus.com/feature/5687444770914304 for more details
    

    演示地址多次刷新不手动触发也会在 console 弹出

    http://cr.kungfoo.net/speech/immediately-speak.html

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   957 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 19:40 · PVG 03:40 · LAX 12:40 · JFK 15:40
    ♥ Do have faith in what you're doing.