Why my Javascript(Voice to Text) works differently when publishing to Web and Review 360?

Feb 01, 2024

I am adding a voice to text function with Javascript in a project. It works perfectly as expect when publishing to Web. But when I publish to Review360, it doesn't work at all. I am wondering is there anyone who can tell me why it won't work in Review 360?


Here is the code:
----------------------------------------------------------------------------------
// Initialize SpeechRecognition
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
recognition.lang = 'en-US';

// Global variable to store the recognized text
let recognizedText = '';

// Event handlers
recognition.onresult = (event) => {
  recognizedText = event.results[0][0].transcript;
  console.log('Speech Recognition Result:', recognizedText);

  // Set the recognized text to the third-party software's variable
  player.SetVar("UserResponce", recognizedText);
};

recognition.onerror = (event) => {
  console.error('Speech recognition error:', event.error);
};

// Function to start recognition
function startRecognition() {
  recognition.start();
}

// Trigger recognition when needed (e.g., when your button is clicked)
// You can call startRecognition() from your third-party software's trigger
startRecognition();
----------------------------------------------------------------------------------
I'll appreciate if someone know how to modify it to work as well in Review 360.

10 Replies
Jürgen Schoenemeyer

https://blog.addpipe.com/camera-and-microphone-access-in-cross-oirigin-iframes-with-feature-policy/

with this setting the microphone (= Speech recognition) should work

<iframe src="https://example.com" allow="camera;microphone"></iframe>

import: this setting is need in ALL surrounding (cross domain) iframes