在ResponsiveVoice.JS website的怪癖部分,它指出:
iOS TTS can’t be triggered without a direct user interaction,ResponsiveVoice JS resolves this
但是,对于我的生活,我无法绕过这种直接的用户交互要求.你怎么解决这个问题?
这是我试图在没有用户交互的情况下执行的代码片段,我目前位于< head>元件:
我想调用responsiveVoice.speak(‘Test’); iOS上的页面加载,没有直接的用户交互.我该怎么做?
这个相同的代码段在桌面上的桌面/ Chrome上的Android / Safari上说得很好,但在iOS中却没有.
On iOS,some events such as Speech Synthesis,need to be triggered from a user action (i.e. a click). That causes ResponsiveVoice speak calls not to work on page load,for example.
With Speech Synthesis,that user triggered action only needs to be done once. Further direct calls after the first one will work as expected.
So,the recommended best practice is to add a “Start” button to the experience for the user to click,and use that as a initialization call to responsiveVoice.speak(). That call,if desired,can have a blank space as text,so there’s no impact to the user.
您不需要实际说出任何内容,因此使用用户只需单击一个调用responsiveVoice的按钮就足够了.
响应语音常见问题解答:https://responsivevoice.org/faq/