bug fix
This commit is contained in:
@@ -176,7 +176,12 @@ function initRecognition() {
|
|||||||
checkBtn.disabled = !display.trim();
|
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(); };
|
r.onerror = (e) => { if (e.error !== 'no-speech') stopRecording(); };
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
@@ -207,7 +212,9 @@ async function startRecording() {
|
|||||||
clearTimeout(recordingTimer);
|
clearTimeout(recordingTimer);
|
||||||
recordingTimer = setTimeout(stopRecording, MAX_RECORD_SECONDS * 1000);
|
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 {
|
try {
|
||||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||||
const mimeType = MediaRecorder.isTypeSupported('audio/webm;codecs=opus')
|
const mimeType = MediaRecorder.isTypeSupported('audio/webm;codecs=opus')
|
||||||
@@ -223,6 +230,7 @@ async function startRecording() {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('MediaRecorder unavailable:', e);
|
console.warn('MediaRecorder unavailable:', e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopRecording() {
|
function stopRecording() {
|
||||||
|
|||||||
Reference in New Issue
Block a user