V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Latin
V2EX  ›  前端开发

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

  •  
  •   Latin · 2019-08-23 12:09:08 +08:00 · 3815 次点击
    这是一个创建于 1708 天前的主题,其中的信息可能已经有所发展或是发生改变。

    问题如下

    • 通过 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

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2812 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 02:45 · PVG 10:45 · LAX 19:45 · JFK 22:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.