Forum Discussion
Why my Javascript(Voice to Text) works differently when publishing to Web and Review 360?
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.
- PhilMayorSuper Hero
are you getting any errors in the console?
- JoanneChenSuper Hero
Hi Phil, thanks for reply. I got a error "Speech recognition error: not-allowed" in the console. So It's Review360 bocks it, right?
- MathNotermans-9Community Member
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.- JoanneChenSuper Hero
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
- Jürgen_Schoene_Community Member
the courses on review 360 are integrated in a cross domain iframe - many things are not possible in such an environment
- PhilMayorSuper Hero
My thoughts exactly, had this happen a lot.
Sent from my iPhone
- Jürgen_Schoene_Community Member
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
- MathNotermans-9Community Member
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.
- PhilMayorSuper Hero
Google have a history of blocking any of their stuff working in frames unless they want it to work.
- Jürgen_Schoene_Community Member
same problem with
- allow="autoplay"
- allow="clipboard-write"
the outer website
- "360.articulate.com"
has to allow the inner iframe the "special" features hosted on
- "articulateusercontent.com"
360.articulate.com => articulateusercontent.com = cross-domain