diff --git a/package-lock.json b/package-lock.json index 741433e..962ef6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "web-ai-toolkit", - "version": "0.1.8", + "version": "0.1.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "web-ai-toolkit", - "version": "0.1.8", + "version": "0.1.7", "license": "ISC", "dependencies": { "@huggingface/transformers": "^3.0.0-alpha.14", diff --git a/package.json b/package.json index 90467aa..d61c418 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "vite build", - "start": "npm run build && npx vite serve" + "start": "npm run build && npx httpster test.html" }, "author": "", "license": "ISC", diff --git a/src/services/ocr/ocr.ts b/src/services/ocr/ocr.ts index cf76ab6..005c68b 100644 --- a/src/services/ocr/ocr.ts +++ b/src/services/ocr/ocr.ts @@ -1,9 +1,12 @@ let ocrWorker: Worker; +// @ts-ignore +import OCRWorker from './ocr-worker?worker&inline'; + export async function loadOCR(model: string): Promise { return new Promise(async (resolve) => { if (!ocrWorker) { - ocrWorker = new Worker(new URL('./ocr-worker.ts', import.meta.url), { type: 'module' }); + ocrWorker = new OCRWorker(); } ocrWorker.onmessage = async (e) => { diff --git a/src/services/speech-recognition/whisper-ai.ts b/src/services/speech-recognition/whisper-ai.ts index 8bc338a..87690b5 100644 --- a/src/services/speech-recognition/whisper-ai.ts +++ b/src/services/speech-recognition/whisper-ai.ts @@ -1,10 +1,11 @@ let whisperWorker: Worker; +// @ts-ignore +import WhisperWorker from './worker?worker&inline' + export async function loadTranscriber(model: string = "Xenova/whisper-tiny", timestamps: boolean, language: string): Promise { return new Promise(async (resolve) => { - if (!whisperWorker) { - whisperWorker = new Worker(new URL('./worker.ts', import.meta.url), { type: 'module' }); - } + whisperWorker = new WhisperWorker(); whisperWorker.onmessage = async (e) => { if (e.data.type === "loaded") { diff --git a/src/services/summarization/summarization.ts b/src/services/summarization/summarization.ts index 10caf38..18779bb 100644 --- a/src/services/summarization/summarization.ts +++ b/src/services/summarization/summarization.ts @@ -1,9 +1,12 @@ let summaryWorker: Worker; +// @ts-ignore +import SummaryWorker from './summary-worker?worker&inline'; + export async function loadSummarizer(model: string = "Xenova/distilbart-cnn-6-6"): Promise { return new Promise(async (resolve) => { if (!summaryWorker) { - summaryWorker = new Worker(new URL('./summary-worker.ts', import.meta.url), { type: 'module' }); + summaryWorker = new SummaryWorker(); } summaryWorker.onmessage = async (e) => { diff --git a/src/services/text-to-speech/text-to-speech.ts b/src/services/text-to-speech/text-to-speech.ts index 354843d..b01001c 100644 --- a/src/services/text-to-speech/text-to-speech.ts +++ b/src/services/text-to-speech/text-to-speech.ts @@ -1,9 +1,12 @@ let ttsWorker: Worker; +// @ts-ignore +import TTSWorker from './tts-worker?worker&inline'; + export async function loadTTS(model: string = "Xenova/mms-tts-eng"): Promise { return new Promise(async (resolve) => { if (!ttsWorker) { - ttsWorker = new Worker(new URL('./tts-worker.ts', import.meta.url), { type: 'module' }); + ttsWorker = new TTSWorker(); } ttsWorker.onmessage = async (e) => { diff --git a/vite.config.ts b/vite.config.ts index ebe7678..2c6fd04 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -12,9 +12,9 @@ export default defineConfig({ target: "es2022", } }, - publicDir: 'dist', build: { sourcemap: false, + assetsDir: "code", cssMinify: true, target: "esnext", lib: { @@ -28,9 +28,6 @@ export default defineConfig({ }, } }, - server: { - open: '/test.html', - }, plugins: [ dts({ rollupTypes: true