Wait for realtime ASR final result
This commit is contained in:
parent
5419103357
commit
c29ee51558
@ -261,15 +261,20 @@ export function WebSocketConnectMethod(config) {
|
||||
stateHandle(1);
|
||||
}
|
||||
|
||||
function onMessage(e) {
|
||||
msgHandle(e);
|
||||
try {
|
||||
const payload = JSON.parse(e.data);
|
||||
if (payload && payload.type === "state" && payload.state === "closed") {
|
||||
resolveGracefulStop();
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
function onMessage(e) {
|
||||
msgHandle(e);
|
||||
try {
|
||||
const payload = JSON.parse(e.data);
|
||||
if (payload && payload.type === "state" && payload.state === "closed") {
|
||||
resolveGracefulStop();
|
||||
} else if (
|
||||
payload &&
|
||||
(payload.mode === "2pass-offline" || payload.mode === "offline-speaker")
|
||||
) {
|
||||
resolveGracefulStop();
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
// info_div.innerHTML="连接"+e;
|
||||
|
||||
@ -628,7 +628,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
return started ? 1 : 0;
|
||||
}
|
||||
|
||||
async function finishRealtimeAsrPipelines(timeoutMs = 3500) {
|
||||
async function finishRealtimeAsrPipelines(timeoutMs = 20000) {
|
||||
const pipelines = getRealtimePipelines();
|
||||
await Promise.allSettled(pipelines.map((pipeline) => pipeline.finish(timeoutMs)));
|
||||
syncRealtimeActiveState();
|
||||
@ -3094,7 +3094,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
}
|
||||
}
|
||||
|
||||
await finishRealtimeAsrPipelines(3500);
|
||||
await finishRealtimeAsrPipelines(20000);
|
||||
|
||||
// Wait for MediaRecorder to emit the final blob.
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user