Skip to content

Commit bb74944

Browse files
feat(api): adding audio APIs
1 parent 9e6d702 commit bb74944

File tree

12 files changed

+755
-179
lines changed

12 files changed

+755
-179
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 33
1+
configured_endpoints: 35
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-9e121bfbc10c1adadd6057831f0dc3b2784b0f31959200681eed561e4b4bd116.yml
33
openapi_spec_hash: 124b766fc217aee5b73420aa9764fd95
4-
config_hash: ae07f8cefe84a8a01ae2d0c8ddc2ef32
4+
config_hash: 0c4aa6f4b4a140792bcc025bd64e3d8b

api.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,32 @@ Methods:
143143

144144
Types:
145145

146-
- <code><a href="./src/resources/audio.ts">AudioFile</a></code>
147-
- <code><a href="./src/resources/audio.ts">AudioSpeechStreamChunk</a></code>
146+
- <code><a href="./src/resources/audio/audio.ts">AudioFile</a></code>
147+
- <code><a href="./src/resources/audio/audio.ts">AudioSpeechStreamChunk</a></code>
148148

149149
Methods:
150150

151-
- <code title="post /audio/speech">client.audio.<a href="./src/resources/audio.ts">create</a>({ ...params }) -> Response</code>
151+
- <code title="post /audio/speech">client.audio.<a href="./src/resources/audio/audio.ts">create</a>({ ...params }) -> Response</code>
152+
153+
## Transcriptions
154+
155+
Types:
156+
157+
- <code><a href="./src/resources/audio/transcriptions.ts">TranscriptionCreateResponse</a></code>
158+
159+
Methods:
160+
161+
- <code title="post /audio/transcriptions">client.audio.transcriptions.<a href="./src/resources/audio/transcriptions.ts">create</a>({ ...params }) -> TranscriptionCreateResponse</code>
162+
163+
## Translations
164+
165+
Types:
166+
167+
- <code><a href="./src/resources/audio/translations.ts">TranslationCreateResponse</a></code>
168+
169+
Methods:
170+
171+
- <code title="post /audio/translations">client.audio.translations.<a href="./src/resources/audio/translations.ts">create</a>({ ...params }) -> TranslationCreateResponse</code>
152172

153173
# Models
154174

src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ import * as Uploads from './uploads';
77
import * as API from './resources/index';
88
import * as TopLevelAPI from './resources/top-level';
99
import { RerankParams, RerankResponse } from './resources/top-level';
10-
import {
11-
Audio,
12-
AudioCreateParams,
13-
AudioCreateParamsNonStreaming,
14-
AudioCreateParamsStreaming,
15-
AudioFile,
16-
AudioSpeechStreamChunk,
17-
} from './resources/audio';
1810
import {
1911
BatchCreateParams,
2012
BatchCreateResponse,
@@ -80,6 +72,14 @@ import { Hardware, HardwareListParams, HardwareListResponse } from './resources/
8072
import { ImageCreateParams, ImageDataB64, ImageDataURL, ImageFile, Images } from './resources/images';
8173
import { JobListResponse, JobRetrieveResponse, Jobs } from './resources/jobs';
8274
import { ModelListResponse, ModelUploadParams, ModelUploadResponse, Models } from './resources/models';
75+
import {
76+
Audio,
77+
AudioCreateParams,
78+
AudioCreateParamsNonStreaming,
79+
AudioCreateParamsStreaming,
80+
AudioFile,
81+
AudioSpeechStreamChunk,
82+
} from './resources/audio/audio';
8383
import { Chat } from './resources/chat/chat';
8484
import {
8585
CodeInterpreter,

src/resources/audio.ts

Lines changed: 1 addition & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -1,167 +1,3 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
import { APIResource } from '../resource';
4-
import { APIPromise } from '../core';
5-
import * as Core from '../core';
6-
import * as AudioAPI from './audio';
7-
import { Stream } from '../streaming';
8-
import { type Response } from '../_shims/index';
9-
10-
export class Audio extends APIResource {
11-
/**
12-
* Generate audio from input text
13-
*
14-
* @example
15-
* ```ts
16-
* const audio = await client.audio.create({
17-
* input: 'input',
18-
* model: 'cartesia/sonic',
19-
* voice: 'laidback woman',
20-
* });
21-
*
22-
* const content = await audio.blob();
23-
* console.log(content);
24-
* ```
25-
*/
26-
create(body: AudioCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<Response>;
27-
create(
28-
body: AudioCreateParamsStreaming,
29-
options?: Core.RequestOptions,
30-
): APIPromise<Stream<AudioSpeechStreamChunk>>;
31-
create(
32-
body: AudioCreateParamsBase,
33-
options?: Core.RequestOptions,
34-
): APIPromise<Stream<AudioSpeechStreamChunk> | Response>;
35-
create(
36-
body: AudioCreateParams,
37-
options?: Core.RequestOptions,
38-
): APIPromise<Response> | APIPromise<Stream<AudioSpeechStreamChunk>> {
39-
return this._client.post('/audio/speech', {
40-
body,
41-
...options,
42-
headers: { Accept: 'application/octet-stream', ...options?.headers },
43-
stream: body.stream ?? false,
44-
__binaryResponse: true,
45-
}) as APIPromise<Response> | APIPromise<Stream<AudioSpeechStreamChunk>>;
46-
}
47-
}
48-
49-
export type AudioFile = AudioFile.AudioSpeechStreamEvent | AudioFile.StreamSentinel;
50-
51-
export namespace AudioFile {
52-
export interface AudioSpeechStreamEvent {
53-
data: AudioAPI.AudioSpeechStreamChunk;
54-
}
55-
56-
export interface StreamSentinel {
57-
data: '[DONE]';
58-
}
59-
}
60-
61-
export interface AudioSpeechStreamChunk {
62-
/**
63-
* base64 encoded audio stream
64-
*/
65-
b64: string;
66-
67-
model: string;
68-
69-
object: 'audio.tts.chunk';
70-
}
71-
72-
export type AudioCreateParams = AudioCreateParamsNonStreaming | AudioCreateParamsStreaming;
73-
74-
export interface AudioCreateParamsBase {
75-
/**
76-
* Input text to generate the audio for
77-
*/
78-
input: string;
79-
80-
/**
81-
* The name of the model to query.
82-
*
83-
* [See all of Together AI's chat models](https://docs.together.ai/docs/serverless-models#audio-models)
84-
*/
85-
model: 'cartesia/sonic' | (string & {});
86-
87-
/**
88-
* The voice to use for generating the audio.
89-
* [View all supported voices here](https://docs.together.ai/docs/text-to-speech#voices-available).
90-
*/
91-
voice: 'laidback woman' | 'polite man' | 'storyteller lady' | 'friendly sidekick' | (string & {});
92-
93-
/**
94-
* Language of input text
95-
*/
96-
language?:
97-
| 'en'
98-
| 'de'
99-
| 'fr'
100-
| 'es'
101-
| 'hi'
102-
| 'it'
103-
| 'ja'
104-
| 'ko'
105-
| 'nl'
106-
| 'pl'
107-
| 'pt'
108-
| 'ru'
109-
| 'sv'
110-
| 'tr'
111-
| 'zh';
112-
113-
/**
114-
* Audio encoding of response
115-
*/
116-
response_encoding?: 'pcm_f32le' | 'pcm_s16le' | 'pcm_mulaw' | 'pcm_alaw';
117-
118-
/**
119-
* The format of audio output
120-
*/
121-
response_format?: 'mp3' | 'wav' | 'raw';
122-
123-
/**
124-
* Sampling rate to use for the output audio
125-
*/
126-
sample_rate?: number;
127-
128-
/**
129-
* If true, output is streamed for several characters at a time instead of waiting
130-
* for the full response. The stream terminates with `data: [DONE]`. If false,
131-
* return the encoded audio as octet stream
132-
*/
133-
stream?: boolean;
134-
}
135-
136-
export namespace AudioCreateParams {
137-
export type AudioCreateParamsNonStreaming = AudioAPI.AudioCreateParamsNonStreaming;
138-
export type AudioCreateParamsStreaming = AudioAPI.AudioCreateParamsStreaming;
139-
}
140-
141-
export interface AudioCreateParamsNonStreaming extends AudioCreateParamsBase {
142-
/**
143-
* If true, output is streamed for several characters at a time instead of waiting
144-
* for the full response. The stream terminates with `data: [DONE]`. If false,
145-
* return the encoded audio as octet stream
146-
*/
147-
stream?: false;
148-
}
149-
150-
export interface AudioCreateParamsStreaming extends AudioCreateParamsBase {
151-
/**
152-
* If true, output is streamed for several characters at a time instead of waiting
153-
* for the full response. The stream terminates with `data: [DONE]`. If false,
154-
* return the encoded audio as octet stream
155-
*/
156-
stream: true;
157-
}
158-
159-
export declare namespace Audio {
160-
export {
161-
type AudioFile as AudioFile,
162-
type AudioSpeechStreamChunk as AudioSpeechStreamChunk,
163-
type AudioCreateParams as AudioCreateParams,
164-
type AudioCreateParamsNonStreaming as AudioCreateParamsNonStreaming,
165-
type AudioCreateParamsStreaming as AudioCreateParamsStreaming,
166-
};
167-
}
3+
export * from './audio/index';

0 commit comments

Comments
 (0)