Skip to content

Commit

Permalink
chore(transcription): assert path to model is a directory for CTransl…
Browse files Browse the repository at this point in the history
…ate2 transcriber

chore(transcription): ctranslate2 assertion

chore(transcription): ctranslate2 assertion
  • Loading branch information
lutangar committed May 31, 2024
1 parent 57b9055 commit 6769134
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ describe('Whisper CTranslate2 transcriber', function () {
this.timeout(5 * 1000 * 60)
const transcribeArgs: WhisperTranscribeArgs = {
mediaFilePath: frVideoPath,
model: await TranscriptionModel.fromPath(buildAbsoluteFixturePath('transcription/models/tiny.pt')),
language: 'fr',
format: 'txt'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { lstat } from 'node:fs/promises'
import { OpenaiTranscriber, WhisperTranscribeArgs } from './openai-transcriber.js'
import { TranscriptFile } from '../../transcript/index.js'
import { WhisperBuiltinModel } from '../whisper-builtin-model.js'
import assert from 'node:assert'

export class Ctranslate2Transcriber extends OpenaiTranscriber {
async transcribe ({
Expand All @@ -20,7 +21,7 @@ export class Ctranslate2Transcriber extends OpenaiTranscriber {
const $$ = $({ verbose: true })

if (model.path) {
await lstat(model.path).then(stats => stats.isDirectory())
assert(await lstat(model.path).then(stats => stats.isDirectory()), 'Model path must be a path to a directory.')
}

const modelArgs = model.path ? [ '--model_directory', model.path ] : [ '--model', model.name ]
Expand Down

0 comments on commit 6769134

Please sign in to comment.