Class DashScopeWebSocketTTSApi
java.lang.Object
com.alibaba.cloud.ai.dashscope.api.tts.DashScopeWebSocketTTSApi
DashScope WebSocket TTS API for Sambert and CosyVoice models.
Uses run-task / continue-task / finish-task protocol.
- Author:
- spring-ai-alibaba
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDashScopeWebSocketTTSApi(String websocketUrl, org.springframework.ai.model.ApiKey apiKey, String workSpaceId, DashScopeWebSocketClientOptions options) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()reactor.core.publisher.Flux<ByteBuffer>stream(String text, DashScopeAudioSpeechOptions options) Create WebSocket TTS task with a single text input.reactor.core.publisher.Flux<ByteBuffer>streamWithStreamingInput(reactor.core.publisher.Flux<String> textStream, DashScopeAudioSpeechOptions options) Create WebSocket TTS task with streaming text input (CosyVoice only).
-
Constructor Details
-
DashScopeWebSocketTTSApi
public DashScopeWebSocketTTSApi(String websocketUrl, org.springframework.ai.model.ApiKey apiKey, String workSpaceId, DashScopeWebSocketClientOptions options)
-
-
Method Details
-
stream
public reactor.core.publisher.Flux<ByteBuffer> stream(String text, DashScopeAudioSpeechOptions options) Create WebSocket TTS task with a single text input. For CosyVoice: run-task (no text) -> continue-task (text) -> finish-task. For Sambert: run-task (with text) only. -
streamWithStreamingInput
public reactor.core.publisher.Flux<ByteBuffer> streamWithStreamingInput(reactor.core.publisher.Flux<String> textStream, DashScopeAudioSpeechOptions options) Create WebSocket TTS task with streaming text input (CosyVoice only). Protocol: run-task (no text) → task-started → N * continue-task (text chunk) → finish-task. Each element in textStream is sent as a separate continue-task message.- Parameters:
textStream- the streaming text inputoptions- TTS options- Returns:
- the binary audio data flux
-
builder
-