subtitle

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package subtitle generates SRT and WebVTT subtitles from STT transcription results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSRT

func GenerateSRT(result *stt.TranscriptionResult, opts Options) string

GenerateSRT generates SRT subtitle content from a transcription result.

func GenerateVTT

func GenerateVTT(result *stt.TranscriptionResult, opts Options) string

GenerateVTT generates WebVTT subtitle content from a transcription result.

func SaveSRT

func SaveSRT(result *stt.TranscriptionResult, filePath string, opts Options) error

SaveSRT generates and saves SRT content to a file.

func SaveVTT

func SaveVTT(result *stt.TranscriptionResult, filePath string, opts Options) error

SaveVTT generates and saves WebVTT content to a file.

Types

type Format

type Format int

Format represents the output format for subtitles.

const (
	// FormatSRT is the SubRip subtitle format.
	FormatSRT Format = iota
	// FormatVTT is the WebVTT subtitle format.
	FormatVTT
)

type Options

type Options struct {
	// MaxCharsPerLine limits characters per subtitle line.
	// Default: 42 (standard for readability).
	MaxCharsPerLine int

	// MaxLinesPerCue limits lines per subtitle cue.
	// Default: 2.
	MaxLinesPerCue int

	// MaxDuration limits the maximum duration for a single cue.
	// Default: 7 seconds.
	MaxDuration time.Duration

	// MinDuration sets the minimum duration for a cue to be readable.
	// Default: 1 second.
	MinDuration time.Duration

	// IncludeSpeakerLabels adds speaker labels to cues.
	IncludeSpeakerLabels bool
}

Options configures subtitle generation.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns sensible defaults for subtitle generation.

Jump to

Keyboard shortcuts

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