Implemented a module to detect filler segments, and skip them for purposes of same-speaker segment coalescing
This commit is contained in:
@@ -91,6 +91,7 @@ func TestMergeWritesMergedOutputAndReport(t *testing.T) {
|
||||
"detect-overlaps",
|
||||
"resolve-overlaps",
|
||||
"backchannel",
|
||||
"filler",
|
||||
"coalesce",
|
||||
"detect-overlaps",
|
||||
"autocorrect",
|
||||
@@ -625,6 +626,45 @@ func TestMergeTagsBackchannelSegments(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeTagsFillerSegments(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
input := writeJSONFile(t, dir, "input.json", `{
|
||||
"segments": [
|
||||
{"start": 1, "end": 1.5, "text": " Um uh "},
|
||||
{"start": 6, "end": 7, "text": "not filler"}
|
||||
]
|
||||
}`)
|
||||
output := filepath.Join(dir, "merged.json")
|
||||
reportPath := filepath.Join(dir, "report.json")
|
||||
|
||||
err := executeMerge(
|
||||
"--input-file", input,
|
||||
"--output-file", output,
|
||||
"--report-file", reportPath,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("merge failed: %v", err)
|
||||
}
|
||||
|
||||
var transcript model.FinalTranscript
|
||||
readJSON(t, output, &transcript)
|
||||
if len(transcript.Segments) != 2 {
|
||||
t.Fatalf("segment count = %d, want 2", len(transcript.Segments))
|
||||
}
|
||||
if !equalStrings(transcript.Segments[0].Categories, []string{"filler"}) {
|
||||
t.Fatalf("segment categories = %v, want [filler]", transcript.Segments[0].Categories)
|
||||
}
|
||||
if len(transcript.Segments[1].Categories) != 0 {
|
||||
t.Fatalf("unexpected categories = %v", transcript.Segments[1].Categories)
|
||||
}
|
||||
|
||||
var rpt report.Report
|
||||
readJSON(t, reportPath, &rpt)
|
||||
if !hasReportEvent(rpt, "postprocessing", "filler", "tagged 1 filler segment(s)") {
|
||||
t.Fatal("expected filler report event")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeCoalescesAroundDifferentSpeakerBackchannel(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
inputA := writeJSONFile(t, dir, "a.json", `{
|
||||
@@ -672,6 +712,53 @@ func TestMergeCoalescesAroundDifferentSpeakerBackchannel(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeCoalescesAroundDifferentSpeakerFiller(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
inputA := writeJSONFile(t, dir, "a.json", `{
|
||||
"segments": [
|
||||
{"start": 1, "end": 2, "text": "first"},
|
||||
{"start": 3, "end": 4, "text": "second"}
|
||||
]
|
||||
}`)
|
||||
inputB := writeJSONFile(t, dir, "b.json", `{
|
||||
"segments": [
|
||||
{"start": 2.2, "end": 2.5, "text": "um"}
|
||||
]
|
||||
}`)
|
||||
speakers := writeYAMLFile(t, dir, "speakers.yml", `match:
|
||||
- speaker: Alice
|
||||
match: ["a.json"]
|
||||
- speaker: Bob
|
||||
match: ["b.json"]
|
||||
`)
|
||||
output := filepath.Join(dir, "merged.json")
|
||||
|
||||
err := executeMerge(
|
||||
"--input-file", inputA,
|
||||
"--input-file", inputB,
|
||||
"--speakers", speakers,
|
||||
"--output-file", output,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("merge failed: %v", err)
|
||||
}
|
||||
|
||||
var transcript model.FinalTranscript
|
||||
readJSON(t, output, &transcript)
|
||||
if len(transcript.Segments) != 2 {
|
||||
t.Fatalf("segment count = %d, want 2", len(transcript.Segments))
|
||||
}
|
||||
if transcript.Segments[0].Speaker != "Alice" || transcript.Segments[0].Text != "first second" {
|
||||
t.Fatalf("first segment = %#v, want coalesced Alice", transcript.Segments[0])
|
||||
}
|
||||
if len(transcript.Segments[0].Categories) != 0 {
|
||||
t.Fatalf("coalesced segment categories = %v, want none", transcript.Segments[0].Categories)
|
||||
}
|
||||
if transcript.Segments[1].Speaker != "Bob" || !equalStrings(transcript.Segments[1].Categories, []string{"filler"}) {
|
||||
t.Fatalf("second segment = %#v, want Bob filler", transcript.Segments[1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpeakerMatchingUsesFirstMatchingRuleCaseInsensitive(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
input := writeJSONFile(t, dir, "2026-04-19-Adam_Rakestraw.json", `{
|
||||
|
||||
Reference in New Issue
Block a user