expose diarization support checking function
All checks were successful
Publish Library / Build NPM Project (push) Successful in 25s
Publish Library / Tag Version (push) Successful in 5s

This commit is contained in:
2026-02-12 11:55:29 -05:00
parent 54730a2b9a
commit 46ae0f7913
2 changed files with 3 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@ztimson/ai-utils", "name": "@ztimson/ai-utils",
"version": "0.6.0", "version": "0.6.1",
"description": "AI Utility library", "description": "AI Utility library",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",

View File

@@ -33,7 +33,7 @@ export class Audio {
return lines.join('\n'); return lines.join('\n');
} }
private async isPyannoteInstalled(): Promise<boolean> { async canDiarization(): Promise<boolean> {
return new Promise((resolve) => { return new Promise((resolve) => {
const proc = spawn('python3', ['-c', 'import pyannote.audio']); const proc = spawn('python3', ['-c', 'import pyannote.audio']);
proc.on('close', (code: number) => resolve(code === 0)); proc.on('close', (code: number) => resolve(code === 0));
@@ -42,7 +42,7 @@ export class Audio {
} }
private async runDiarization(audioPath: string): Promise<any[]> { private async runDiarization(audioPath: string): Promise<any[]> {
if(!await this.isPyannoteInstalled()) throw new Error('Pyannote is not installed: pip install pyannote.audio'); if(!await this.canDiarization()) throw new Error('Pyannote is not installed: pip install pyannote.audio');
const script = ` const script = `
import sys import sys
import json import json