Skip to content

Commit d5896b3

Browse files
committed
fix: correct types for audio responses
1 parent 0680c8d commit d5896b3

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

src/resources/audio/transcriptions.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,22 @@ export class Transcriptions extends APIResource {
99
/**
1010
* Transcribes audio into the input language.
1111
*/
12+
create(
13+
body: TranscriptionCreateParams<'json'>,
14+
options?: Core.RequestOptions,
15+
): Core.APIPromise<Transcription>;
16+
create(
17+
body: TranscriptionCreateParams<'verbose_json'>,
18+
options?: Core.RequestOptions,
19+
): Core.APIPromise<TranscriptionVerbose>;
20+
create(
21+
body: TranscriptionCreateParams<'srt' | 'vtt' | 'text'>,
22+
options?: Core.RequestOptions,
23+
): Core.APIPromise<string>;
1224
create(
1325
body: TranscriptionCreateParams,
1426
options?: Core.RequestOptions,
15-
): Core.APIPromise<TranscriptionCreateResponse> {
27+
): Core.APIPromise<TranscriptionCreateResponse | string> {
1628
return this._client.post('/audio/transcriptions', Core.multipartFormRequestOptions({ body, ...options }));
1729
}
1830
}
@@ -137,7 +149,9 @@ export interface TranscriptionWord {
137149
*/
138150
export type TranscriptionCreateResponse = Transcription | TranscriptionVerbose;
139151

140-
export interface TranscriptionCreateParams {
152+
export interface TranscriptionCreateParams<
153+
ResponseFormat extends AudioAPI.AudioResponseFormat = AudioAPI.AudioResponseFormat,
154+
> {
141155
/**
142156
* The audio file object (not file name) to transcribe, in one of these formats:
143157
* flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
@@ -169,7 +183,7 @@ export interface TranscriptionCreateParams {
169183
* The format of the output, in one of these options: `json`, `text`, `srt`,
170184
* `verbose_json`, or `vtt`.
171185
*/
172-
response_format?: AudioAPI.AudioResponseFormat;
186+
response_format?: ResponseFormat;
173187

174188
/**
175189
* The sampling temperature, between 0 and 1. Higher values like 0.8 will make the

src/resources/audio/translations.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,19 @@ export class Translations extends APIResource {
1010
/**
1111
* Translates audio into English.
1212
*/
13+
create(body: TranslationCreateParams<'json'>, options?: Core.RequestOptions): Core.APIPromise<Translation>;
14+
create(
15+
body: TranslationCreateParams<'verbose_json'>,
16+
options?: Core.RequestOptions,
17+
): Core.APIPromise<TranslationVerbose>;
18+
create(
19+
body: TranslationCreateParams<'text' | 'srt' | 'vtt'>,
20+
options?: Core.RequestOptions,
21+
): Core.APIPromise<string>;
1322
create(
1423
body: TranslationCreateParams,
1524
options?: Core.RequestOptions,
16-
): Core.APIPromise<TranslationCreateResponse> {
25+
): Core.APIPromise<TranslationCreateResponse | string> {
1726
return this._client.post('/audio/translations', Core.multipartFormRequestOptions({ body, ...options }));
1827
}
1928
}
@@ -46,7 +55,9 @@ export interface TranslationVerbose {
4655

4756
export type TranslationCreateResponse = Translation | TranslationVerbose;
4857

49-
export interface TranslationCreateParams {
58+
export interface TranslationCreateParams<
59+
ResponseFormat extends AudioAPI.AudioResponseFormat = AudioAPI.AudioResponseFormat,
60+
> {
5061
/**
5162
* The audio file object (not file name) translate, in one of these formats: flac,
5263
* mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
@@ -71,7 +82,7 @@ export interface TranslationCreateParams {
7182
* The format of the output, in one of these options: `json`, `text`, `srt`,
7283
* `verbose_json`, or `vtt`.
7384
*/
74-
response_format?: AudioAPI.AudioResponseFormat;
85+
response_format?: ResponseFormat;
7586

7687
/**
7788
* The sampling temperature, between 0 and 1. Higher values like 0.8 will make the

0 commit comments

Comments
 (0)