类 TTSResponse

java.lang.Object
io.agentscope.core.model.tts.TTSResponse

public class TTSResponse extends Object
Response from TTS synthesis.

This class encapsulates the result of a text-to-speech synthesis operation, including the audio data and metadata about the synthesis.

The response can contain either raw audio bytes or a URL to the audio file, depending on the TTS provider and configuration.

  • 方法详细资料

    • getAudioData

      public byte[] getAudioData()
      Gets the raw audio data.
      返回:
      audio data bytes, or null if only URL is available
    • getAudioUrl

      public String getAudioUrl()
      Gets the audio URL.
      返回:
      URL to audio file, or null if only raw data is available
    • getFormat

      public String getFormat()
      Gets the audio format.
      返回:
      audio format (e.g., "wav", "mp3")
    • getSampleRate

      public Integer getSampleRate()
      Gets the audio sample rate.
      返回:
      sample rate in Hz
    • getDurationMs

      public Long getDurationMs()
      Gets the audio duration.
      返回:
      duration in milliseconds
    • getRequestId

      public String getRequestId()
      Gets the request ID.
      返回:
      request ID for tracking
    • toAudioBlock

      public AudioBlock toAudioBlock()
      Converts this response to an AudioBlock for use in Msg.

      If audio data is available, it will be encoded as Base64. If only URL is available, it will be used directly.

      返回:
      an AudioBlock containing the audio content
      抛出:
      IllegalStateException - if neither audio data nor URL is available
    • builder

      public static TTSResponse.Builder builder()
      Creates a new builder for TTSResponse.
      返回:
      a new Builder instance