From 1c59379c7dc168464a8cf1ca4c13c2ceec230f35 Mon Sep 17 00:00:00 2001 From: ztimson Date: Fri, 16 Jan 2026 20:33:51 -0500 Subject: [PATCH] Set tesseract model --- package.json | 2 +- src/ai.ts | 10 ++++++++-- src/vision.ts | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e6fd5b8..7876703 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ztimson/ai-utils", - "version": "0.2.4", + "version": "0.2.5", "description": "AI Utility library", "author": "Zak Timson", "license": "MIT", diff --git a/src/ai.ts b/src/ai.ts index 087ba76..ff22524 100644 --- a/src/ai.ts +++ b/src/ai.ts @@ -4,14 +4,20 @@ import { Audio } from './audio.ts'; import {Vision} from './vision.ts'; export type AiOptions = LLMOptions & { + /** Path to models */ + path?: string; + /** Whisper ASR configuration */ whisper?: { /** Whisper binary location */ binary: string; /** Model: `ggml-base.en.bin` */ model: string; } - /** Path to models */ - path?: string; + /** Tesseract OCR configuration */ + tesseract?: { + /** Model: eng, eng_best, eng_fast */ + model?: string; + } } export class Ai { diff --git a/src/vision.ts b/src/vision.ts index ad06df6..4eac943 100644 --- a/src/vision.ts +++ b/src/vision.ts @@ -15,7 +15,7 @@ export class Vision { return { abort: () => { worker?.terminate(); }, response: new Promise(async res => { - worker = await createWorker('eng', 1, {cachePath: this.ai.options.path}); + worker = await createWorker(this.ai.options.tesseract?.model || 'eng', 2, {cachePath: this.ai.options.path}); const {data} = await worker.recognize(path); await worker.terminate(); res(data.text.trim() || null);