From 0172887877e695e1b678179ed0aea44b92e9f880 Mon Sep 17 00:00:00 2001 From: ztimson Date: Thu, 12 Feb 2026 20:24:12 -0500 Subject: [PATCH] audio worker fix --- package.json | 2 +- src/audio.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index d249597..4750e83 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ztimson/ai-utils", - "version": "0.6.8", + "version": "0.6.9", "description": "AI Utility library", "author": "Zak Timson", "license": "MIT", diff --git a/src/audio.ts b/src/audio.ts index 21cf027..c7fe00f 100644 --- a/src/audio.ts +++ b/src/audio.ts @@ -1,19 +1,19 @@ +import {fileURLToPath} from 'url'; import {Worker} from 'worker_threads'; -import Path from 'node:path'; import {AbortablePromise, Ai} from './ai.ts'; import {canDiarization} from './asr.ts'; +import {dirname, join} from 'path'; export class Audio { constructor(private ai: Ai) {} asr(file: string, options: { model?: string; speaker?: boolean } = {}): AbortablePromise { - console.log('audio', file); const { model = this.ai.options.asr || 'whisper-base', speaker = false } = options; let aborted = false; const abort = () => { aborted = true; }; const p = new Promise((resolve, reject) => { - const worker = new Worker(Path.join(import.meta.dirname, 'asr.js')); + const worker = new Worker(join(dirname(fileURLToPath(import.meta.url)), 'asr.js')); const handleMessage = ({ text, warning, error }: any) => { worker.terminate(); if(aborted) return;