public final class TranscriptionResult

  1. Object
  2. TranscriptionResult
A complete transcription: plain text plus the timed segments needed for captions.

Constructors

public TranscriptionResult(List<TranscriptionSegment> segments)Creates a transcription result from timed segments.

Methods

public static TranscriptionResult textOnly(String text)Creates a text-only result for providers that do not expose segment timing.
public List<TranscriptionSegment> getSegments()Gets the ordered timed transcript segments.
public String getText()Gets the plain transcript text.
public String toSrt()Formats this transcription as SubRip captions.
public String toVtt()Formats this transcription as WebVTT captions.

Inherited methods

Constructor details

TranscriptionResult

public TranscriptionResult(List<TranscriptionSegment> segments)

Creates a transcription result from timed segments.

The supplied list is copied, validated, and exposed through getSegments() as an immutable list. The plain text returned by getText() is the concatenation of each segment’s text in order.

Parameters

segments List<TranscriptionSegment>
ordered transcript segments

Throws

IllegalArgumentException
if segments is null or contains null

Method details

textOnly

public static TranscriptionResult textOnly(String text)

Creates a text-only result for providers that do not expose segment timing.

The returned result contains one segment from 0 to 0 milliseconds.

Parameters

text String
recognized text

Returns

a transcription result containing one untimed segment

getSegments

public List<TranscriptionSegment> getSegments()
Gets the ordered timed transcript segments.

Returns

immutable segment list

getText

public String getText()
Gets the plain transcript text.

Returns

transcript text, never null

toSrt

public String toSrt()
Formats this transcription as SubRip captions.

Returns

SRT text using millisecond timestamps

toVtt

public String toVtt()
Formats this transcription as WebVTT captions.

Returns

WebVTT text using millisecond timestamps