问题描述
我正在尝试进行网络应用,使其无法自动阅读文本,我有以下代码:
function hablalo()
{
var palabra = new SpeechSynthesisUtterance('Casilla 6 turno E18');
palabra.lang = "es"
speechSynthesis.speak(palabra);
}
$('#perez').trigger($.Event( "click",{ originalEvent: true } ));
问题是当我尝试这样做时,结果是:
(index):20 [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
我想用一种方法在chrome浏览器中模拟点击,或用另一种方法来生成tts,谢谢。 :)
-编辑
解决方法
所以我用this解决了我的问题,摘要我修改了客户端计算机中铬的laucher-flags,在启动器属性的路径末尾添加了--autoplay-policy=no-user-gesture-required
。
用代码制作似乎是不可能的,但是这种解决方案是一种辞职方式。