Class DashScopeAudioSpeechModel

java.lang.Object
com.alibaba.cloud.ai.dashscope.audio.tts.DashScopeAudioSpeechModel
All Implemented Interfaces:
StreamingInputTextToSpeechModel, org.springframework.ai.audio.tts.StreamingTextToSpeechModel, org.springframework.ai.audio.tts.TextToSpeechModel, org.springframework.ai.model.Model<org.springframework.ai.audio.tts.TextToSpeechPrompt,org.springframework.ai.audio.tts.TextToSpeechResponse>, org.springframework.ai.model.StreamingModel<org.springframework.ai.audio.tts.TextToSpeechPrompt,org.springframework.ai.audio.tts.TextToSpeechResponse>

public class DashScopeAudioSpeechModel extends Object implements org.springframework.ai.audio.tts.TextToSpeechModel, StreamingInputTextToSpeechModel
DashScope TTS model facade. Supports all four TTS modes:
  • Qwen-TTS (REST/SSE) — call / stream
  • Sambert (WebSocket half-duplex) — stream
  • CosyVoice (WebSocket duplex) — stream / stream with streaming input
  • Qwen TTS Realtime (WebSocket append/commit) — stream / stream with streaming input

Implements both Spring AI's TextToSpeechModel (complete text input) and StreamingInputTextToSpeechModel (streaming text input for CosyVoice / Qwen TTS Realtime).

Author:
kevinlin09, xuguan, yingzi
  • Constructor Details

  • Method Details

    • call

      @NonNull public org.springframework.ai.audio.tts.TextToSpeechResponse call(org.springframework.ai.audio.tts.TextToSpeechPrompt prompt)
      Specified by:
      call in interface org.springframework.ai.model.Model<org.springframework.ai.audio.tts.TextToSpeechPrompt,org.springframework.ai.audio.tts.TextToSpeechResponse>
      Specified by:
      call in interface org.springframework.ai.audio.tts.TextToSpeechModel
    • stream

      public reactor.core.publisher.Flux<org.springframework.ai.audio.tts.TextToSpeechResponse> stream(org.springframework.ai.audio.tts.TextToSpeechPrompt prompt)
      Specified by:
      stream in interface org.springframework.ai.model.StreamingModel<org.springframework.ai.audio.tts.TextToSpeechPrompt,org.springframework.ai.audio.tts.TextToSpeechResponse>
      Specified by:
      stream in interface org.springframework.ai.audio.tts.StreamingTextToSpeechModel
    • stream

      public reactor.core.publisher.Flux<org.springframework.ai.audio.tts.TextToSpeechResponse> stream(reactor.core.publisher.Flux<String> textStream, org.springframework.ai.audio.tts.TextToSpeechOptions options)
      Description copied from interface: StreamingInputTextToSpeechModel
      Stream text-to-speech with streaming text input.
      Specified by:
      stream in interface StreamingInputTextToSpeechModel
      Parameters:
      textStream - the text stream to be synthesized (e.g., from LLM streaming output)
      options - TTS options including model, voice, etc.
      Returns:
      flux of audio responses (each typically contains a chunk of audio data)
    • mutate

      Returns a builder pre-populated with the current configuration for mutation.
    • clone

      public DashScopeAudioSpeechModel clone()
      Overrides:
      clone in class Object
    • builder

      public static DashScopeAudioSpeechModel.Builder builder()