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 818d16c commit 55dd3ac
Show file tree
Hide file tree
Showing 180 changed files with 4,687 additions and 196 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,30 @@ jobs:

- name: Compile
run: yarn && yarn test

publish:
needs: [ compile, test ]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up node
uses: actions/setup-node@v3
- name: Install dependencies
run: yarn install
- name: Build
run: yarn build

- name: Publish to npm
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
if [[ ${GITHUB_REF} == *alpha* ]]; then
npm publish --access public --tag alpha
elif [[ ${GITHUB_REF} == *beta* ]]; then
npm publish --access public --tag beta
else
npm publish --access public
fi
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
39 changes: 22 additions & 17 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 }) -> void</code></summary>
<details><summary><code>client.tts.<a href="/src/api/resources/tts/client/Client.ts">bytes</a>({ ...params }) -> stream.Readable</code></summary>
<dl>
<dd>

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

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

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

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

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

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

Expand Down Expand Up @@ -592,7 +597,7 @@ await client.voices.localize({
1, 1, 1, 1, 1, 1, 1,
],
language: "en",
original_speaker_gender: "male",
originalSpeakerGender: "male",
dialect: "au",
});
```
Expand Down
9 changes: 8 additions & 1 deletion src/api/resources/apiStatus/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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 @@ -58,7 +59,13 @@ export class ApiStatus {
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
return _response.body as Cartesia.ApiInfo;
return serializers.ApiInfo.parseOrThrow(_response.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
});
}

if (_response.error.reason === "status-code") {
Expand Down
71 changes: 10 additions & 61 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 urlJoin from "url-join";
import * as errors from "../../../../errors/index";
import * as stream from "stream";
import * as serializers from "../../../../serialization/index";
import urlJoin from "url-join";
import * as errors from "../../../../errors/index";

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

/**
* @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)({
public async bytes(request: Cartesia.TtsRequest, requestOptions?: Tts.RequestOptions): Promise<stream.Readable> {
const _response = await (this._options.fetcher ?? core.fetcher)<stream.Readable>({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.CartesiaEnvironment.Production,
"/tts/bytes"
Expand All @@ -105,13 +53,14 @@ export class Tts {
},
contentType: "application/json",
requestType: "json",
body: request,
body: serializers.TtsRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
responseType: "streaming",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
return;
return _response.body;
}

if (_response.error.reason === "status-code") {
Expand Down Expand Up @@ -158,7 +107,7 @@ export class Tts {
},
contentType: "application/json",
requestType: "json",
body: request,
body: serializers.TtsRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
responseType: "sse",
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
Expand All @@ -178,8 +127,8 @@ export class Tts {
},
signal: requestOptions?.abortSignal,
eventShape: {
type: "json",
messageTerminator: "\n",
type: "sse",
streamTerminator: "[DONE]",
},
});
}
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. */
context_id: Cartesia.ContextId;
contextId: Cartesia.ContextId;
/** Whether to cancel the context, so that no more messages are generated for that context. */
cancel: true;
}
8 changes: 4 additions & 4 deletions src/api/resources/tts/types/GenerationRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ import * as Cartesia from "../../../index";

export interface GenerationRequest {
/** The ID of the model to use for the generation. See [Models](/build-with-sonic/models) for available models. */
model_id: string;
modelId: string;
transcript: string;
voice: Cartesia.TtsRequestVoiceSpecifier;
language?: Cartesia.SupportedLanguage;
output_format: Cartesia.WebSocketRawOutputFormat;
outputFormat: Cartesia.WebSocketRawOutputFormat;
/**
* The maximum duration of the audio in seconds. You do not usually need to specify this.
* If the duration is not appropriate for the length of the transcript, the output audio may be truncated.
*/
duration?: number;
context_id: Cartesia.ContextId;
contextId: Cartesia.ContextId;
/**
* Whether this input may be followed by more inputs.
* If not specified, this defaults to `false`.
*/
continue?: boolean;
/** Whether to return word-level timestamps. */
add_timestamps?: boolean;
addTimestamps?: boolean;
}
4 changes: 2 additions & 2 deletions src/api/resources/tts/types/Mp3OutputFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
*/

export interface Mp3OutputFormat {
sample_rate: number;
bit_rate: number;
sampleRate: number;
bitRate: number;
}
2 changes: 1 addition & 1 deletion src/api/resources/tts/types/RawOutputFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import * as Cartesia from "../../../index";

export interface RawOutputFormat {
encoding: Cartesia.RawEncoding;
sample_rate: number;
sampleRate: number;
}
4 changes: 2 additions & 2 deletions src/api/resources/tts/types/TtsRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import * as Cartesia from "../../../index";

export interface TtsRequest {
/** The ID of the model to use for the generation. See [Models](/build-with-sonic/models) for available models. */
model_id: string;
modelId: string;
transcript: string;
voice: Cartesia.TtsRequestVoiceSpecifier;
language?: Cartesia.SupportedLanguage;
output_format: Cartesia.OutputFormat;
outputFormat: Cartesia.OutputFormat;
/**
* The maximum duration of the audio in seconds. You do not usually need to specify this.
* If the duration is not appropriate for the length of the transcript, the output audio may be truncated.
Expand Down
3 changes: 2 additions & 1 deletion src/api/resources/tts/types/TtsRequestEmbeddingSpecifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import * as Cartesia from "../../../index";

export interface TtsRequestEmbeddingSpecifier {
mode: "embedding";
embedding: Cartesia.Embedding;
__experimental_controls?: Cartesia.Controls;
experimentalControls?: Cartesia.Controls;
}
3 changes: 2 additions & 1 deletion src/api/resources/tts/types/TtsRequestIdSpecifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import * as Cartesia from "../../../index";

export interface TtsRequestIdSpecifier {
mode: "id";
id: Cartesia.VoiceId;
__experimental_controls?: Cartesia.Controls;
experimentalControls?: Cartesia.Controls;
}
14 changes: 1 addition & 13 deletions src/api/resources/tts/types/TtsRequestVoiceSpecifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,4 @@

import * as Cartesia from "../../../index";

export type TtsRequestVoiceSpecifier =
| Cartesia.TtsRequestVoiceSpecifier.Id
| Cartesia.TtsRequestVoiceSpecifier.Embedding;

export declare namespace TtsRequestVoiceSpecifier {
interface Id extends Cartesia.TtsRequestIdSpecifier {
mode: "id";
}

interface Embedding extends Cartesia.TtsRequestEmbeddingSpecifier {
mode: "embedding";
}
}
export type TtsRequestVoiceSpecifier = Cartesia.TtsRequestIdSpecifier | Cartesia.TtsRequestEmbeddingSpecifier;
4 changes: 2 additions & 2 deletions src/api/resources/tts/types/WebSocketBaseResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as Cartesia from "../../../index";

export interface WebSocketBaseResponse {
context_id: Cartesia.ContextId;
status_code: number;
contextId?: Cartesia.ContextId;
statusCode: number;
done: boolean;
}
2 changes: 1 addition & 1 deletion src/api/resources/tts/types/WebSocketChunkResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import * as Cartesia from "../../../index";

export interface WebSocketChunkResponse extends Cartesia.WebSocketBaseResponse {
data: string;
step_time: number;
stepTime: number;
}
2 changes: 1 addition & 1 deletion src/api/resources/tts/types/WebSocketRawOutputFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import * as Cartesia from "../../../index";
export interface WebSocketRawOutputFormat {
container: "raw";
encoding: Cartesia.RawEncoding;
sample_rate: number;
sampleRate: number;
}
Loading

0 comments on commit 55dd3ac

Please sign in to comment.