bug fix
This commit is contained in:
@@ -176,7 +176,12 @@ function initRecognition() {
|
||||
checkBtn.disabled = !display.trim();
|
||||
};
|
||||
|
||||
r.onend = () => { if (state.isRecording) stopRecording(); };
|
||||
r.onend = () => {
|
||||
if (state.isRecording) {
|
||||
// Android stops recognition on its own after silence — restart it
|
||||
try { r.start(); } catch (_) {}
|
||||
}
|
||||
};
|
||||
r.onerror = (e) => { if (e.error !== 'no-speech') stopRecording(); };
|
||||
|
||||
return r;
|
||||
@@ -207,7 +212,9 @@ async function startRecording() {
|
||||
clearTimeout(recordingTimer);
|
||||
recordingTimer = setTimeout(stopRecording, MAX_RECORD_SECONDS * 1000);
|
||||
|
||||
// MediaRecorder for audio download — best-effort, after recognition starts
|
||||
// MediaRecorder for audio download — desktop only; on mobile it conflicts with SpeechRecognition
|
||||
const isMobile = /Android|iPhone|iPad/i.test(navigator.userAgent);
|
||||
if (!isMobile) {
|
||||
try {
|
||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||
const mimeType = MediaRecorder.isTypeSupported('audio/webm;codecs=opus')
|
||||
@@ -224,6 +231,7 @@ async function startRecording() {
|
||||
console.warn('MediaRecorder unavailable:', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stopRecording() {
|
||||
clearTimeout(recordingTimer);
|
||||
|
||||
Reference in New Issue
Block a user