Add WhisperX configuration contract
This commit is contained in:
@@ -14,13 +14,14 @@ func TestLoadAndValidate(t *testing.T) {
|
||||
sessionYAML string
|
||||
wantLoadErr string
|
||||
wantValidate string
|
||||
checkDefault bool
|
||||
}{
|
||||
{
|
||||
name: "valid minimal config",
|
||||
pipelineYAML: `workspace:
|
||||
root: /tmp/narratio
|
||||
whisperx:
|
||||
timeout: 10m
|
||||
transcribe_url: https://transcription.ai.rakestrawhome.com/transcribe
|
||||
seriatim:
|
||||
timeout: 30s
|
||||
audita:
|
||||
@@ -37,6 +38,7 @@ inputs:
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`,
|
||||
checkDefault: true,
|
||||
},
|
||||
{
|
||||
name: "unknown pipeline field fails",
|
||||
@@ -53,6 +55,23 @@ inputs:
|
||||
`,
|
||||
wantLoadErr: "pipeline file",
|
||||
},
|
||||
{
|
||||
name: "unknown whisperx field fails",
|
||||
pipelineYAML: `workspace:
|
||||
root: /tmp/narratio
|
||||
whisperx:
|
||||
transcribe_url: https://transcription.ai.rakestrawhome.com/transcribe
|
||||
bogus: true
|
||||
`,
|
||||
sessionYAML: `session_id: 2026-05-03
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`,
|
||||
wantLoadErr: "strict decode failed",
|
||||
},
|
||||
{
|
||||
name: "unknown session field fails",
|
||||
pipelineYAML: `workspace:
|
||||
@@ -72,6 +91,8 @@ unknown_field: true
|
||||
name: "missing required field fails",
|
||||
pipelineYAML: `workspace:
|
||||
root: /tmp/narratio
|
||||
whisperx:
|
||||
transcribe_url: https://transcription.ai.rakestrawhome.com/transcribe
|
||||
`,
|
||||
sessionYAML: `session_id: ""
|
||||
inputs:
|
||||
@@ -82,11 +103,43 @@ inputs:
|
||||
`,
|
||||
wantValidate: "session config \"session.yml\" invalid: session.session_id is required",
|
||||
},
|
||||
{
|
||||
name: "missing transcribe_url fails",
|
||||
pipelineYAML: `workspace:
|
||||
root: /tmp/narratio
|
||||
whisperx:
|
||||
`,
|
||||
sessionYAML: `session_id: 2026-05-03
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`,
|
||||
wantValidate: "pipeline config \"pipeline.yml\" invalid: pipeline.whisperx.transcribe_url is required",
|
||||
},
|
||||
{
|
||||
name: "invalid transcribe_url fails",
|
||||
pipelineYAML: `workspace:
|
||||
root: /tmp/narratio
|
||||
whisperx:
|
||||
transcribe_url: ://
|
||||
`,
|
||||
sessionYAML: `session_id: 2026-05-03
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`,
|
||||
wantValidate: "pipeline config \"pipeline.yml\" invalid: pipeline.whisperx.transcribe_url must be a valid URL",
|
||||
},
|
||||
{
|
||||
name: "invalid timeout fails",
|
||||
pipelineYAML: `workspace:
|
||||
root: /tmp/narratio
|
||||
whisperx:
|
||||
transcribe_url: https://transcription.ai.rakestrawhome.com/transcribe
|
||||
timeout: definitely-not-a-duration
|
||||
`,
|
||||
sessionYAML: `session_id: 2026-05-03
|
||||
@@ -98,6 +151,57 @@ inputs:
|
||||
`,
|
||||
wantValidate: "pipeline config \"pipeline.yml\" invalid: pipeline.whisperx.timeout must be a valid duration",
|
||||
},
|
||||
{
|
||||
name: "invalid retry_delay fails",
|
||||
pipelineYAML: `workspace:
|
||||
root: /tmp/narratio
|
||||
whisperx:
|
||||
transcribe_url: https://transcription.ai.rakestrawhome.com/transcribe
|
||||
retry_delay: not-a-duration
|
||||
`,
|
||||
sessionYAML: `session_id: 2026-05-03
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`,
|
||||
wantValidate: "pipeline config \"pipeline.yml\" invalid: pipeline.whisperx.retry_delay must be a valid duration",
|
||||
},
|
||||
{
|
||||
name: "negative retries fails",
|
||||
pipelineYAML: `workspace:
|
||||
root: /tmp/narratio
|
||||
whisperx:
|
||||
transcribe_url: https://transcription.ai.rakestrawhome.com/transcribe
|
||||
retries: -1
|
||||
`,
|
||||
sessionYAML: `session_id: 2026-05-03
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`,
|
||||
wantValidate: "pipeline config \"pipeline.yml\" invalid: pipeline.whisperx.retries must be >= 0",
|
||||
},
|
||||
{
|
||||
name: "invalid concurrency fails",
|
||||
pipelineYAML: `workspace:
|
||||
root: /tmp/narratio
|
||||
whisperx:
|
||||
transcribe_url: https://transcription.ai.rakestrawhome.com/transcribe
|
||||
concurrency: 0
|
||||
`,
|
||||
sessionYAML: `session_id: 2026-05-03
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`,
|
||||
wantValidate: "pipeline config \"pipeline.yml\" invalid: pipeline.whisperx.concurrency must be > 0",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
@@ -127,6 +231,23 @@ inputs:
|
||||
if cfg.SessionPath != sessionPath {
|
||||
t.Fatalf("SessionPath = %q, want %q", cfg.SessionPath, sessionPath)
|
||||
}
|
||||
if tt.checkDefault {
|
||||
if cfg.Pipeline.WhisperX.Language != "en" {
|
||||
t.Fatalf("whisperx.language = %q, want %q", cfg.Pipeline.WhisperX.Language, "en")
|
||||
}
|
||||
if cfg.Pipeline.WhisperX.Timeout != "30m" {
|
||||
t.Fatalf("whisperx.timeout = %q, want %q", cfg.Pipeline.WhisperX.Timeout, "30m")
|
||||
}
|
||||
if cfg.Pipeline.WhisperX.RetryDelay != "2s" {
|
||||
t.Fatalf("whisperx.retry_delay = %q, want %q", cfg.Pipeline.WhisperX.RetryDelay, "2s")
|
||||
}
|
||||
if cfg.Pipeline.WhisperX.Retries == nil || *cfg.Pipeline.WhisperX.Retries != 3 {
|
||||
t.Fatalf("whisperx.retries = %v, want 3", cfg.Pipeline.WhisperX.Retries)
|
||||
}
|
||||
if cfg.Pipeline.WhisperX.Concurrency == nil || *cfg.Pipeline.WhisperX.Concurrency != 2 {
|
||||
t.Fatalf("whisperx.concurrency = %v, want 2", cfg.Pipeline.WhisperX.Concurrency)
|
||||
}
|
||||
}
|
||||
|
||||
err = Validate(cfg)
|
||||
if tt.wantValidate != "" {
|
||||
@@ -146,8 +267,20 @@ inputs:
|
||||
}
|
||||
|
||||
func TestValidateMissingAudioSource(t *testing.T) {
|
||||
retries := 3
|
||||
concurrency := 2
|
||||
cfg := &Config{
|
||||
Pipeline: &PipelineConfig{Workspace: WorkspaceConfig{Root: "/tmp/narratio"}},
|
||||
Pipeline: &PipelineConfig{
|
||||
Workspace: WorkspaceConfig{Root: "/tmp/narratio"},
|
||||
WhisperX: WhisperXConfig{
|
||||
TranscribeURL: "https://transcription.ai.rakestrawhome.com/transcribe",
|
||||
Language: "en",
|
||||
Timeout: "30m",
|
||||
Retries: &retries,
|
||||
RetryDelay: "2s",
|
||||
Concurrency: &concurrency,
|
||||
},
|
||||
},
|
||||
Session: &SessionConfig{
|
||||
SessionID: "2026-05-03",
|
||||
Inputs: SessionInputsConfig{
|
||||
|
||||
Reference in New Issue
Block a user