JavaScript speechSynthesis.speak() without user activation is no longer allowed since M71

后端 未结 6 1109
失恋的感觉
失恋的感觉 2021-01-11 11:15

I used speechSynthesis API in this way:

speechSynthesis.speak(new SpeechSynthesisUtterance(\"hello world\"));

But right now I get error aft

6条回答
  •  春和景丽
    2021-01-11 11:45

    This error means entire document (Website) has no user interaction and Google Chrome update its policy regarding making sound from the website without user interaction.

    User interaction means: click, dblclick, mouseup, pointerup, reset, submit etc.

    Solution:

    So, if you want to run speechSynthesis.speak(); without real user interaction, then you just create temporary user interaction using a method like .click(), etc.

提交回复
热议问题