Class OpenAiAudioSpeechModel
java.lang.Object
org.springframework.ai.openai.OpenAiAudioSpeechModel
- All Implemented Interfaces:
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 OpenAiAudioSpeechModel
extends Object
implements org.springframework.ai.audio.tts.TextToSpeechModel
OpenAI audio speech client implementation for backed by
OpenAiAudioApi.- Since:
- 1.0.0-M1
- Author:
- Ahmed Yousri, Hyunjoon Choi, Thomas Vitale, Jonghoon Park
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpenAiAudioSpeechModel(OpenAiAudioApi audioApi) Initializes a new instance of the OpenAiAudioSpeechModel class with the provided OpenAiAudioApi.OpenAiAudioSpeechModel(OpenAiAudioApi audioApi, OpenAiAudioSpeechOptions options) Initializes a new instance of the OpenAiAudioSpeechModel class with the provided OpenAiAudioApi and options.OpenAiAudioSpeechModel(OpenAiAudioApi audioApi, OpenAiAudioSpeechOptions options, org.springframework.core.retry.RetryTemplate retryTemplate) Initializes a new instance of the OpenAiAudioSpeechModel class with the provided OpenAiAudioApi and options. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]org.springframework.ai.audio.tts.TextToSpeechResponsecall(org.springframework.ai.audio.tts.TextToSpeechPrompt prompt) org.springframework.ai.audio.tts.TextToSpeechOptionsreactor.core.publisher.Flux<org.springframework.ai.audio.tts.TextToSpeechResponse> stream(org.springframework.ai.audio.tts.TextToSpeechPrompt prompt) Streams the audio response for the given speech prompt.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ai.audio.tts.StreamingTextToSpeechModel
stream, stream
-
Constructor Details
-
OpenAiAudioSpeechModel
Initializes a new instance of the OpenAiAudioSpeechModel class with the provided OpenAiAudioApi. It uses the model tts-1, response format mp3, voice alloy, and the default speed of 1.0.- Parameters:
audioApi- The OpenAiAudioApi to use for speech synthesis.
-
OpenAiAudioSpeechModel
Initializes a new instance of the OpenAiAudioSpeechModel class with the provided OpenAiAudioApi and options.- Parameters:
audioApi- The OpenAiAudioApi to use for speech synthesis.options- The OpenAiAudioSpeechOptions containing the speech synthesis options.
-
OpenAiAudioSpeechModel
public OpenAiAudioSpeechModel(OpenAiAudioApi audioApi, OpenAiAudioSpeechOptions options, org.springframework.core.retry.RetryTemplate retryTemplate) Initializes a new instance of the OpenAiAudioSpeechModel class with the provided OpenAiAudioApi and options.- Parameters:
audioApi- The OpenAiAudioApi to use for speech synthesis.options- The OpenAiAudioSpeechOptions containing the speech synthesis options.retryTemplate- The retry template.
-
-
Method Details
-
call
- Specified by:
callin interfaceorg.springframework.ai.audio.tts.TextToSpeechModel
-
call
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) Streams the audio response for the given speech 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- Parameters:
prompt- The speech prompt containing the text and options for speech synthesis.- Returns:
- A Flux of TextToSpeechResponse objects containing the streamed audio and metadata.
-
getDefaultOptions
public org.springframework.ai.audio.tts.TextToSpeechOptions getDefaultOptions()- Specified by:
getDefaultOptionsin interfaceorg.springframework.ai.audio.tts.TextToSpeechModel
-