Class OpenAiAudioSpeechModel
java.lang.Object
org.springframework.ai.openai.OpenAiAudioSpeechModel
- All Implemented Interfaces:
StreamingTextToSpeechModel, TextToSpeechModel, Model<TextToSpeechPrompt, TextToSpeechResponse>, StreamingModel<TextToSpeechPrompt, TextToSpeechResponse>
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[]call(TextToSpeechPrompt prompt) Executes a method call to the AI model.reactor.core.publisher.Flux<TextToSpeechResponse> stream(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 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 interfaceTextToSpeechModel
-
call
Description copied from interface:ModelExecutes a method call to the AI model.- Specified by:
callin interfaceModel<TextToSpeechPrompt, TextToSpeechResponse>- Specified by:
callin interfaceTextToSpeechModel- Parameters:
prompt- the request object to be sent to the AI model- Returns:
- the response from the AI model
-
stream
Streams the audio response for the given speech prompt.- Specified by:
streamin interfaceStreamingModel<TextToSpeechPrompt, TextToSpeechResponse>- Specified by:
streamin interfaceStreamingTextToSpeechModel- 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
- Specified by:
getDefaultOptionsin interfaceTextToSpeechModel
-