I want to use the HTML5 Speech API to synthesize speech by calling window.speechSynthesis.speak(...)
, which works in nearly all browsers as expected, but I have some trouble with iOS Safari:
Calling speechSynthesis.speak(...)
is only possible in iOS Safari if the user has actually triggered the function call himself by clicking somewhere. If this is the case, everything works as expected. The problem I have is that I need to call speechSynthesis.speak(...)
in a callback function that is called when a http request returns. As this callback function is no longer directly triggered by the user, the speech synthesizer doesn't work.
Is there any way to work around this restriction? I know that the behavior is supposed to protect the user from misuse of the API, but in my scenario the synthesis is triggered by a user action, but there's the remote request in between.