Skip to content

Commit

Permalink
Merge pull request #7 from jgw96/revert-6-master
Browse files Browse the repository at this point in the history
Revert "fix: replace inline worker with url + vite serve"
  • Loading branch information
jgw96 authored Sep 25, 2024
2 parents ec4abaa + a2bd042 commit a663e84
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion src/services/ocr/ocr.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
let ocrWorker: Worker;

// @ts-ignore
import OCRWorker from './ocr-worker?worker&inline';

export async function loadOCR(model: string): Promise<void> {
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) => {
Expand Down
7 changes: 4 additions & 3 deletions src/services/speech-recognition/whisper-ai.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
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") {
Expand Down
5 changes: 4 additions & 1 deletion src/services/summarization/summarization.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
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) => {
Expand Down
5 changes: 4 additions & 1 deletion src/services/text-to-speech/text-to-speech.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
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) => {
Expand Down
5 changes: 1 addition & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export default defineConfig({
target: "es2022",
}
},
publicDir: 'dist',
build: {
sourcemap: false,
assetsDir: "code",
cssMinify: true,
target: "esnext",
lib: {
Expand All @@ -28,9 +28,6 @@ export default defineConfig({
},
}
},
server: {
open: '/test.html',
},
plugins: [
dts({
rollupTypes: true
Expand Down

0 comments on commit a663e84

Please sign in to comment.