Skip to content

Commit 7b93be6

Browse files
feat(openai): for tts and chat completions update supported voices enums
Signed-off-by: punnapavankumar9 <punnapavankumar9@gmail.com>
1 parent 902fc09 commit 7b93be6

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

models/spring-ai-openai/src/main/java/org/springframework/ai/openai/api/OpenAiApi.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,12 @@ public record AudioParameters(
11801180
public enum Voice {
11811181
/** Alloy voice */
11821182
@JsonProperty("alloy") ALLOY,
1183+
/** Ash voice */
1184+
@JsonProperty("ash") ASH,
1185+
/** Ballad voice */
1186+
@JsonProperty("ballad") BALLAD,
1187+
/** Coral voice */
1188+
@JsonProperty("coral") CORAL,
11831189
/** Echo voice */
11841190
@JsonProperty("echo") ECHO,
11851191
/** Fable voice */
@@ -1188,6 +1194,8 @@ public enum Voice {
11881194
@JsonProperty("onyx") ONYX,
11891195
/** Nova voice */
11901196
@JsonProperty("nova") NOVA,
1197+
/** Sage voice */
1198+
@JsonProperty("sage") SAGE,
11911199
/** Shimmer voice */
11921200
@JsonProperty("shimmer") SHIMMER
11931201
}

models/spring-ai-openai/src/main/java/org/springframework/ai/openai/api/OpenAiAudioApi.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,14 @@ public Class<?> getResponseType() {
330330
* Speech</a>
331331
*
332332
* @param model The model to use for generating the audio. One of the available TTS
333-
* models: tts-1 or tts-1-hd.
333+
* models: tts-1, tts-1-hd, or gpt-4o-mini-tts.
334334
* @param input The input text to synthesize. Must be at most 4096 tokens long.
335335
* @param voice The voice to use for synthesis. One of the available voices for the
336-
* chosen model: 'alloy', 'echo', 'fable', 'onyx', 'nova', and 'shimmer'.
336+
* chosen model: 'alloy', 'ash', 'ballad', 'coral', 'echo', 'fable', 'onyx', 'nova', 'sage', 'shimmer', and 'verse'.
337337
* @param responseFormat The format to audio in. Supported formats are mp3, opus, aac,
338-
* and flac. Defaults to mp3.
338+
* flac, wav, and pcm. Defaults to mp3.
339339
* @param speed The speed of the voice synthesis. The acceptable range is from 0.25
340-
* (slowest) to 4.0 (fastest).
341-
*/
340+
* (slowest) to 4.0 (fastest). Does not work with gpt-4o-mini-tts. */
342341
@JsonInclude(Include.NON_NULL)
343342
public record SpeechRequest(
344343
// @formatter:off
@@ -361,6 +360,8 @@ public enum Voice {
361360
// @formatter:off
362361
@JsonProperty("alloy")
363362
ALLOY("alloy"),
363+
@JsonProperty("ballad")
364+
BALLAD("ballad"),
364365
@JsonProperty("echo")
365366
ECHO("echo"),
366367
@JsonProperty("fable")
@@ -376,7 +377,9 @@ public enum Voice {
376377
@JsonProperty("coral")
377378
CORAL("coral"),
378379
@JsonProperty("ash")
379-
ASH("ash");
380+
ASH("ash"),
381+
@JsonProperty("verse")
382+
VERSE("verse");
380383
// @formatter:on
381384

382385
public final String value;

models/spring-ai-openai/src/test/java/org/springframework/ai/openai/audio/speech/OpenAiSpeechModelIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void shouldStreamNonEmptyResponsesForValidSpeechPrompts() {
136136
}
137137

138138
@ParameterizedTest(name = "{0} : {displayName} ")
139-
@ValueSource(strings = { "alloy", "echo", "fable", "onyx", "nova", "shimmer", "sage", "coral", "ash" })
139+
@ValueSource(strings = { "alloy", "echo", "fable", "onyx", "nova", "shimmer", "sage", "coral", "ash", "verse", "ballad" })
140140
void speechVoicesTest(String voice) {
141141
OpenAiAudioSpeechOptions speechOptions = OpenAiAudioSpeechOptions.builder()
142142
.voice(voice)

0 commit comments

Comments
 (0)