Skip to content
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
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 68
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-17ddd746c775ca4d4fbe64e5621ac30756ef09c061ff6313190b6ec162222d4c.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-71e58a77027c67e003fdd1b1ac8ac11557d8bfabc7666d1a827c6b1ca8ab98b5.yml
10 changes: 8 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,26 @@ Types:
Types:

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

Methods:

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

## Translations

Types:

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

Methods:

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

## Speech

Expand Down
6 changes: 6 additions & 0 deletions src/resources/audio/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ export namespace Audio {
export import AudioResponseFormat = AudioAPI.AudioResponseFormat;
export import Transcriptions = TranscriptionsAPI.Transcriptions;
export import Transcription = TranscriptionsAPI.Transcription;
export import TranscriptionSegment = TranscriptionsAPI.TranscriptionSegment;
export import TranscriptionVerbose = TranscriptionsAPI.TranscriptionVerbose;
export import TranscriptionWord = TranscriptionsAPI.TranscriptionWord;
export import TranscriptionCreateResponse = TranscriptionsAPI.TranscriptionCreateResponse;
export import TranscriptionCreateParams = TranscriptionsAPI.TranscriptionCreateParams;
export import Translations = TranslationsAPI.Translations;
export import Translation = TranslationsAPI.Translation;
export import TranslationVerbose = TranslationsAPI.TranslationVerbose;
export import TranslationCreateResponse = TranslationsAPI.TranslationCreateResponse;
export import TranslationCreateParams = TranslationsAPI.TranslationCreateParams;
export import Speech = SpeechAPI.Speech;
export import SpeechModel = SpeechAPI.SpeechModel;
Expand Down
18 changes: 16 additions & 2 deletions src/resources/audio/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,19 @@

export { AudioModel, AudioResponseFormat, Audio } from './audio';
export { SpeechModel, SpeechCreateParams, Speech } from './speech';
export { Transcription, TranscriptionCreateParams, Transcriptions } from './transcriptions';
export { Translation, TranslationCreateParams, Translations } from './translations';
export {
Transcription,
TranscriptionSegment,
TranscriptionVerbose,
TranscriptionWord,
TranscriptionCreateResponse,
TranscriptionCreateParams,
Transcriptions,
} from './transcriptions';
export {
Translation,
TranslationVerbose,
TranslationCreateResponse,
TranslationCreateParams,
Translations,
} from './translations';
136 changes: 133 additions & 3 deletions src/resources/audio/transcriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,22 @@ export class Transcriptions extends APIResource {
/**
* Transcribes audio into the input language.
*/
create(body: TranscriptionCreateParams, options?: Core.RequestOptions): Core.APIPromise<Transcription> {
create(
body: TranscriptionCreateParams<'json' | undefined>,
options?: Core.RequestOptions,
): Core.APIPromise<Transcription>;
create(
body: TranscriptionCreateParams<'verbose_json'>,
options?: Core.RequestOptions,
): Core.APIPromise<TranscriptionVerbose>;
create(
body: TranscriptionCreateParams<'srt' | 'vtt' | 'text'>,
options?: Core.RequestOptions,
): Core.APIPromise<string>;
create(
body: TranscriptionCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<TranscriptionCreateResponse | string> {
return this._client.post('/audio/transcriptions', Core.multipartFormRequestOptions({ body, ...options }));
}
}
Expand All @@ -25,7 +40,118 @@ export interface Transcription {
text: string;
}

export interface TranscriptionCreateParams {
export interface TranscriptionSegment {
/**
* 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>;
}

/**
* Represents a verbose json transcription response returned by model, based on the
* provided input.
*/
export interface TranscriptionVerbose {
/**
* 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<TranscriptionSegment>;

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

export interface TranscriptionWord {
/**
* 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;
}

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

export interface TranscriptionCreateParams<
ResponseFormat extends AudioAPI.AudioResponseFormat | undefined = AudioAPI.AudioResponseFormat | undefined,
> {
/**
* The audio file object (not file name) to transcribe, in one of these formats:
* flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
Expand Down Expand Up @@ -57,7 +183,7 @@ export interface TranscriptionCreateParams {
* The format of the output, in one of these options: `json`, `text`, `srt`,
* `verbose_json`, or `vtt`.
*/
response_format?: AudioAPI.AudioResponseFormat;
response_format?: ResponseFormat;

/**
* The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
Expand All @@ -80,5 +206,9 @@ export interface TranscriptionCreateParams {

export namespace Transcriptions {
export import Transcription = TranscriptionsAPI.Transcription;
export import TranscriptionSegment = TranscriptionsAPI.TranscriptionSegment;
export import TranscriptionVerbose = TranscriptionsAPI.TranscriptionVerbose;
export import TranscriptionWord = TranscriptionsAPI.TranscriptionWord;
export import TranscriptionCreateResponse = TranscriptionsAPI.TranscriptionCreateResponse;
export import TranscriptionCreateParams = TranscriptionsAPI.TranscriptionCreateParams;
}
50 changes: 47 additions & 3 deletions src/resources/audio/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,28 @@ import { APIResource } from '../../resource';
import * as Core from '../../core';
import * as TranslationsAPI from './translations';
import * as AudioAPI from './audio';
import * as TranscriptionsAPI from './transcriptions';

export class Translations extends APIResource {
/**
* Translates audio into English.
*/
create(body: TranslationCreateParams, options?: Core.RequestOptions): Core.APIPromise<Translation> {
create(
body: TranslationCreateParams<'json' | undefined>,
options?: Core.RequestOptions,
): Core.APIPromise<Translation>;
create(
body: TranslationCreateParams<'verbose_json'>,
options?: Core.RequestOptions,
): Core.APIPromise<TranslationVerbose>;
create(
body: TranslationCreateParams<'text' | 'srt' | 'vtt'>,
options?: Core.RequestOptions,
): Core.APIPromise<string>;
create(
body: TranslationCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<TranslationCreateResponse | string> {
return this._client.post('/audio/translations', Core.multipartFormRequestOptions({ body, ...options }));
}
}
Expand All @@ -18,7 +34,33 @@ export interface Translation {
text: string;
}

export interface TranslationCreateParams {
export interface TranslationVerbose {
/**
* 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<TranscriptionsAPI.TranscriptionSegment>;
}

export type TranslationCreateResponse = Translation | TranslationVerbose;

export interface TranslationCreateParams<
ResponseFormat extends AudioAPI.AudioResponseFormat | undefined = AudioAPI.AudioResponseFormat | undefined,
> {
/**
* The audio file object (not file name) translate, in one of these formats: flac,
* mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
Expand All @@ -43,7 +85,7 @@ export interface TranslationCreateParams {
* The format of the output, in one of these options: `json`, `text`, `srt`,
* `verbose_json`, or `vtt`.
*/
response_format?: AudioAPI.AudioResponseFormat;
response_format?: ResponseFormat;

/**
* The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
Expand All @@ -57,5 +99,7 @@ export interface TranslationCreateParams {

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