ASR debugging
All checks were successful
Publish Library / Build NPM Project (push) Successful in 30s
Publish Library / Tag Version (push) Successful in 7s

This commit is contained in:
2025-12-13 22:31:54 -05:00
parent 904cc10639
commit af4b09173c
2 changed files with 6 additions and 4 deletions

View File

@@ -43,11 +43,13 @@ export class Ai {
*/
async asr(path: string, model?: WhisperModel): Promise<string | null> {
if(!this.options.whisper?.binary) throw new Error('Whisper not configured');
await this.downloadAsrModel(model);
const m = await this.downloadAsrModel(model);
const name = Math.random().toString(36).substring(2, 10) + '-' + path.split('/').pop() + '.txt';
const output = Path.join(this.options.whisper.temp || '/tmp', name);
console.log(`rm -f ${output} && ${this.options.whisper.binary} -nt -np -m ${model ? Path.join(this.options.whisper.path, model) : this.whisperModel} -f ${path} -otxt -of ${output}`);
await $`rm -f ${output} && ${this.options.whisper.binary} -nt -np -m ${model ? Path.join(this.options.whisper.path, model) : this.whisperModel} -f ${path} -otxt -of ${output}`;
console.log('model:', this.options.whisper?.model);
console.log(this.whisperModel);
console.log(`rm -f ${output} && ${this.options.whisper.binary} -nt -np -m ${m} -f ${path} -otxt -of ${output}`);
await $`rm -f ${output} && ${this.options.whisper.binary} -nt -np -m ${m} -f ${path} -otxt -of ${output}`;
return fs.readFile(output, 'utf-8').then(text => text?.trim() || null)
.finally(() => fs.rm(output, {force: true}).catch(() => {}));
}