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
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDashScopeAudioSpeechModel(DashScopeAudioSpeechApi audioSpeechApi) DashScopeAudioSpeechModel(DashScopeAudioSpeechApi audioSpeechApi, DashScopeAudioSpeechOptions defaultOptions) DashScopeAudioSpeechModel(DashScopeAudioSpeechApi audioSpeechApi, DashScopeAudioSpeechOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()org.springframework.ai.audio.tts.TextToSpeechResponsecall(org.springframework.ai.audio.tts.TextToSpeechPrompt prompt) clone()mutate()Returns a builder pre-populated with the current configuration for mutation.reactor.core.publisher.Flux<org.springframework.ai.audio.tts.TextToSpeechResponse>stream(org.springframework.ai.audio.tts.TextToSpeechPrompt prompt) reactor.core.publisher.Flux<org.springframework.ai.audio.tts.TextToSpeechResponse>stream(reactor.core.publisher.Flux<String> textStream, org.springframework.ai.audio.tts.TextToSpeechOptions options) Stream text-to-speech with streaming text input.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ai.audio.tts.StreamingTextToSpeechModel
stream, streamMethods inherited from interface org.springframework.ai.audio.tts.TextToSpeechModel
call, getDefaultOptions
-
Constructor Details
-
DashScopeAudioSpeechModel
-
DashScopeAudioSpeechModel
public DashScopeAudioSpeechModel(DashScopeAudioSpeechApi audioSpeechApi, DashScopeAudioSpeechOptions defaultOptions) -
DashScopeAudioSpeechModel
public DashScopeAudioSpeechModel(DashScopeAudioSpeechApi audioSpeechApi, DashScopeAudioSpeechOptions defaultOptions, org.springframework.retry.support.RetryTemplate retryTemplate)
-
-
Method Details
-
call
@NonNull public org.springframework.ai.audio.tts.TextToSpeechResponse call(org.springframework.ai.audio.tts.TextToSpeechPrompt prompt) - Specified by:
callin interfaceorg.springframework.ai.model.Model<org.springframework.ai.audio.tts.TextToSpeechPrompt,org.springframework.ai.audio.tts.TextToSpeechResponse> - Specified by:
callin interfaceorg.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:
streamin interfaceorg.springframework.ai.model.StreamingModel<org.springframework.ai.audio.tts.TextToSpeechPrompt,org.springframework.ai.audio.tts.TextToSpeechResponse> - Specified by:
streamin interfaceorg.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:StreamingInputTextToSpeechModelStream text-to-speech with streaming text input.- Specified by:
streamin interfaceStreamingInputTextToSpeechModel- 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
-
builder
-