Add WhisperX configuration contract
This commit is contained in:
@@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -32,10 +33,10 @@ func validatePipeline(cfg *PipelineConfig) error {
|
||||
if strings.TrimSpace(cfg.Workspace.Root) == "" {
|
||||
return fmt.Errorf("pipeline.workspace.root is required")
|
||||
}
|
||||
|
||||
if err := validateDuration("pipeline.whisperx.timeout", cfg.WhisperX.Timeout); err != nil {
|
||||
if err := validateWhisperX(cfg.WhisperX); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateDuration("pipeline.seriatim.timeout", cfg.Seriatim.Timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -52,6 +53,38 @@ func validatePipeline(cfg *PipelineConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateWhisperX(cfg WhisperXConfig) error {
|
||||
if strings.TrimSpace(cfg.TranscribeURL) == "" {
|
||||
return fmt.Errorf("pipeline.whisperx.transcribe_url is required")
|
||||
}
|
||||
u, err := url.Parse(cfg.TranscribeURL)
|
||||
if err != nil || u.Scheme == "" || u.Host == "" {
|
||||
if err != nil {
|
||||
return fmt.Errorf("pipeline.whisperx.transcribe_url must be a valid URL: %w", err)
|
||||
}
|
||||
return fmt.Errorf("pipeline.whisperx.transcribe_url must be a valid URL")
|
||||
}
|
||||
if err := validateDuration("pipeline.whisperx.timeout", cfg.Timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateDuration("pipeline.whisperx.retry_delay", cfg.RetryDelay); err != nil {
|
||||
return err
|
||||
}
|
||||
if cfg.Retries == nil {
|
||||
return fmt.Errorf("pipeline.whisperx.retries must be set (defaults should populate this)")
|
||||
}
|
||||
if *cfg.Retries < 0 {
|
||||
return fmt.Errorf("pipeline.whisperx.retries must be >= 0")
|
||||
}
|
||||
if cfg.Concurrency == nil {
|
||||
return fmt.Errorf("pipeline.whisperx.concurrency must be set (defaults should populate this)")
|
||||
}
|
||||
if *cfg.Concurrency <= 0 {
|
||||
return fmt.Errorf("pipeline.whisperx.concurrency must be > 0")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateSession(cfg *SessionConfig) error {
|
||||
if strings.TrimSpace(cfg.SessionID) == "" {
|
||||
return fmt.Errorf("session.session_id is required")
|
||||
|
||||
Reference in New Issue
Block a user