类 TTSResponse
java.lang.Object
io.agentscope.core.model.tts.TTSResponse
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.
-
嵌套类概要
嵌套类 -
方法概要
修饰符和类型方法说明static TTSResponse.Builderbuilder()Creates a new builder for TTSResponse.byte[]Gets the raw audio data.Gets the audio URL.Gets the audio duration.Gets the audio format.Gets the request ID.Gets the audio sample rate.Converts this response to an AudioBlock for use in Msg.
-
方法详细资料
-
getAudioData
public byte[] getAudioData()Gets the raw audio data.- 返回:
- audio data bytes, or null if only URL is available
-
getAudioUrl
Gets the audio URL.- 返回:
- URL to audio file, or null if only raw data is available
-
getFormat
Gets the audio format.- 返回:
- audio format (e.g., "wav", "mp3")
-
getSampleRate
Gets the audio sample rate.- 返回:
- sample rate in Hz
-
getDurationMs
Gets the audio duration.- 返回:
- duration in milliseconds
-
getRequestId
Gets the request ID.- 返回:
- request ID for tracking
-
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
Creates a new builder for TTSResponse.- 返回:
- a new Builder instance
-