Skip to content

Commit 343ab5c

Browse files
punnapavankumar9spring-builds
authored andcommitted
feat(openai): for tts and chat completions update supported voices enums (#3411)
* feat(openai): for tts and chat completions update supported voices enums Fixes: #3411 Signed-off-by: punnapavankumar9 <punnapavankumar9@gmail.com> (cherry picked from commit eb69a60)
1 parent c790d6c commit 343ab5c

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
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: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,12 @@ public enum TtsModel {
240240
* The latest text to speech model, optimized for quality.
241241
*/
242242
@JsonProperty("tts-1-hd")
243-
TTS_1_HD("tts-1-hd");
243+
TTS_1_HD("tts-1-hd"),
244+
/**
245+
* Text-to-speech model powered by GPT-4o mini
246+
*/
247+
@JsonProperty("gpt-4o-mini-tts")
248+
GPT_4_O_MINI_TTS("gpt-4o-mini-tts");
244249
// @formatter:on
245250

246251
public final String value;
@@ -330,14 +335,15 @@ public Class<?> getResponseType() {
330335
* Speech</a>
331336
*
332337
* @param model The model to use for generating the audio. One of the available TTS
333-
* models: tts-1 or tts-1-hd.
338+
* models: tts-1, tts-1-hd, or gpt-4o-mini-tts.
334339
* @param input The input text to synthesize. Must be at most 4096 tokens long.
335340
* @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'.
341+
* chosen model: 'alloy', 'ash', 'ballad', 'coral', 'echo', 'fable', 'onyx', 'nova',
342+
* 'sage', 'shimmer', and 'verse'.
337343
* @param responseFormat The format to audio in. Supported formats are mp3, opus, aac,
338-
* and flac. Defaults to mp3.
344+
* flac, wav, and pcm. Defaults to mp3.
339345
* @param speed The speed of the voice synthesis. The acceptable range is from 0.25
340-
* (slowest) to 4.0 (fastest).
346+
* (slowest) to 4.0 (fastest). Does not work with gpt-4o-mini-tts.
341347
*/
342348
@JsonInclude(Include.NON_NULL)
343349
public record SpeechRequest(
@@ -361,6 +367,8 @@ public enum Voice {
361367
// @formatter:off
362368
@JsonProperty("alloy")
363369
ALLOY("alloy"),
370+
@JsonProperty("ballad")
371+
BALLAD("ballad"),
364372
@JsonProperty("echo")
365373
ECHO("echo"),
366374
@JsonProperty("fable")
@@ -376,7 +384,9 @@ public enum Voice {
376384
@JsonProperty("coral")
377385
CORAL("coral"),
378386
@JsonProperty("ash")
379-
ASH("ash");
387+
ASH("ash"),
388+
@JsonProperty("verse")
389+
VERSE("verse");
380390
// @formatter:on
381391

382392
public final String value;

0 commit comments

Comments
 (0)