Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Missing Audio Formats (WAV, PCM) #2551

Closed
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 @@ -378,7 +378,7 @@ public String getValue() {
}

/**
* The format to audio in. Supported formats are mp3, opus, aac, and flac.
* The format to audio in. Supported formats are mp3, opus, aac, wav, pcm and flac.
* Defaults to mp3.
*/
public enum AudioResponseFormat {
Expand All @@ -391,7 +391,11 @@ public enum AudioResponseFormat {
@JsonProperty("aac")
AAC("aac"),
@JsonProperty("flac")
FLAC("flac");
FLAC("flac"),
@JsonProperty("wav")
WAV("wav"),
@JsonProperty("pcm")
PCM("pcm");
// @formatter:on

public final String value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ void shouldGenerateNonEmptyMp3AudioFromSpeechPrompt() {

}

@Test
void shouldGenerateNonEmptyWavAudioFromSpeechPrompt() {
OpenAiAudioSpeechOptions speechOptions = OpenAiAudioSpeechOptions.builder()
.voice(OpenAiAudioApi.SpeechRequest.Voice.ALLOY)
.speed(SPEED)
.responseFormat(OpenAiAudioApi.SpeechRequest.AudioResponseFormat.WAV)
.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);

}

@Test
void speechRateLimitTest() {
OpenAiAudioSpeechOptions speechOptions = OpenAiAudioSpeechOptions.builder()
Expand Down
Loading