Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Nov 29, 2024
1 parent 4293760 commit 818d16c
Show file tree
Hide file tree
Showing 187 changed files with 384 additions and 4,717 deletions.
9 changes: 1 addition & 8 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
/** @type {import('jest').Config} */
module.exports = {
preset: "ts-jest/presets/default-esm",
preset: "ts-jest",
testEnvironment: "node",
extensionsToTreatAsEsm: [".ts"],
globals: {
"ts-jest": {
useESM: true,
},
},
transformIgnorePatterns: ["/node_modules/(?!(emittery)/)"],
};
26 changes: 11 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cartesia/cartesia-js",
"version": "1.3.1",
"version": "2.0.0-alpha0",
"private": false,
"repository": "https://github.com/cartesia-ai/cartesia-js",
"main": "./index.js",
Expand All @@ -12,33 +12,29 @@
"test": "jest"
},
"dependencies": {
"emittery": "^1.0.3",
"url-join": "4.0.1",
"form-data": "^4.0.0",
"form-data-encoder": "^4.0.2",
"formdata-node": "^6.0.3",
"human-id": "^4.1.1",
"node-fetch": "2.7.0",
"qs": "6.11.2",
"readable-stream": "^4.5.2",
"url-join": "4.0.1",
"ws": "^8.14.2"
"form-data-encoder": "^4.0.2"
},
"devDependencies": {
"@types/jest": "29.5.5",
"@types/node": "17.0.33",
"@types/node-fetch": "2.6.9",
"@types/url-join": "4.0.1",
"@types/qs": "6.9.8",
"@types/node-fetch": "2.6.9",
"@types/readable-stream": "^4.0.15",
"@types/url-join": "4.0.1",
"@types/ws": "^8.5.13",
"fetch-mock-jest": "^1.5.1",
"webpack": "^5.94.0",
"ts-loader": "^9.3.1",
"jest": "29.7.0",
"@types/jest": "29.5.5",
"ts-jest": "29.1.1",
"jest-environment-jsdom": "29.7.0",
"@types/node": "17.0.33",
"prettier": "2.7.1",
"ts-jest": "29.1.1",
"ts-loader": "^9.3.1",
"typescript": "4.6.4",
"webpack": "^5.94.0"
"typescript": "4.6.4"
},
"browser": {
"fs": false,
Expand Down
57 changes: 30 additions & 27 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ await client.apiStatus.get();

## Tts

<details><summary><code>client.tts.<a href="/src/api/resources/tts/client/Client.ts">bytes</a>({ ...params }) -> stream.Readable</code></summary>
<details><summary><code>client.tts.<a href="/src/api/resources/tts/client/Client.ts">bytes</a>({ ...params }) -> void</code></summary>
<dl>
<dd>

Expand All @@ -58,17 +58,17 @@ await client.apiStatus.get();

```typescript
await client.tts.bytes({
modelId: "sonic-english",
model_id: "sonic-english",
transcript: "Hello, world!",
voice: {
mode: "id",
id: "694f9389-aac1-45b6-b726-9d9369183238",
},
language: "en",
outputFormat: {
output_format: {
container: "mp3",
sampleRate: 44100,
bitRate: 128000,
sample_rate: 44100,
bit_rate: 128000,
},
});
```
Expand Down Expand Up @@ -119,18 +119,13 @@ await client.tts.bytes({

```typescript
const response = await client.tts.sse({
modelId: "string",
model_id: "string",
transcript: "string",
voice: {
mode: "id",
id: "string",
experimentalControls: {
speed: 1.1,
emotion: "anger:lowest",
},
},
language: "en",
outputFormat: {
output_format: {
container: "raw",
},
duration: 1.1,
Expand Down Expand Up @@ -205,10 +200,10 @@ This endpoint is priced at 15 characters per second of input audio.

```typescript
await client.voiceChanger.bytes(fs.createReadStream("/path/to/your/file"), {
voiceId: "694f9389-aac1-45b6-b726-9d9369183238",
outputFormatContainer: "mp3",
outputFormatSampleRate: 44100,
outputFormatBitRate: 128000,
"voice[id]": "694f9389-aac1-45b6-b726-9d9369183238",
"output_format[container]": "mp3",
"output_format[sample_rate]": 44100,
"output_format[bit_rate]": 128000,
});
```

Expand Down Expand Up @@ -266,10 +261,10 @@ await client.voiceChanger.bytes(fs.createReadStream("/path/to/your/file"), {

```typescript
const response = await client.voiceChanger.sse(fs.createReadStream("/path/to/your/file"), {
voiceId: "694f9389-aac1-45b6-b726-9d9369183238",
outputFormatContainer: "mp3",
outputFormatSampleRate: 44100,
outputFormatBitRate: 128000,
"voice[id]": "694f9389-aac1-45b6-b726-9d9369183238",
"output_format[container]": "mp3",
"output_format[sample_rate]": 44100,
"output_format[bit_rate]": 128000,
});
for await (const item of response) {
console.log(item);
Expand Down Expand Up @@ -383,7 +378,7 @@ await client.voices.create({
1, 1, 1, 1, 1, 1, 1,
],
language: "en",
baseVoiceId: "string",
base_voice_id: "string",
});
```

Expand Down Expand Up @@ -597,7 +592,7 @@ await client.voices.localize({
1, 1, 1, 1, 1, 1, 1,
],
language: "en",
originalSpeakerGender: "male",
original_speaker_gender: "male",
dialect: "au",
});
```
Expand Down Expand Up @@ -689,7 +684,7 @@ await client.voices.mix({
</dl>
</details>

<details><summary><code>client.voices.<a href="/src/api/resources/voices/client/Client.ts">cloneFromClip</a>(clip, { ...params }) -> Cartesia.EmbeddingResponse</code></summary>
<details><summary><code>client.voices.<a href="/src/api/resources/voices/client/Client.ts">clone</a>(clip, { ...params }) -> Cartesia.VoiceMetadata</code></summary>
<dl>
<dd>

Expand All @@ -701,9 +696,11 @@ await client.voices.mix({
<dl>
<dd>

Clone a voice from a clip. The clip should be a 15-20 second recording of a person speaking with little to no background noise.
Clone a voice from an audio clip. This endpoint has two modes, stability and similarity.

Similarity mode clones are more similar to the source clip, but may reproduce background noise. For these, use an audio clip about 5 seconds long.

The endpoint will return an embedding that can either be used directly with text-to-speech endpoints or used to create a new voice.
Stability mode clones are more stable, but may not sound as similar to the source clip. For these, use an audio clip 10-20 seconds long.

</dd>
</dl>
Expand All @@ -719,7 +716,13 @@ The endpoint will return an embedding that can either be used directly with text
<dd>

```typescript
await client.voices.cloneFromClip(fs.createReadStream("/path/to/your/file"), {});
await client.voices.clone(fs.createReadStream("/path/to/your/file"), {
name: "A high-stability cloned voice",
description: "Copied from Cartesia docs",
mode: "stability",
language: "en",
enhance: true,
});
```

</dd>
Expand All @@ -743,7 +746,7 @@ await client.voices.cloneFromClip(fs.createReadStream("/path/to/your/file"), {})
<dl>
<dd>

**request:** `Cartesia.CloneFromClipRequest`
**request:** `Cartesia.CloneVoiceRequest`

</dd>
</dl>
Expand Down
13 changes: 3 additions & 10 deletions src/api/resources/apiStatus/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import * as environments from "../../../../environments";
import * as core from "../../../../core";
import * as Cartesia from "../../../index";
import * as serializers from "../../../../serialization/index";
import * as errors from "../../../../errors/index";

export declare namespace ApiStatus {
Expand Down Expand Up @@ -46,8 +45,8 @@ export class ApiStatus {
"Cartesia-Version": requestOptions?.cartesiaVersion ?? this._options?.cartesiaVersion ?? "2024-06-10",
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@cartesia/cartesia-js",
"X-Fern-SDK-Version": "1.3.1",
"User-Agent": "@cartesia/cartesia-js/1.3.1",
"X-Fern-SDK-Version": "2.0.0-alpha0",
"User-Agent": "@cartesia/cartesia-js/2.0.0-alpha0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await this._getCustomAuthorizationHeaders()),
Expand All @@ -59,13 +58,7 @@ export class ApiStatus {
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
return serializers.ApiInfo.parseOrThrow(_response.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
});
return _response.body as Cartesia.ApiInfo;
}

if (_response.error.reason === "status-code") {
Expand Down
79 changes: 65 additions & 14 deletions src/api/resources/tts/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import * as environments from "../../../../environments";
import * as core from "../../../../core";
import * as Cartesia from "../../../index";
import * as stream from "stream";
import * as serializers from "../../../../serialization/index";
import urlJoin from "url-join";
import * as errors from "../../../../errors/index";
import * as stream from "stream";
import * as serializers from "../../../../serialization/index";

Check failure on line 11 in src/api/resources/tts/client/Client.ts

View workflow job for this annotation

GitHub Actions / compile

Cannot find module '../../../../serialization/index' or its corresponding type declarations.

export declare namespace Tts {
interface Options {
Expand All @@ -34,8 +34,60 @@ export declare namespace Tts {
export class Tts {
constructor(protected readonly _options: Tts.Options = {}) {}

public async bytes(request: Cartesia.TtsRequest, requestOptions?: Tts.RequestOptions): Promise<stream.Readable> {
const _response = await (this._options.fetcher ?? core.fetcher)<stream.Readable>({
/**
* @param {Cartesia.TtsRequest} request
* @param {Tts.RequestOptions} requestOptions - Request-specific configuration.
*
* @example
* await client.tts.bytes({
* model_id: "sonic-english",
* transcript: "Hello, world!",
* voice: {
* mode: "id",
* id: "694f9389-aac1-45b6-b726-9d9369183238"
* },
* language: "en",
* output_format: {
* container: "mp3",
* sample_rate: 44100,
* bit_rate: 128000
* }
* })
*
* @example
* await client.tts.bytes({
* model_id: "sonic-english",
* transcript: "Hello, world!",
* voice: {
* mode: "id",
* id: "694f9389-aac1-45b6-b726-9d9369183238"
* },
* language: "en",
* output_format: {
* container: "wav",
* sample_rate: 44100,
* encoding: "pcm_f32le"
* }
* })
*
* @example
* await client.tts.bytes({
* model_id: "sonic-english",
* transcript: "Hello, world!",
* voice: {
* mode: "id",
* id: "694f9389-aac1-45b6-b726-9d9369183238"
* },
* language: "en",
* output_format: {
* container: "raw",
* sample_rate: 44100,
* encoding: "pcm_f32le"
* }
* })
*/
public async bytes(request: Cartesia.TtsRequest, requestOptions?: Tts.RequestOptions): Promise<void> {
const _response = await (this._options.fetcher ?? core.fetcher)({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.CartesiaEnvironment.Production,
"/tts/bytes"
Expand All @@ -45,22 +97,21 @@ export class Tts {
"Cartesia-Version": requestOptions?.cartesiaVersion ?? this._options?.cartesiaVersion ?? "2024-06-10",
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@cartesia/cartesia-js",
"X-Fern-SDK-Version": "1.3.1",
"User-Agent": "@cartesia/cartesia-js/1.3.1",
"X-Fern-SDK-Version": "2.0.0-alpha0",
"User-Agent": "@cartesia/cartesia-js/2.0.0-alpha0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await this._getCustomAuthorizationHeaders()),
},
contentType: "application/json",
requestType: "json",
body: serializers.TtsRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
responseType: "streaming",
body: request,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
return _response.body;
return;
}

if (_response.error.reason === "status-code") {
Expand Down Expand Up @@ -99,15 +150,15 @@ export class Tts {
"Cartesia-Version": requestOptions?.cartesiaVersion ?? this._options?.cartesiaVersion ?? "2024-06-10",
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "@cartesia/cartesia-js",
"X-Fern-SDK-Version": "1.3.1",
"User-Agent": "@cartesia/cartesia-js/1.3.1",
"X-Fern-SDK-Version": "2.0.0-alpha0",
"User-Agent": "@cartesia/cartesia-js/2.0.0-alpha0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await this._getCustomAuthorizationHeaders()),
},
contentType: "application/json",
requestType: "json",
body: serializers.TtsRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
body: request,
responseType: "sse",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
Expand All @@ -127,8 +178,8 @@ export class Tts {
},
signal: requestOptions?.abortSignal,
eventShape: {
type: "sse",
streamTerminator: "[DONE]",
type: "json",
messageTerminator: "\n",
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/resources/tts/types/CancelContextRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as Cartesia from "../../../index";

export interface CancelContextRequest {
/** The ID of the context to cancel. */
contextId: Cartesia.ContextId;
context_id: Cartesia.ContextId;
/** Whether to cancel the context, so that no more messages are generated for that context. */
cancel: true;
}
Loading

0 comments on commit 818d16c

Please sign in to comment.