Skip to content

Commit f494e8f

Browse files
committed
feat(speech-voice-types): add SpeechVoice and SpeechResponseFormat types
- Introduce new exported type aliases SpeechVoice and SpeechResponseFormat for valid voice and audio format options. - Update SpeechCreateParams: - Change voice field type to (string & {}) | SpeechVoice for flexibility and consistency. - Change response_format field type to (string & {}) | SpeechResponseFormat for flexibility and consistency. - Extend the exported namespace to include the new types.
1 parent 0d3045e commit f494e8f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/resources/audio/speech.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export class Speech extends APIResource {
2020

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

23+
export type SpeechVoice = 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer';
24+
25+
export type SpeechResponseFormat = 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm';
26+
2327
export interface SpeechCreateParams {
2428
/**
2529
* The text to generate audio for. The maximum length is 4096 characters.
@@ -38,13 +42,13 @@ export interface SpeechCreateParams {
3842
* voices are available in the
3943
* [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
4044
*/
41-
voice: 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer';
45+
voice: (string & {}) | SpeechVoice;
4246

4347
/**
4448
* The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
4549
* `wav`, and `pcm`.
4650
*/
47-
response_format?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm';
51+
response_format?: (string & {}) | SpeechResponseFormat;
4852

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

5660
export declare namespace Speech {
57-
export { type SpeechModel as SpeechModel, type SpeechCreateParams as SpeechCreateParams };
61+
export {
62+
type SpeechModel as SpeechModel,
63+
type SpeechCreateParams as SpeechCreateParams,
64+
type SpeechVoice as SpeechVoice,
65+
type SpeechResponseFormat as SpeechResponseFormat,
66+
};
5867
}

0 commit comments

Comments
 (0)