Pad audio before WhisperX transcription
This commit is contained in:
28
internal/transcription/client_test.go
Normal file
28
internal/transcription/client_test.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user