public class HttpSpeechSynthesizer extends Object
Supports models like CosyVoice (cosyvoice-v3-flash, etc.) that use HTTP SSE for streaming synthesis.
| 构造器和说明 |
|---|
HttpSpeechSynthesizer()
Creates a new HttpSpeechSynthesizer instance with default settings.
|
| 限定符和类型 | 方法和说明 |
|---|---|
HttpSpeechSynthesisResult |
call(HttpSpeechSynthesisParam param)
Synchronous call without SSE - returns a result containing the audio URL.
|
ByteBuffer |
callAndReturnAudio(HttpSpeechSynthesisParam param)
Streaming call that returns audio data as a ByteBuffer.
|
void |
streamCall(HttpSpeechSynthesisParam param,
ResultCallback<HttpSpeechSynthesisResult> callback)
Streaming call with callback interface.
|
public HttpSpeechSynthesizer()
public HttpSpeechSynthesisResult call(HttpSpeechSynthesisParam param) throws ApiException, NoApiKeyException, InputRequiredException
Use this method when you want to get the audio URL and download it later.
Example response:
{
"request_id": "xxx",
"output": {
"finish_reason": "stop",
"audio": {
"url": "http://dashscope-result-bj.oss-cn-beijing.aliyuncs.com/...",
"id": "audio_xxx",
"expires_at": 1772697707
}
},
"usage": { "characters": 15 }
}
param - The synthesis parametersApiException - If the API call failsNoApiKeyException - If the API key is not configuredInputRequiredException - If required parameters are missingpublic void streamCall(HttpSpeechSynthesisParam param, ResultCallback<HttpSpeechSynthesisResult> callback) throws ApiException, NoApiKeyException, InputRequiredException
param - The synthesis parameterscallback - The callback to receive synthesis resultsApiException - If the API call failsNoApiKeyException - If the API key is not configuredInputRequiredException - If required parameters are missingpublic ByteBuffer callAndReturnAudio(HttpSpeechSynthesisParam param) throws ApiException, NoApiKeyException, InputRequiredException
param - The synthesis parametersApiException - If the API call failsNoApiKeyException - If the API key is not configuredInputRequiredException - If required parameters are missingCopyright © 2026. All rights reserved.