Class HttpSpeechSynthesizer
java.lang.Object
com.alibaba.dashscope.legacy_2x.audio.http_tts.HttpSpeechSynthesizer
Deprecated.
HTTP-based Speech Synthesizer using Server-Sent Events (SSE). This class provides a simple
interface for text-to-speech synthesis via HTTP SSE protocol.
Supports models like CosyVoice (cosyvoice-v3-flash, etc.) that use HTTP SSE for streaming synthesis.
- Author:
- songsong.sss
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Creates a new HttpSpeechSynthesizer instance with default settings. -
Method Summary
Modifier and TypeMethodDescriptioncall(HttpSpeechSynthesisParam param) Deprecated.Synchronous call without SSE - returns a result containing the audio URL.Deprecated.Streaming call that returns audio data as a ByteBuffer.voidstreamCall(HttpSpeechSynthesisParam param, ResultCallback<HttpSpeechSynthesisResult> callback) Deprecated.Streaming call with callback interface.
-
Constructor Details
-
HttpSpeechSynthesizer
public HttpSpeechSynthesizer()Deprecated.Creates a new HttpSpeechSynthesizer instance with default settings.
-
-
Method Details
-
call
public HttpSpeechSynthesisResult call(HttpSpeechSynthesisParam param) throws ApiException, NoApiKeyException, InputRequiredException Deprecated.Synchronous call without SSE - returns a result containing the audio URL. This is a simpler, faster call that returns a download URL instead of streaming audio data.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 } }- Parameters:
param- The synthesis parameters- Returns:
- HttpSpeechSynthesisResult containing audio URL and metadata
- Throws:
ApiException- If the API call failsNoApiKeyException- If the API key is not configuredInputRequiredException- If required parameters are missing
-
streamCall
public void streamCall(HttpSpeechSynthesisParam param, ResultCallback<HttpSpeechSynthesisResult> callback) throws ApiException, NoApiKeyException, InputRequiredException Deprecated.Streaming call with callback interface. Results are delivered through the callback as they arrive.- Parameters:
param- The synthesis parameterscallback- The callback to receive synthesis results- Throws:
ApiException- If the API call failsNoApiKeyException- If the API key is not configuredInputRequiredException- If required parameters are missing
-
callAndReturnAudio
public ByteBuffer callAndReturnAudio(HttpSpeechSynthesisParam param) throws ApiException, NoApiKeyException, InputRequiredException Deprecated.Streaming call that returns audio data as a ByteBuffer. This method blocks until the audio data is fully received.- Parameters:
param- The synthesis parameters- Returns:
- The accumulated audio data as ByteBuffer
- Throws:
ApiException- If the API call failsNoApiKeyException- If the API key is not configuredInputRequiredException- If required parameters are missing
-