Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,13 @@ public enum Voice {
@JsonProperty("nova")
NOVA("nova"),
@JsonProperty("shimmer")
SHIMMER("shimmer");
SHIMMER("shimmer"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to update the javadoc for the same. Will update when merging.

@JsonProperty("sage")
SAGE("sage"),
@JsonProperty("coral")
CORAL("coral"),
@JsonProperty("ash")
ASH("ash");
// @formatter:on

public final String value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import reactor.core.publisher.Flux;

import org.springframework.ai.openai.OpenAiAudioSpeechOptions;
Expand Down Expand Up @@ -111,4 +113,22 @@ void shouldStreamNonEmptyResponsesForValidSpeechPrompts() {
assertThat(response.getResult().getOutput()).isNotEmpty());
}

@ParameterizedTest(name = "{0} : {displayName} ")
@ValueSource(strings = { "alloy", "echo", "fable", "onyx", "nova", "shimmer", "sage", "coral", "ash" })
void speechVoicesTest(String voice) {
OpenAiAudioSpeechOptions speechOptions = OpenAiAudioSpeechOptions.builder()
.voice(OpenAiAudioApi.SpeechRequest.Voice.valueOf(voice.toUpperCase()))
.speed(SPEED)
.responseFormat(OpenAiAudioApi.SpeechRequest.AudioResponseFormat.MP3)
.model(OpenAiAudioApi.TtsModel.TTS_1.value)
.build();
SpeechPrompt speechPrompt = new SpeechPrompt("Today is a wonderful day to build something people love!",
speechOptions);
SpeechResponse response = this.speechModel.call(speechPrompt);
byte[] audioBytes = response.getResult().getOutput();
assertThat(response.getResults()).hasSize(1);
assertThat(response.getResults().get(0).getOutput()).isNotEmpty();
assertThat(audioBytes).hasSizeGreaterThan(0);
}

}
Loading