Class TranscriptionResult

java.lang.Object
com.codename1.media.TranscriptionResult

public final class TranscriptionResult extends Object
A complete transcription: plain text plus the timed segments needed for captions.
  • 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 - 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 - 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