Skip to content

Commit

Permalink
feat(api): Fix audio transcription response formats
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and gradenr committed Jun 11, 2024
1 parent e257ab7 commit 7154e35
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 228 deletions.
6 changes: 2 additions & 4 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,20 @@ Methods:
Types:

- <code><a href="./src/resources/audio/transcriptions.ts">Transcription</a></code>
- <code><a href="./src/resources/audio/transcriptions.ts">TranscriptionCreateResponse</a></code>

Methods:

- <code title="post /openai/v1/audio/transcriptions">client.audio.transcriptions.<a href="./src/resources/audio/transcriptions.ts">create</a>({ ...params }) -> TranscriptionCreateResponse</code>
- <code title="post /openai/v1/audio/transcriptions">client.audio.transcriptions.<a href="./src/resources/audio/transcriptions.ts">create</a>({ ...params }) -> Transcription</code>

## Translations

Types:

- <code><a href="./src/resources/audio/translations.ts">Translation</a></code>
- <code><a href="./src/resources/audio/translations.ts">TranslationCreateResponse</a></code>

Methods:

- <code title="post /openai/v1/audio/translations">client.audio.translations.<a href="./src/resources/audio/translations.ts">create</a>({ ...params }) -> TranslationCreateResponse</code>
- <code title="post /openai/v1/audio/translations">client.audio.translations.<a href="./src/resources/audio/translations.ts">create</a>({ ...params }) -> Translation</code>

# Models

Expand Down
2 changes: 0 additions & 2 deletions src/resources/audio/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ export class Audio extends APIResource {
export namespace Audio {
export import Transcriptions = TranscriptionsAPI.Transcriptions;
export import Transcription = TranscriptionsAPI.Transcription;
export import TranscriptionCreateResponse = TranscriptionsAPI.TranscriptionCreateResponse;
export import TranscriptionCreateParams = TranscriptionsAPI.TranscriptionCreateParams;
export import Translations = TranslationsAPI.Translations;
export import Translation = TranslationsAPI.Translation;
export import TranslationCreateResponse = TranslationsAPI.TranslationCreateResponse;
export import TranslationCreateParams = TranslationsAPI.TranslationCreateParams;
}
14 changes: 2 additions & 12 deletions src/resources/audio/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { Audio } from './audio';
export {
Transcription,
TranscriptionCreateResponse,
TranscriptionCreateParams,
Transcriptions,
} from './transcriptions';
export {
Translation,
TranslationCreateResponse,
TranslationCreateParams,
Translations,
} from './translations';
export { Transcription, TranscriptionCreateParams, Transcriptions } from './transcriptions';
export { Translation, TranslationCreateParams, Translations } from './translations';
121 changes: 1 addition & 120 deletions src/resources/audio/transcriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ export class Transcriptions extends APIResource {
/**
* Transcribes audio into the input language.
*/
create(
body: TranscriptionCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<TranscriptionCreateResponse> {
create(body: TranscriptionCreateParams, options?: Core.RequestOptions): Core.APIPromise<Transcription> {
return this._client.post(
'/openai/v1/audio/transcriptions',
multipartFormRequestOptions({ body, ...options }),
Expand All @@ -31,121 +28,6 @@ export interface Transcription {
text: string;
}

/**
* Represents a transcription response returned by model, based on the provided
* input.
*/
export type TranscriptionCreateResponse =
| Transcription
| TranscriptionCreateResponse.CreateTranscriptionResponseVerboseJson;

export namespace TranscriptionCreateResponse {
/**
* Represents a verbose json transcription response returned by model, based on the
* provided input.
*/
export interface CreateTranscriptionResponseVerboseJson {
/**
* The duration of the input audio.
*/
duration: string;

/**
* The language of the input audio.
*/
language: string;

/**
* The transcribed text.
*/
text: string;

/**
* Segments of the transcribed text and their corresponding details.
*/
segments?: Array<CreateTranscriptionResponseVerboseJson.Segment>;

/**
* Extracted words and their corresponding timestamps.
*/
words?: Array<CreateTranscriptionResponseVerboseJson.Word>;
}

export namespace CreateTranscriptionResponseVerboseJson {
export interface Segment {
/**
* Unique identifier of the segment.
*/
id: number;

/**
* Average logprob of the segment. If the value is lower than -1, consider the
* logprobs failed.
*/
avg_logprob: number;

/**
* Compression ratio of the segment. If the value is greater than 2.4, consider the
* compression failed.
*/
compression_ratio: number;

/**
* End time of the segment in seconds.
*/
end: number;

/**
* Probability of no speech in the segment. If the value is higher than 1.0 and the
* `avg_logprob` is below -1, consider this segment silent.
*/
no_speech_prob: number;

/**
* Seek offset of the segment.
*/
seek: number;

/**
* Start time of the segment in seconds.
*/
start: number;

/**
* Temperature parameter used for generating the segment.
*/
temperature: number;

/**
* Text content of the segment.
*/
text: string;

/**
* Array of token IDs for the text content.
*/
tokens: Array<number>;
}

export interface Word {
/**
* End time of the word in seconds.
*/
end: number;

/**
* Start time of the word in seconds.
*/
start: number;

/**
* The text content of the word.
*/
word: string;
}
}
}

export interface TranscriptionCreateParams {
/**
* The audio file object (not file name) to transcribe, in one of these formats:
Expand Down Expand Up @@ -199,6 +81,5 @@ export interface TranscriptionCreateParams {

export namespace Transcriptions {
export import Transcription = TranscriptionsAPI.Transcription;
export import TranscriptionCreateResponse = TranscriptionsAPI.TranscriptionCreateResponse;
export import TranscriptionCreateParams = TranscriptionsAPI.TranscriptionCreateParams;
}
91 changes: 1 addition & 90 deletions src/resources/audio/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ export class Translations extends APIResource {
/**
* Translates audio into English.
*/
create(
body: TranslationCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<TranslationCreateResponse> {
create(body: TranslationCreateParams, options?: Core.RequestOptions): Core.APIPromise<Translation> {
return this._client.post(
'/openai/v1/audio/translations',
multipartFormRequestOptions({ body, ...options }),
Expand All @@ -24,91 +21,6 @@ export interface Translation {
text: string;
}

export type TranslationCreateResponse =
| Translation
| TranslationCreateResponse.CreateTranslationResponseVerboseJson;

export namespace TranslationCreateResponse {
export interface CreateTranslationResponseVerboseJson {
/**
* The duration of the input audio.
*/
duration: string;

/**
* The language of the output translation (always `english`).
*/
language: string;

/**
* The translated text.
*/
text: string;

/**
* Segments of the translated text and their corresponding details.
*/
segments?: Array<CreateTranslationResponseVerboseJson.Segment>;
}

export namespace CreateTranslationResponseVerboseJson {
export interface Segment {
/**
* Unique identifier of the segment.
*/
id: number;

/**
* Average logprob of the segment. If the value is lower than -1, consider the
* logprobs failed.
*/
avg_logprob: number;

/**
* Compression ratio of the segment. If the value is greater than 2.4, consider the
* compression failed.
*/
compression_ratio: number;

/**
* End time of the segment in seconds.
*/
end: number;

/**
* Probability of no speech in the segment. If the value is higher than 1.0 and the
* `avg_logprob` is below -1, consider this segment silent.
*/
no_speech_prob: number;

/**
* Seek offset of the segment.
*/
seek: number;

/**
* Start time of the segment in seconds.
*/
start: number;

/**
* Temperature parameter used for generating the segment.
*/
temperature: number;

/**
* Text content of the segment.
*/
text: string;

/**
* Array of token IDs for the text content.
*/
tokens: Array<number>;
}
}
}

export interface TranslationCreateParams {
/**
* The audio file object (not file name) translate, in one of these formats: flac,
Expand Down Expand Up @@ -146,6 +58,5 @@ export interface TranslationCreateParams {

export namespace Translations {
export import Translation = TranslationsAPI.Translation;
export import TranslationCreateResponse = TranslationsAPI.TranslationCreateResponse;
export import TranslationCreateParams = TranslationsAPI.TranslationCreateParams;
}

0 comments on commit 7154e35

Please sign in to comment.