go-whisper-api/whisper/format_test.go
admin b5c083e06f
Some checks failed
CodeQL / Analyze (go) (push) Successful in 6m28s
Docker Image / build-docker (push) Failing after 13m26s
Lint and Testing / lint (push) Successful in 11m17s
Lint and Testing / test (push) Successful in 11m17s
Lint and Testing / golangci (push) Successful in 2m40s
first commit
2026-06-04 18:10:52 +07:00

41 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)
}
}