Allow checkpoints for empty audio accepted by WhisperX

This commit is contained in:
2026-09-22 00:53:28 +00:00
parent 54d335c820
commit 5dca34e0e0
5 changed files with 76 additions and 9 deletions

View File

@@ -18,6 +18,57 @@ import (
"gitea.maximumdirect.net/eric/narratio/internal/stage"
)
func TestExecuteStagesDelegatesEmptyAudioAcceptanceToWhisperX(t *testing.T) {
for _, rejected := range []bool{false, true} {
name := "accepted"
if rejected {
name = "rejected"
}
t.Run(name, func(t *testing.T) {
cfg, store := setupTranscribeRecoveryFixture(t, []string{"alice"})
paths := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root).SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)
if err := os.WriteFile(filepath.Join(paths.AudioDir, "alice.flac"), nil, 0o644); err != nil {
t.Fatal(err)
}
fake := &whisperx.FakeClient{}
if rejected {
fake.Err = errors.New("service rejected audio")
}
transcribe := mustSelectStage(t, "transcribe")
_, err := executeStages(context.Background(), cfg, []stage.Stage{transcribe}, RunOptions{
Env: &Env{ManifestStore: store, WhisperX: fake},
})
if !errors.Is(err, fake.Err) {
t.Fatalf("transcribe error = %v, want %v", err, fake.Err)
}
if len(fake.RequestsSnapshot()) != 1 {
t.Fatal("empty audio was not sent to service")
}
m := loadTranscribeRecoveryManifest(t, store, cfg)
if rejected {
if len(m.Stages["transcribe"].TranscribeSpeakers) != 0 {
t.Fatal("rejected audio was checkpointed")
}
return
}
record, ok := m.Stages["transcribe"].TranscribeSpeakers["alice"]
if !ok || record.AudioSize != 0 {
t.Fatalf("missing zero-size checkpoint: %#v", record)
}
retry := &whisperx.FakeClient{}
summary, err := executeStages(context.Background(), cfg, []stage.Stage{transcribe}, RunOptions{
Env: &Env{ManifestStore: store, WhisperX: retry},
})
if err != nil {
t.Fatal(err)
}
if len(summary.Skipped) != 1 || len(retry.RequestsSnapshot()) != 0 {
t.Fatal("successful empty-audio result was not reused")
}
})
}
}
func TestExecuteStagesRetriesOnlyUncommittedTranscribeSpeakers(t *testing.T) {
cfg, baseStore := setupTranscribeRecoveryFixture(t, []string{"a", "b", "c", "d"})
concurrency := 1