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

feat(api): add wav and pcm to response_format #1189

Merged
merged 1 commit into from
Feb 24, 2024
Merged
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
16 changes: 12 additions & 4 deletions src/openai/resources/audio/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def create(
input: str,
model: Union[str, Literal["tts-1", "tts-1-hd"]],
voice: Literal["alloy", "echo", "fable", "onyx", "nova", "shimmer"],
response_format: Literal["mp3", "opus", "aac", "flac"] | NotGiven = NOT_GIVEN,
response_format: Literal["mp3", "opus", "aac", "flac", "pcm", "wav"] | NotGiven = NOT_GIVEN,
speed: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -65,7 +65,11 @@ def create(
available in the
[Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech/voice-options).

response_format: The format to audio in. Supported formats are `mp3`, `opus`, `aac`, and `flac`.
response_format: The format to return audio in. Supported formats are `mp3`, `opus`, `aac`,
`flac`, `pcm`, and `wav`.

The `pcm` audio format, similar to `wav` but without a header, utilizes a 24kHz
sample rate, mono channel, and 16-bit depth in signed little-endian format.

speed: The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
the default.
Expand Down Expand Up @@ -113,7 +117,7 @@ async def create(
input: str,
model: Union[str, Literal["tts-1", "tts-1-hd"]],
voice: Literal["alloy", "echo", "fable", "onyx", "nova", "shimmer"],
response_format: Literal["mp3", "opus", "aac", "flac"] | NotGiven = NOT_GIVEN,
response_format: Literal["mp3", "opus", "aac", "flac", "pcm", "wav"] | NotGiven = NOT_GIVEN,
speed: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -137,7 +141,11 @@ async def create(
available in the
[Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech/voice-options).

response_format: The format to audio in. Supported formats are `mp3`, `opus`, `aac`, and `flac`.
response_format: The format to return audio in. Supported formats are `mp3`, `opus`, `aac`,
`flac`, `pcm`, and `wav`.

The `pcm` audio format, similar to `wav` but without a header, utilizes a 24kHz
sample rate, mono channel, and 16-bit depth in signed little-endian format.

speed: The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
the default.
Expand Down
10 changes: 8 additions & 2 deletions src/openai/types/audio/speech_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ class SpeechCreateParams(TypedDict, total=False):
[Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech/voice-options).
"""

response_format: Literal["mp3", "opus", "aac", "flac"]
"""The format to audio in. Supported formats are `mp3`, `opus`, `aac`, and `flac`."""
response_format: Literal["mp3", "opus", "aac", "flac", "pcm", "wav"]
"""The format to return audio in.

Supported formats are `mp3`, `opus`, `aac`, `flac`, `pcm`, and `wav`.

The `pcm` audio format, similar to `wav` but without a header, utilizes a 24kHz
sample rate, mono channel, and 16-bit depth in signed little-endian format.
"""

speed: float
"""The speed of the generated audio.
Expand Down