OCR
All checks were successful
Publish Library / Build NPM Project (push) Successful in 1m4s
Publish Library / Tag Version (push) Successful in 17s

This commit is contained in:
2026-06-09 08:29:46 -04:00
parent 51ab8f2538
commit 3121d542d4
3 changed files with 5 additions and 5 deletions

View File

@@ -12,12 +12,12 @@ export class Vision {
*/
ocr(path: string): AbortablePromise<string | null> {
let worker: any;
const p = new Promise<string | null>(async res => {
const p = (async () => {
worker = await createWorker(this.ai.options.ocr || 'eng', 2, {cachePath: this.ai.options.path});
const {data} = await worker.recognize(path);
await worker.terminate();
res(data.text.trim() || null);
}).finally(() => worker?.terminate());
return data.text.trim() || null;
})().finally(() => worker?.terminate());
return Object.assign(p, {abort: () => worker?.terminate()});
}
}