aws-samples / amazon-sumerian-hosts

Amazon Sumerian Hosts (Hosts) is an experimental open source project that aims to make it easy to create interactive animated 3D characters for Babylon.js, three.js, and other web 3D frameworks. It leverages AWS services including Amazon Polly (text-to-speech) and Amazon Lex (chatbot).
MIT No Attribution
183 stars 82 forks source link

Audio auto play warning from Chrome #82

Closed charles-hay closed 2 years ago

charles-hay commented 2 years ago

When loading the app from a static site generator(Github Pages) I get the warning message The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu on line three.min.js:formatted:19644 and The audio context is not running. Speech will not be able to be played until it is resumed. Use the "TextToSpeechFeature.resumeAudio" method to try to resume it after a user gesture. on line TextToSpeechFeature.js:26

lbracegirdle commented 2 years ago

@charles-hay Is this linked to this previously reported issue?

charles-hay commented 2 years ago

Yes it is. I was using it on MacOS so it wasn't causing it not to play it was just throwing a warning. I was also using Three.js so the streaming flag is not available. Thanks for pointing me in the right direction!

lbracegirdle commented 2 years ago

I'm having the same issue as two of my clients require this in three.js for its other features (so can't use the Babylon workaround). This has had me stuck for a while so really hope someone has an solution for three.js

SavagePencil commented 2 years ago

This isn't an issue in the hosts, three.js or Babylon, this is enforced by the browser unfortunately. Making it worse, browsers enforce this differently and not always consistently. You will need to add a user interaction, such as a button press or other touch interaction, before audio starts to play. This is why many experiences begin with a "touch to begin"-type button to fulfill that requirement.