in static/js/chat.js [208:219]
speechRecognizer.canceled = function(s, e) {
console.error("Speech recognizer canceled: " + e.errorDetails);
// Check if the cancellation was due to an error (e.g., token expiry or connection failure)
if (e.reason === SpeechSDK.CancellationReason.Error) {
console.log("Detected token expiration or connection issue. Reinitializing recognizer...");
window.stopRecording();
// Wait briefly before reinitializing
setTimeout(() => {
window.startRecording();
}, 2000);
}
};