Pad audio before WhisperX transcription
All checks were successful
CI / test (push) Successful in 16s
Build and Deploy / build-and-deploy (push) Successful in 28s

This commit is contained in:
Grendgi
2026-06-08 23:09:02 +03:00
parent 16ff6ecb5e
commit 8a2fef5a24
6 changed files with 166 additions and 24 deletions

View File

@@ -0,0 +1,28 @@
package transcription
import (
"math"
"testing"
"time"
)
func TestAdjustLeadSilence(t *testing.T) {
got := adjustLeadSilence([]Segment{
{Start: 0.2, End: 1.1, Text: "first"},
{Start: 1.4, End: 2.0, Text: "second"},
}, 800*time.Millisecond)
if got[0].Start != 0 {
t.Fatalf("first start = %v, want 0", got[0].Start)
}
if !near(got[0].End, 0.3) {
t.Fatalf("first end = %v, want 0.3", got[0].End)
}
if !near(got[1].Start, 0.6) {
t.Fatalf("second start = %v, want 0.6", got[1].Start)
}
}
func near(got, want float64) bool {
return math.Abs(got-want) < 0.000001
}