Add missing audio formats for OpenAIAudio API
- Add missing formats "wav" and "pcm" which OpenAI supports but SpringAI does not have serializers for Signed-off-by: gabriel duncan <gabrielduncan@Mac.attlocal.net>
This commit is contained in:
committed by
Ilayaperumal Gopinathan
parent
4f4da3076a
commit
64a4f79783
@@ -378,8 +378,8 @@ public class OpenAiAudioApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* The format to audio in. Supported formats are mp3, opus, aac, and flac.
|
||||
* Defaults to mp3.
|
||||
* The format to audio in. Supported formats are mp3, opus, aac, wav, pcm and
|
||||
* flac. Defaults to mp3.
|
||||
*/
|
||||
public enum AudioResponseFormat {
|
||||
|
||||
@@ -391,7 +391,11 @@ public class OpenAiAudioApi {
|
||||
@JsonProperty("aac")
|
||||
AAC("aac"),
|
||||
@JsonProperty("flac")
|
||||
FLAC("flac");
|
||||
FLAC("flac"),
|
||||
@JsonProperty("wav")
|
||||
WAV("wav"),
|
||||
@JsonProperty("pcm")
|
||||
PCM("pcm");
|
||||
// @formatter:on
|
||||
|
||||
public final String value;
|
||||
|
||||
@@ -72,6 +72,24 @@ class OpenAiSpeechModelIT extends AbstractIT {
|
||||
|
||||
}
|
||||
|
||||
@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()
|
||||
|
||||
Reference in New Issue
Block a user