subtitle

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 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 subtitle writes the segments of a transcript as subtitles, in SRT or WebVTT format, whose cues are the segments, in turn, until one is spoken by another speaker, or after a silence, or would make the cue too long, or have too much text, to read

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(w io.Writer, format Format, segments []llm.TranscriptSegment) error

Write writes the segments of a transcript as subtitles, in the format, which is SRT, or VTT, or returns an error for another format

Types

type Format

type Format string

Format is the format of subtitles

const (
	SRT Format = "srt" // SubRip
	VTT Format = "vtt" // WebVTT
)

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer writes the segments of a transcript as subtitles, in SRT, or WebVTT, format, as they're added, so they can be written as they're transcribed. A cue is the segments, in turn, until one is spoken by another speaker, or after a silence, or would make the cue too long, or have too much text, to read. A segment isn't split. Once a write fails, nothing more is written, and Add and Close return its error.

func NewWriter

func NewWriter(w io.Writer, format Format) (*Writer, error)

NewWriter returns a writer of subtitles, in the format, which is SRT, or VTT, or an error for another format

func (*Writer) Add

func (s *Writer) Add(segment llm.TranscriptSegment) error

Add adds the segment to the cue, or writes the cue, and starts another, when the segment ends it, returning an error when a cue can't be written

func (*Writer) Close

func (s *Writer) Close() error

Close writes the last cue, and the WebVTT header, when no cue was written, returning the first error writing the subtitles

Jump to

Keyboard shortcuts

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