Set tesseract model
All checks were successful
Publish Library / Build NPM Project (push) Successful in 31s
Publish Library / Tag Version (push) Successful in 5s

This commit is contained in:
2026-01-16 20:33:51 -05:00
parent 6dce0e8954
commit 1c59379c7d
3 changed files with 10 additions and 4 deletions

View File

@@ -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",

View File

@@ -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 {

View File

@@ -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);