fix: phoneticAnalysis timeout 15s — защита от зависания decodeAudioData (Chrome bug, длинные WebM)
This commit is contained in:
+4
-1
@@ -223,9 +223,12 @@ async function doCompare(blob, originalText, duration) {
|
|||||||
}, 150);
|
}, 150);
|
||||||
let whisperResult, phon;
|
let whisperResult, phon;
|
||||||
try {
|
try {
|
||||||
|
const phonTimeout = new Promise(resolve =>
|
||||||
|
setTimeout(() => resolve({ pitchHz: 0, pitchStability: 0, voiceClarity: 0, phonScore: 0 }), 15000)
|
||||||
|
);
|
||||||
[whisperResult, phon] = await Promise.all([
|
[whisperResult, phon] = await Promise.all([
|
||||||
transcribe(blob),
|
transcribe(blob),
|
||||||
phoneticAnalysis(blob)
|
Promise.race([phoneticAnalysis(blob), phonTimeout])
|
||||||
]);
|
]);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
clearInterval(timerId);
|
clearInterval(timerId);
|
||||||
|
|||||||
Reference in New Issue
Block a user