Text to speech in immersive xr mode

1-- I want to add javascript text to speech on webxr content in both ordinary 2D mode and 3D immersive mode.

With a lot of different tries it does not seem to work when the same page that works in 2D on Chrome is placed in 3D immersive mode on the Quest 2 Browser.

2-- One example is

which works in 2D & 3D XR (note 9/8/24 – it did work when I wrote this, but checking it again today it was not the same. “CreateSphere” had a line struck through it.)

works in 2D, but does not even load properly in 3D.

3-- The demo in Convert Mesh Names to Web Speech Synthesis Voice - BabylonPress

ran, but was silent in 3D immersive mode.

4a-- With other ways of creating a 2D XR enabled site with TTS audio that works, the same page in 3D immersive mode loads, but ignores the audio;

4b-- or when a click on a sphere triggering the audio in 2D works, selecting the sphere in 3D immersive mode crashes - freezing the page.

Am I doing something wrong? Is there a way to make it work?

Is there a problem with the Oculus Browser, or some special setting that’s needed?

(I tried it on Wolvic without success also.)

WHEN

is viewed in chrome on the desktop, the audio plays and the sphere shows.

when it is viewed in a Q2 with the Meta Browser, the sphere does not show and the words do not play

Without any xr in the scene, playing

which has

let synth = window.speechSynthesis;
let utterThis = new SpeechSynthesisUtterance(I am a COLORLESS sphere);
synth.speak(utterThis);

for the speech,

the program works in Chrome on the web, but in Q2 in the Meta browser, it shows the error message

SpeechSynthesisUtterance is not defined.

This also raises the issue, what is the best way to find “hidden” error messages when there is an XR command in the scene and using (or not using) the playground for testing:

The error message did not show up until I did the test in a Playground without any XR.

That could mean you don’t have any voice installed on your system for the speech synthesis.

Maybe there are ways to install voices on the Quest as it is quite open, or maybe there could be a flag to turn on in the browser?

API TTS systems install software using <script src = “X” …

Is there some similar way to access the javascript TTS (and speech recognition) for XR modes?

Related:

https://www.reddit.com/r/WebXR/comments/zbsjxq/web_speech_api_is_not_available_in_the_quest/

They seem to say that SpeechSynthesisUtterance is not supported at all by the browser. But you can probably use WebAudio with an API such as Eleven Labs to bypass that problem