UNPKG

@omnimedia/omnitool

Version:

open source video processing tools

35 lines 1.19 kB
import { defer, once } from "@e280/stz"; import { Comrade } from "@e280/comrade"; import { loadPipe } from "../../parts/load-pipe.js"; import { transcribe } from "./parts/transcribe.js"; import { exposeErrors } from "../../parts/expose-errors.js"; const deferred = defer(); const makePrepare = (host) => once(async (spec) => { deferred.resolve({ spec, pipe: await loadPipe({ spec, task: "automatic-speech-recognition", onLoading: loading => host.loading(loading), }) }); }); await Comrade.worker(shell => { const prepare = makePrepare(shell.host); return { prepare: exposeErrors(prepare), transcribe: exposeErrors(async (request) => { const { pipe, spec } = await deferred.promise; return transcribe({ pipe, spec, request, callbacks: { onReport: report => shell.host.deliverReport(report), onTranscription: transcription => shell.host.deliverTranscription(transcription), }, }); }) }; }); //# sourceMappingURL=worker.bundle.js.map