package whisper import ( "testing" "time" wpkg "github.com/ggerganov/whisper.cpp/bindings/go/pkg/whisper" ) func TestFormatSegments_pauseAndSpeaker(t *testing.T) { segments := []wpkg.Segment{ {Text: " привет", Start: 0, End: 2 * time.Second}, {Text: " мир", Start: 4 * time.Second, End: 5 * time.Second}, {Text: " ответ", Start: 6 * time.Second, End: 8 * time.Second}, } turns := []Turn{ {Start: 0, End: 5.5, Speaker: 0}, {Start: 5.5, End: 10, Speaker: 1}, } got := FormatSegments(segments, turns, FormatOptions{ PauseGap: 1500 * time.Millisecond, SpeakerLabel: "Спикер", UseSpeakers: true, }) want := "Спикер 1: привет\nмир\n\nСпикер 2: ответ" if got != want { t.Fatalf("got %q\nwant %q", got, want) } } func TestFormatSegments_noSpeakers(t *testing.T) { segments := []wpkg.Segment{ {Text: "a", Start: 0, End: time.Second}, {Text: "b", Start: 3 * time.Second, End: 4 * time.Second}, } got := FormatSegments(segments, nil, FormatOptions{PauseGap: time.Second, UseSpeakers: false}) if got != "a\nb" { t.Fatalf("got %q", got) } }