Documentation
¶
Overview ¶
Package transcript holds the rules of editing by text (SDD-023): the mapping from the words of a transcript to the ranges of the timeline that show them, and the detection of filler words and repetitions. It is pure: no I/O, no clock, no model. The commands that cut live in core/command and the service reads the transcript; this package only answers questions about words.
Index ¶
- Constants
- func Follows(it *timeline.Item) bool
- func HasFillerRules(language string) bool
- func Locate(it *timeline.Item, from, to int) (start, end int, ok bool)
- func Normalize(s string) string
- func RuleDescription(language string) string
- func Shows(it *timeline.Item, assetID string) bool
- func SourceRange(it *timeline.Item) (start, end int)
- type Kind
- type Options
- type Range
- type SpokenWord
- type Strength
- type Suggestion
- type View
- type Word
- type WordRanges
Constants ¶
const (
// MaxSuggestions bounds the answer (SDD-023 section 8).
MaxSuggestions = 2000
)
Variables ¶
This section is empty.
Functions ¶
func Follows ¶
Follows reports whether the item plays its source forward at a constant speed, so that a source frame maps to one frame of the timeline.
func HasFillerRules ¶
HasFillerRules reports whether the language has a list of filler words; without one only repetitions are checked.
func Locate ¶
Locate maps the source range [from, to) of an item to the timeline, as caption.from_transcript does (SDD-002 C.40): the start rounds up, the end is capped at the visible range and at the end of the item, and the result is at least one frame. ok is false when from is outside the visible range.
func Normalize ¶
Normalize lowercases a word and strips punctuation and symbols; letters, digits and inner apostrophes stay.
func RuleDescription ¶
RuleDescription says in one sentence what Detect checks for a language, so that an empty list is not read as "there are no fillers".
func Shows ¶
Shows reports whether an item plays the sound or the picture of the asset: a clip or an audio item of it, not a freeze frame (which shows one source frame and has no sound).
func SourceRange ¶
SourceRange is the visible source range of an item, [SourceIn, SourceIn + ceil(duration x speed)), in asset frames.
Types ¶
type Options ¶
type Options struct {
// Language is the ISO 639-1 code of the transcript. An unlisted language has no filler rule.
Language string
// RepeatWindowMS is the longest gap between the two copies of a repetition. Default 700.
RepeatWindowMS int64
}
Options of Detect. The zero value is the default.
type Range ¶
type Range struct {
ItemID string `json:"item_id"`
TrackID string `json:"track_id"`
Start int `json:"start"`
End int `json:"end"`
}
Range is where an item of the timeline shows a word, in timeline frames, half-open.
type SpokenWord ¶
type SpokenWord struct {
Text string `json:"text"`
StartMS int64 `json:"start_ms"`
EndMS int64 `json:"end_ms"`
}
SpokenWord is a transcript word with its time in milliseconds, as the transcript artifact has it (SDD-011 section 10.5). Detection reads milliseconds so that it does not depend on a frame rate.
type Strength ¶
type Strength string
Strength says how sure the rule is. A strong suggestion is shown checked in the review, a weak one unchecked.
type Suggestion ¶
type Suggestion struct {
Kind Kind `json:"kind"`
Strength Strength `json:"strength"`
FromWord int `json:"from_word"`
ToWord int `json:"to_word"`
Text string `json:"text"`
StartMS int64 `json:"start_ms"`
EndMS int64 `json:"end_ms"`
}
Suggestion is a range of words a person may remove. It changes nothing by itself.
func Detect ¶
func Detect(words []SpokenWord, opts Options) []Suggestion
Detect finds the filler words and the repetitions of a transcript (SDD-023 section 4). It is a pure function: the same words and options give the same suggestions, ordered by first word, not overlapping, at most MaxSuggestions.
func DetectShown ¶
func DetectShown(words []SpokenWord, shown []bool, opts Options) []Suggestion
DetectShown is Detect over the words the timeline still shows: shown[i] says whether word i has a range. A word already cut cannot be removed again, and two copies that a cut made adjacent are a repetition. The indices of the suggestions are those of words.
type View ¶
type View struct {
Words []WordRanges `json:"words"`
// Skipped are the items that show the asset and cannot map a frame of the timeline to a frame of the
// source: an item with a speed curve or one that plays backwards.
Skipped []string `json:"skipped_items"`
}
View is the result of Map.