Updataes?
All checks were successful
Publish Library / Build NPM Project (push) Successful in 26s
Publish Library / Tag Version (push) Successful in 5s

This commit is contained in:
2026-02-12 20:14:00 -05:00
parent ad1ee48763
commit e4399e1b7b
4 changed files with 12 additions and 15 deletions

View File

@@ -82,12 +82,12 @@ function combineSpeakerTranscript(chunks: any[], speakers: any[]): string {
return lines.join('\n');
}
parentPort?.on('message', async ({ path, model, speaker, torchHome }) => {
parentPort?.on('message', async ({ file, speaker, model, modelDir }) => {
try {
if(!whisperPipeline) whisperPipeline = await pipeline('automatic-speech-recognition', `Xenova/${model}`, {cache_dir: torchHome, quantized: true});
if(!whisperPipeline) whisperPipeline = await pipeline('automatic-speech-recognition', `Xenova/${model}`, {cache_dir: modelDir, quantized: true});
// Prepare audio file (convert to mono channel wave)
const wav = new wavefile.WaveFile(fs.readFileSync(path));
const wav = new wavefile.WaveFile(fs.readFileSync(file));
wav.toBitDepth('32f');
wav.toSampleRate(16000);
const samples = wav.getSamples();
@@ -111,11 +111,11 @@ parentPort?.on('message', async ({ path, model, speaker, torchHome }) => {
// Speaker Diarization
const hasDiarization = await canDiarization();
if(!hasDiarization) {
parentPort?.postMessage({ text: transcriptResult.text?.trim() || null, warning: 'Speaker diarization unavailable' });
parentPort?.postMessage({ text: transcriptResult.text?.trim() || null, error: 'Speaker diarization unavailable' });
return;
}
const speakers = await runDiarization(path, torchHome);
const speakers = await runDiarization(file, modelDir);
const combined = combineSpeakerTranscript(transcriptResult.chunks || [], speakers);
parentPort?.postMessage({ text: combined });
} catch (err) {