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