UNPKG

web-ai-toolkit

Version:

AI powered features on the web made easy

24 lines (23 loc) 635 B
import { _ as n, a as c, w as i } from "./utils-BzV5l7tu.js"; let t; async function p(e, a = "Xenova/trocr-small-printed") { return new Promise(async (o, s) => { try { t || await w(a), typeof e != "string" && (e = URL.createObjectURL(e)); const r = await t(e); o(r); } catch (r) { s(r); } }); } async function w(e) { return new Promise(async (a) => { t || (n.allowLocalModels = !1, n.useBrowserCache = !1, t = await c("image-to-text", e || "Xenova/trocr-small-printed", { device: navigator.ml ? "webnn" : await i() ? "webgpu" : "wasm" })), a(); }); } export { p as runOCR };