Added initial segment overlap resolution logic
This commit is contained in:
@@ -11,6 +11,7 @@ type RawSegment struct {
|
||||
Start float64 `json:"start"`
|
||||
End float64 `json:"end"`
|
||||
Text string `json:"text"`
|
||||
Words []Word `json:"words,omitempty"`
|
||||
}
|
||||
|
||||
// CanonicalTranscript is a per-speaker transcript in seriatim's internal model.
|
||||
@@ -45,16 +46,18 @@ type OutputMetadata struct {
|
||||
|
||||
// Segment is the canonical transcript segment shape used by the framework.
|
||||
type Segment struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
InternalRef string `json:"internal_ref,omitempty"`
|
||||
Source string `json:"source"`
|
||||
SourceSegmentIndex int `json:"source_segment_index"`
|
||||
Speaker string `json:"speaker"`
|
||||
Start float64 `json:"start"`
|
||||
End float64 `json:"end"`
|
||||
Text string `json:"text"`
|
||||
Words []Word `json:"words,omitempty"`
|
||||
OverlapGroupID int `json:"overlap_group_id,omitempty"`
|
||||
ID int `json:"id,omitempty"`
|
||||
InternalRef string `json:"internal_ref,omitempty"`
|
||||
Source string `json:"source"`
|
||||
SourceSegmentIndex *int `json:"source_segment_index,omitempty"`
|
||||
SourceRef string `json:"source_ref,omitempty"`
|
||||
DerivedFrom []string `json:"derived_from,omitempty"`
|
||||
Speaker string `json:"speaker"`
|
||||
Start float64 `json:"start"`
|
||||
End float64 `json:"end"`
|
||||
Text string `json:"text"`
|
||||
Words []Word `json:"words,omitempty"`
|
||||
OverlapGroupID int `json:"overlap_group_id,omitempty"`
|
||||
}
|
||||
|
||||
// Word preserves optional word-level timing data.
|
||||
@@ -64,6 +67,7 @@ type Word struct {
|
||||
End float64 `json:"end"`
|
||||
Score float64 `json:"score,omitempty"`
|
||||
Speaker string `json:"speaker,omitempty"`
|
||||
Timed bool `json:"-"`
|
||||
}
|
||||
|
||||
// OverlapGroup describes a detected overlapping speech region.
|
||||
@@ -76,3 +80,30 @@ type OverlapGroup struct {
|
||||
Class string `json:"class"`
|
||||
Resolution string `json:"resolution"`
|
||||
}
|
||||
|
||||
// SegmentLess defines the deterministic chronological ordering used by merge
|
||||
// and postprocessing modules.
|
||||
func SegmentLess(left Segment, right Segment) bool {
|
||||
if left.Start != right.Start {
|
||||
return left.Start < right.Start
|
||||
}
|
||||
if left.End != right.End {
|
||||
return left.End < right.End
|
||||
}
|
||||
if left.Source != right.Source {
|
||||
return left.Source < right.Source
|
||||
}
|
||||
if left.SourceSegmentIndex != nil && right.SourceSegmentIndex != nil && *left.SourceSegmentIndex != *right.SourceSegmentIndex {
|
||||
return *left.SourceSegmentIndex < *right.SourceSegmentIndex
|
||||
}
|
||||
if left.SourceSegmentIndex == nil && right.SourceSegmentIndex != nil {
|
||||
return false
|
||||
}
|
||||
if left.SourceSegmentIndex != nil && right.SourceSegmentIndex == nil {
|
||||
return true
|
||||
}
|
||||
if left.SourceRef != right.SourceRef {
|
||||
return left.SourceRef < right.SourceRef
|
||||
}
|
||||
return left.Speaker < right.Speaker
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user