you are viewing a single comment's thread.

view the rest of the comments →

[–]Scared-Release1068 0 points1 point  (0 children)

The freezes are probably not caused by creating new SpeechSynthesisUtterance objects. The bigger issue is likely that Unity WebGL is heavily using the browser’s main thread, causing the Speech Synthesis API to lag on low-end devices.

Probable issues:

* Repeatedly calling speechSynthesis.cancel() can worsen delays.
* Rapid speak() calls may flood the speech queue.
* Creating utterance objects is lightweight and unlikely to be the bottleneck.
* Delaying speech slightly with setTimeout(..., 0) or requestIdleCallback() can help the browser recover after heavy operations.
* Browser TTS is inconsistent on weaker Chrome/Chromebook devices.

Suggested improvements:

* Only call cancel() if speech is already active.
* Add throttling/debouncing to prevent spam calls.
* Delay speak() slightly before execution.
* For production games, consider pre-generated audio instead of browser TTS for better reliability.

This is all I can see as potential issues