Class DashScopeWebSocketTTSApi

java.lang.Object
com.alibaba.cloud.ai.dashscope.api.tts.DashScopeWebSocketTTSApi

public class DashScopeWebSocketTTSApi extends Object
DashScope WebSocket TTS API for Sambert and CosyVoice models. Uses run-task / continue-task / finish-task protocol.
Author:
spring-ai-alibaba
  • Constructor Details

  • 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 input
      options - TTS options
      Returns:
      the binary audio data flux
    • builder

      public static DashScopeWebSocketTTSApi.Builder builder()