Implemented a bugfix for the whisperx stage, and added corresponding regression tests
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/analyzer"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/audita"
|
||||
@@ -51,7 +52,11 @@ func executeStages(ctx context.Context, cfg *config.Config, stages []stage.Stage
|
||||
env.Logger = logging.NewLogger(os.Stderr, slog.LevelInfo)
|
||||
}
|
||||
if env.WhisperX == nil {
|
||||
env.WhisperX = &whisperx.NoopClient{}
|
||||
client, err := buildDefaultWhisperXClient(env.Config)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("initialize whisperx client: %w", err)
|
||||
}
|
||||
env.WhisperX = client
|
||||
}
|
||||
if env.Seriatim == nil {
|
||||
env.Seriatim = &seriatim.NoopRunner{}
|
||||
@@ -145,6 +150,35 @@ func executeStages(ctx context.Context, cfg *config.Config, stages []stage.Stage
|
||||
}, nil
|
||||
}
|
||||
|
||||
func buildDefaultWhisperXClient(cfg *config.Config) (whisperx.Client, error) {
|
||||
if cfg == nil || cfg.Pipeline == nil {
|
||||
return &whisperx.NoopClient{}, nil
|
||||
}
|
||||
|
||||
wx := cfg.Pipeline.WhisperX
|
||||
if strings.TrimSpace(wx.TranscribeURL) == "" {
|
||||
// Compatibility fallback for tests or internal call paths that bypass config validation.
|
||||
return &whisperx.NoopClient{}, nil
|
||||
}
|
||||
|
||||
retries := 0
|
||||
if wx.Retries != nil {
|
||||
retries = *wx.Retries
|
||||
}
|
||||
|
||||
client, err := whisperx.NewHTTPClientFromConfigValues(
|
||||
wx.TranscribeURL,
|
||||
wx.Language,
|
||||
wx.Timeout,
|
||||
wx.RetryDelay,
|
||||
retries,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("from pipeline.whisperx: %w", err)
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func loadOrCreateManifest(ctx context.Context, store manifest.Store, path, sessionID string) (*manifest.Manifest, error) {
|
||||
exists, err := fileExists(path)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user