fix: complaints mic - check server STT on init and handle server mode click
- initComplaintsSpeech() now calls checkComplaintsSttServer() async: server up → mode 'server', browser fallback → mode 'browser', else 'off' - click handler now handles both 'server' and 'browser' modes (previously only 'browser' was handled, server mode click did nothing) - show '…' while server health check is in progress to avoid confusion
This commit is contained in:
parent
17e2d8e16b
commit
7bb539a620
|
|
@ -1379,6 +1379,10 @@
|
|||
}
|
||||
|
||||
function initComplaintsSpeech() {
|
||||
// Show checking state while server availability is probed
|
||||
var $micBtn = $('#btn_complaints_mic');
|
||||
$micBtn.prop('disabled', true).text('…');
|
||||
|
||||
var SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
||||
if (SpeechRecognition) {
|
||||
complaintsSpeechRecognition = new SpeechRecognition();
|
||||
|
|
@ -1423,14 +1427,27 @@
|
|||
};
|
||||
}
|
||||
|
||||
if (complaintsSpeechRecognition) {
|
||||
setComplaintsMicMode('browser', 'Complaints Mic is ready (browser mode for local language).');
|
||||
} else {
|
||||
setComplaintsMicMode('off', 'Complaints Mic unavailable in this browser.');
|
||||
}
|
||||
// Check server STT availability first; fallback to browser, then off
|
||||
checkComplaintsSttServer().then(function(serverUp) {
|
||||
if (serverUp) {
|
||||
setComplaintsMicMode('server', 'Complaints Mic ready (server STT).');
|
||||
} else if (complaintsSpeechRecognition) {
|
||||
setComplaintsMicMode('browser', 'Complaints Mic ready (browser mode).');
|
||||
} else {
|
||||
setComplaintsMicMode('off', 'Complaints Mic unavailable in this browser.');
|
||||
}
|
||||
}).catch(function() {
|
||||
if (complaintsSpeechRecognition) {
|
||||
setComplaintsMicMode('browser', 'Complaints Mic ready (browser mode).');
|
||||
} else {
|
||||
setComplaintsMicMode('off', 'Complaints Mic unavailable in this browser.');
|
||||
}
|
||||
});
|
||||
|
||||
$('#btn_complaints_mic').on('click', function() {
|
||||
if (complaintsMicMode === 'browser') {
|
||||
if (complaintsMicMode === 'server') {
|
||||
startComplaintsServerStt();
|
||||
} else if (complaintsMicMode === 'browser') {
|
||||
startComplaintsBrowserStt();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user