Skip to content

Commit ec4e51d

Browse files
fix(api): fix generate method name (#59)
1 parent f33aedf commit ec4e51d

File tree

6 files changed

+36
-38
lines changed

6 files changed

+36
-38
lines changed

README.md

+17-19
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Lmnt from 'lmnt-node';
2525
const client = new Lmnt();
2626

2727
async function main() {
28-
const response = await client.speech.synthesize({ text: 'hello world.', voice: 'ava' });
28+
const response = await client.speech.generate({ text: 'hello world.', voice: 'ava' });
2929

3030
console.log(response.audio);
3131
}
@@ -44,8 +44,8 @@ import Lmnt from 'lmnt-node';
4444
const client = new Lmnt();
4545

4646
async function main() {
47-
const params: Lmnt.SpeechSynthesizeParams = { text: 'hello world.', voice: 'ava' };
48-
const response: Lmnt.SpeechSynthesizeResponse = await client.speech.synthesize(params);
47+
const params: Lmnt.SpeechGenerateParams = { text: 'hello world.', voice: 'ava' };
48+
const response: Lmnt.SpeechGenerateResponse = await client.speech.generate(params);
4949
}
5050

5151
main();
@@ -62,17 +62,15 @@ a subclass of `APIError` will be thrown:
6262
<!-- prettier-ignore -->
6363
```ts
6464
async function main() {
65-
const response = await client.speech
66-
.synthesize({ text: 'hello world.', voice: 'ava' })
67-
.catch(async (err) => {
68-
if (err instanceof Lmnt.APIError) {
69-
console.log(err.status); // 400
70-
console.log(err.name); // BadRequestError
71-
console.log(err.headers); // {server: 'nginx', ...}
72-
} else {
73-
throw err;
74-
}
75-
});
65+
const response = await client.speech.generate({ text: 'hello world.', voice: 'ava' }).catch(async (err) => {
66+
if (err instanceof Lmnt.APIError) {
67+
console.log(err.status); // 400
68+
console.log(err.name); // BadRequestError
69+
console.log(err.headers); // {server: 'nginx', ...}
70+
} else {
71+
throw err;
72+
}
73+
});
7674
}
7775

7876
main();
@@ -107,7 +105,7 @@ const client = new Lmnt({
107105
});
108106

109107
// Or, configure per-request:
110-
await client.speech.synthesize({ text: 'hello world.', voice: 'ava' }, {
108+
await client.speech.generate({ text: 'hello world.', voice: 'ava' }, {
111109
maxRetries: 5,
112110
});
113111
```
@@ -124,7 +122,7 @@ const client = new Lmnt({
124122
});
125123

126124
// Override per-request:
127-
await client.speech.synthesize({ text: 'hello world.', voice: 'ava' }, {
125+
await client.speech.generate({ text: 'hello world.', voice: 'ava' }, {
128126
timeout: 5 * 1000,
129127
});
130128
```
@@ -145,12 +143,12 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
145143
```ts
146144
const client = new Lmnt();
147145

148-
const response = await client.speech.synthesize({ text: 'hello world.', voice: 'ava' }).asResponse();
146+
const response = await client.speech.generate({ text: 'hello world.', voice: 'ava' }).asResponse();
149147
console.log(response.headers.get('X-My-Header'));
150148
console.log(response.statusText); // access the underlying Response object
151149

152150
const { data: response, response: raw } = await client.speech
153-
.synthesize({ text: 'hello world.', voice: 'ava' })
151+
.generate({ text: 'hello world.', voice: 'ava' })
154152
.withResponse();
155153
console.log(raw.headers.get('X-My-Header'));
156154
console.log(response.audio);
@@ -257,7 +255,7 @@ const client = new Lmnt({
257255
});
258256

259257
// Override per-request:
260-
await client.speech.synthesize(
258+
await client.speech.generate(
261259
{ text: 'hello world.', voice: 'ava' },
262260
{
263261
httpAgent: new http.Agent({ keepAlive: false }),

api.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
Types:
44

5-
- <code><a href="./src/resources/speech.ts">SpeechSynthesizeResponse</a></code>
5+
- <code><a href="./src/resources/speech.ts">SpeechGenerateResponse</a></code>
66

77
Methods:
88

9-
- <code title="post /v1/ai/speech">client.speech.<a href="./src/resources/speech.ts">synthesize</a>({ ...params }) -> SpeechSynthesizeResponse</code>
9+
- <code title="post /v1/ai/speech">client.speech.<a href="./src/resources/speech.ts">generate</a>({ ...params }) -> SpeechGenerateResponse</code>
1010

1111
# Accounts
1212

src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as Errors from './error';
66
import * as Uploads from './uploads';
77
import * as API from './resources/index';
88
import { AccountRetrieveResponse, Accounts } from './resources/accounts';
9-
import { Speech, SpeechSynthesizeParams, SpeechSynthesizeResponse } from './resources/speech';
9+
import { Speech, SpeechGenerateParams, SpeechGenerateResponse } from './resources/speech';
1010
import {
1111
Voice,
1212
VoiceCreateParams,
@@ -179,8 +179,8 @@ export declare namespace Lmnt {
179179

180180
export {
181181
Speech as Speech,
182-
type SpeechSynthesizeResponse as SpeechSynthesizeResponse,
183-
type SpeechSynthesizeParams as SpeechSynthesizeParams,
182+
type SpeechGenerateResponse as SpeechGenerateResponse,
183+
type SpeechGenerateParams as SpeechGenerateParams,
184184
};
185185

186186
export { Accounts as Accounts, type AccountRetrieveResponse as AccountRetrieveResponse };

src/resources/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
export { Accounts, type AccountRetrieveResponse } from './accounts';
4-
export { Speech, type SpeechSynthesizeResponse, type SpeechSynthesizeParams } from './speech';
4+
export { Speech, type SpeechGenerateResponse, type SpeechGenerateParams } from './speech';
55
export {
66
Voices,
77
type Voice,

src/resources/speech.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ export class Speech extends APIResource {
1010
* the seed used in speech generation, and optionally an object detailing the
1111
* duration of each word spoken.
1212
*/
13-
synthesize(
14-
body: SpeechSynthesizeParams,
13+
generate(
14+
body: SpeechGenerateParams,
1515
options?: Core.RequestOptions,
16-
): Core.APIPromise<SpeechSynthesizeResponse> {
16+
): Core.APIPromise<SpeechGenerateResponse> {
1717
return this._client.post('/v1/ai/speech', Core.multipartFormRequestOptions({ body, ...options }));
1818
}
1919
}
2020

21-
export interface SpeechSynthesizeResponse {
21+
export interface SpeechGenerateResponse {
2222
/**
2323
* The base64-encoded audio file; the format is determined by the `format`
2424
* parameter.
@@ -38,10 +38,10 @@ export interface SpeechSynthesizeResponse {
3838
* [example of this object](https://imgur.com/Uw6qNzY.png) for the input string
3939
* "Hello world!"
4040
*/
41-
durations?: Array<SpeechSynthesizeResponse.Duration>;
41+
durations?: Array<SpeechGenerateResponse.Duration>;
4242
}
4343

44-
export namespace SpeechSynthesizeResponse {
44+
export namespace SpeechGenerateResponse {
4545
export interface Duration {
4646
/**
4747
* The spoken duration of each synthesized input element, in seconds.
@@ -60,7 +60,7 @@ export namespace SpeechSynthesizeResponse {
6060
}
6161
}
6262

63-
export interface SpeechSynthesizeParams {
63+
export interface SpeechGenerateParams {
6464
/**
6565
* The text to synthesize; max 5000 characters per request (including spaces)
6666
*/
@@ -123,7 +123,7 @@ export interface SpeechSynthesizeParams {
123123

124124
export declare namespace Speech {
125125
export {
126-
type SpeechSynthesizeResponse as SpeechSynthesizeResponse,
127-
type SpeechSynthesizeParams as SpeechSynthesizeParams,
126+
type SpeechGenerateResponse as SpeechGenerateResponse,
127+
type SpeechGenerateParams as SpeechGenerateParams,
128128
};
129129
}

tests/api-resources/speech.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const client = new Lmnt({
99
});
1010

1111
describe('resource speech', () => {
12-
test('synthesize: only required params', async () => {
13-
const responsePromise = client.speech.synthesize({ text: 'hello world.', voice: 'ava' });
12+
test('generate: only required params', async () => {
13+
const responsePromise = client.speech.generate({ text: 'hello world.', voice: 'ava' });
1414
const rawResponse = await responsePromise.asResponse();
1515
expect(rawResponse).toBeInstanceOf(Response);
1616
const response = await responsePromise;
@@ -20,8 +20,8 @@ describe('resource speech', () => {
2020
expect(dataAndResponse.response).toBe(rawResponse);
2121
});
2222

23-
test('synthesize: required and optional params', async () => {
24-
const response = await client.speech.synthesize({
23+
test('generate: required and optional params', async () => {
24+
const response = await client.speech.generate({
2525
text: 'hello world.',
2626
voice: 'ava',
2727
conversational: true,

0 commit comments

Comments
 (0)