Class Audio

java.lang.Object
dev.langchain4j.data.audio.Audio

public class Audio extends Object
Represents audio data that can be used with various AI model implementations. This class supports multiple formats for storing audio:
  • URL: A reference to audio data located at a specific URI
  • Binary Data: Raw binary audio data as a byte array, primarily used by implementations like Azure OpenAI
  • Base64 Data: Base64 encoded string representation of audio data, primarily used by implementations like OpenAI
Different AI model implementations may require different audio data formats, so this class provides flexibility to support various use cases.
  • Method Details

    • builder

      public static Audio.Builder builder()
      Create a new Audio.Builder.
      Returns:
      the new Audio.Builder.
    • url

      public URI url()
      Get the url of the audio.
      Returns:
      the url of the audio, or null if not set.
    • binaryData

      public byte[] binaryData()
      Get the raw binary data of the audio as a byte array. This format is primarily used by implementations like Azure OpenAI that require raw binary audio data for processing.
      Returns:
      the raw binary data of the audio as a byte array, or null if not set.
    • base64Data

      public String base64Data()
      Get the Base64 encoded string representation of the audio data. This format is primarily used by implementations like OpenAI that accept Base64 encoded audio data in API requests.
      Returns:
      the Base64 encoded string representation of the audio data, or null if not set.
    • mimeType

      public String mimeType()
      Get the mime type of the audio.
      Returns:
      the mime type of the audio, or null if not set.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object