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
are you getting any errors in the console?
When publishing to Review and checking your console... you immediately notice an error telling you 'Speech recognition: not allowed'. Thus Articulate has blocked it.
@Articulate: Do allow users to use this for testcases.
Hi Phil, thanks for reply. I got a error "Speech recognition error: not-allowed" in the console. So It's Review360 bocks it, right?
Thanks Math for testing it. Yes, It shows "Speech recognition error: not-allowed" in the console. Since Review360 is design for testing and review. They should unblock it.
@Artivulate @Dan Backes @Mike Swart
the courses on review 360 are integrated in a cross domain iframe - many things are not possible in such an environment
My thoughts exactly, had this happen a lot.
Sent from my iPhone
But then we should get a CORS-error in the console. Thats not happening. The only error now is showing: 'Speech recognition error: not-allowed'.
If im not wrong it is deliberately blocked at some point.
Google have a history of blocking any of their stuff working in frames unless they want it to work.
https://blog.addpipe.com/camera-and-microphone-access-in-cross-oirigin-iframes-with-feature-policy/
with this setting the microphone (= Speech recognition) should work
import: this setting is need in ALL surrounding (cross domain) iframes
same problem with
the outer website
has to allow the inner iframe the "special" features hosted on
360.articulate.com => articulateusercontent.com = cross-domain