Class OpenAiAudioTranscriptionResponseMetadata

java.lang.Object
org.springframework.ai.model.MutableResponseMetadata
org.springframework.ai.audio.transcription.AudioTranscriptionResponseMetadata
org.springframework.ai.openai.metadata.OpenAiAudioTranscriptionResponseMetadata
All Implemented Interfaces:
org.springframework.ai.model.ResponseMetadata

public class OpenAiAudioTranscriptionResponseMetadata extends org.springframework.ai.audio.transcription.AudioTranscriptionResponseMetadata
Audio transcription metadata implementation for OpenAI using the OpenAI Java SDK.

duration, usage and segment/word-level timestamps are only returned by the OpenAI API for the verbose_json and diarized_json response_format values; for other formats these accessors return null.

Author:
Christian Tzolov
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    OpenAiAudioTranscriptionResponseMetadata(@Nullable Double duration, @Nullable String language, @Nullable Object usage, @Nullable List<?> segments, @Nullable List<com.openai.models.audio.transcriptions.TranscriptionWord> words)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable Double
    Returns the audio duration in seconds, or null if not returned by the API.
    @Nullable String
    Returns the detected input language, or null if not returned by the API.
    @Nullable List<?>
    Returns the segment-level transcription breakdown, or null if not returned by the API.
    @Nullable Object
    Returns the provider-native usage object for this transcription, or null if not returned by the API.
    @Nullable List<com.openai.models.audio.transcriptions.TranscriptionWord>
    Returns the word-level timestamps, or null if not returned by the API.
     

    Methods inherited from class org.springframework.ai.model.MutableResponseMetadata

    clear, computeIfAbsent, containsKey, entrySet, get, getOrDefault, getRawMap, getRequired, isEmpty, keySet, put, remove

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.springframework.ai.model.ResponseMetadata

    getOrDefault
  • Constructor Details

    • OpenAiAudioTranscriptionResponseMetadata

      public OpenAiAudioTranscriptionResponseMetadata()
    • OpenAiAudioTranscriptionResponseMetadata

      public OpenAiAudioTranscriptionResponseMetadata(@Nullable Double duration, @Nullable String language, @Nullable Object usage, @Nullable List<?> segments, @Nullable List<com.openai.models.audio.transcriptions.TranscriptionWord> words)
  • Method Details

    • getDuration

      public @Nullable Double getDuration()
      Returns the audio duration in seconds, or null if not returned by the API.
    • getLanguage

      public @Nullable String getLanguage()
      Returns the detected input language, or null if not returned by the API.
    • getUsage

      public @Nullable Object getUsage()
      Returns the provider-native usage object for this transcription, or null if not returned by the API. The concrete type depends on the response format requested: TranscriptionVerbose.Usage for verbose_json, TranscriptionDiarized.Usage for diarized_json, or Transcription.Usage otherwise.
    • getSegments

      public @Nullable List<?> getSegments()
      Returns the segment-level transcription breakdown, or null if not returned by the API. Elements are TranscriptionSegment for verbose_json, or TranscriptionDiarizedSegment (carrying per-speaker attribution) for diarized_json.
    • getWords

      public @Nullable List<com.openai.models.audio.transcriptions.TranscriptionWord> getWords()
      Returns the word-level timestamps, or null if not returned by the API. Only populated for verbose_json when word-level timestamp_granularities were requested.
    • toString

      public String toString()
      Overrides:
      toString in class Object