Skip to content

feat(speech-voice-types): add SpeechVoice and SpeechResponseFormat types #1355

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 12 additions & 3 deletions src/resources/audio/speech.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export class Speech extends APIResource {

export type SpeechModel = 'tts-1' | 'tts-1-hd';

export type SpeechVoice = 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer';

export type SpeechResponseFormat = 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm';

export interface SpeechCreateParams {
/**
* The text to generate audio for. The maximum length is 4096 characters.
Expand All @@ -38,13 +42,13 @@ export interface SpeechCreateParams {
* voices are available in the
* [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
*/
voice: 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer';
voice: (string & {}) | SpeechVoice;

/**
* The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
* `wav`, and `pcm`.
*/
response_format?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm';
response_format?: (string & {}) | SpeechResponseFormat;

/**
* The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
Expand All @@ -54,5 +58,10 @@ export interface SpeechCreateParams {
}

export declare namespace Speech {
export { type SpeechModel as SpeechModel, type SpeechCreateParams as SpeechCreateParams };
export {
type SpeechModel as SpeechModel,
type SpeechCreateParams as SpeechCreateParams,
type SpeechVoice as SpeechVoice,
type SpeechResponseFormat as SpeechResponseFormat,
};
}