transcript

package
v0.50.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (

	// MaxSuggestions bounds the answer (SDD-023 section 8).
	MaxSuggestions = 2000
)

Variables

This section is empty.

Functions

func Follows

func Follows(it *timeline.Item) bool

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

func HasFillerRules(language string) bool

HasFillerRules reports whether the language has a list of filler words; without one only repetitions are checked.

func Locate

func Locate(it *timeline.Item, from, to int) (start, end int, ok bool)

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

func Normalize(s string) string

Normalize lowercases a word and strips punctuation and symbols; letters, digits and inner apostrophes stay.

func RuleDescription

func RuleDescription(language string) string

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

func Shows(it *timeline.Item, assetID string) bool

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

func SourceRange(it *timeline.Item) (start, end int)

SourceRange is the visible source range of an item, [SourceIn, SourceIn + ceil(duration x speed)), in asset frames.

Types

type Kind

type Kind string

Kind says what a suggestion found.

const (
	KindFiller     Kind = "filler"
	KindRepetition Kind = "repetition"
)

The two kinds of suggestion.

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.

const (
	Strong Strength = "strong"
	Weak   Strength = "weak"
)

The two strengths.

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.

func Map

func Map(doc *timeline.Document, assetID string, words []Word) View

Map places the words of a transcript on the timeline: for each word, the range of every item of the asset that shows it. It is a pure function of the document and the transcript and is recomputed after every edit.

type Word

type Word struct {
	Text  string `json:"text"`
	Start int    `json:"start"`
	End   int    `json:"end"`
}

Word is a transcript word on the asset's time axis, in frames, half-open.

type WordRanges

type WordRanges struct {
	Index  int     `json:"index"`
	Text   string  `json:"text"`
	Start  int     `json:"start"`
	End    int     `json:"end"`
	Ranges []Range `json:"ranges"`
}

WordRanges is a word with the ranges of the timeline that show it. A word with no range was cut, or lies outside every item.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL