Skip to content

Commit

Permalink
SDK regeneration (#62)
Browse files Browse the repository at this point in the history
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
  • Loading branch information
fern-api[bot] authored Jul 10, 2024
1 parent e950909 commit 95d3803
Show file tree
Hide file tree
Showing 28 changed files with 343 additions and 96 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elevenlabs",
"version": "0.8.2",
"version": "0.9.0",
"private": false,
"repository": "https://github.com/elevenlabs/elevenlabs-js",
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as environments from "./environments";
import * as core from "./core";
import { History } from "./api/resources/history/client/Client";
import { TextToSoundEffects } from "./api/resources/textToSoundEffects/client/Client";
import { AudioIsolation } from "./api/resources/audioIsolation/client/Client";
import { Samples } from "./api/resources/samples/client/Client";
import { TextToSpeech } from "./api/resources/textToSpeech/client/Client";
import { SpeechToSpeech } from "./api/resources/speechToSpeech/client/Client";
Expand Down Expand Up @@ -53,6 +54,12 @@ export class ElevenLabsClient {
return (this._textToSoundEffects ??= new TextToSoundEffects(this._options));
}

protected _audioIsolation: AudioIsolation | undefined;

public get audioIsolation(): AudioIsolation {
return (this._audioIsolation ??= new AudioIsolation(this._options));
}

protected _samples: Samples | undefined;

public get samples(): Samples {
Expand Down
184 changes: 184 additions & 0 deletions src/api/resources/audioIsolation/client/Client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as environments from "../../../../environments";
import * as core from "../../../../core";
import * as ElevenLabs from "../../../index";
import * as fs from "fs";
import urlJoin from "url-join";
import * as errors from "../../../../errors/index";

export declare namespace AudioIsolation {
interface Options {
environment?: core.Supplier<environments.ElevenLabsEnvironment | string>;
apiKey?: core.Supplier<string | undefined>;
}

interface RequestOptions {
/** The maximum time to wait for a response in seconds. */
timeoutInSeconds?: number;
/** The number of times to retry the request. Defaults to 2. */
maxRetries?: number;
/** A hook to abort the request. */
abortSignal?: AbortSignal;
/** Override the xi-api-key header */
apiKey?: string | undefined;
}
}

export class AudioIsolation {
constructor(protected readonly _options: AudioIsolation.Options = {}) {}

/**
* Removes background noise from audio
*
* @param {ElevenLabs.BodyAudioIsolationV1AudioIsolationPost} request
* @param {AudioIsolation.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link ElevenLabs.UnprocessableEntityError}
*
* @example
* await client.audioIsolation.audioIsolation({
* audio: fs.createReadStream("/path/to/your/file")
* })
*/
public async audioIsolation(
request: ElevenLabs.BodyAudioIsolationV1AudioIsolationPost,
requestOptions?: AudioIsolation.RequestOptions
): Promise<ElevenLabs.AudioIsolationResponseModel> {
const _request = new core.FormDataWrapper();
await _request.append("audio", request.audio);
const _maybeEncodedRequest = _request.getRequest();
const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production,
"v1/audio-isolation"
),
method: "POST",
headers: {
"xi-api-key":
(await core.Supplier.get(this._options.apiKey)) != null
? await core.Supplier.get(this._options.apiKey)
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await _maybeEncodedRequest.getHeaders()),
},
body: await _maybeEncodedRequest.getBody(),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
return _response.body as ElevenLabs.AudioIsolationResponseModel;
}

if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 422:
throw new ElevenLabs.UnprocessableEntityError(
_response.error.body as ElevenLabs.HttpValidationError
);
default:
throw new errors.ElevenLabsError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
}
}

switch (_response.error.reason) {
case "non-json":
throw new errors.ElevenLabsError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
});
case "timeout":
throw new errors.ElevenLabsTimeoutError();
case "unknown":
throw new errors.ElevenLabsError({
message: _response.error.errorMessage,
});
}
}

/**
* Removes background noise from audio and streams the result
*
* @param {ElevenLabs.BodyAudioIsolationStreamV1AudioIsolationStreamPost} request
* @param {AudioIsolation.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link ElevenLabs.UnprocessableEntityError}
*
* @example
* await client.audioIsolation.audioIsolationStream({
* audio: fs.createReadStream("/path/to/your/file")
* })
*/
public async audioIsolationStream(
request: ElevenLabs.BodyAudioIsolationStreamV1AudioIsolationStreamPost,
requestOptions?: AudioIsolation.RequestOptions
): Promise<void> {
const _request = new core.FormDataWrapper();
await _request.append("audio", request.audio);
const _maybeEncodedRequest = _request.getRequest();
const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production,
"v1/audio-isolation/stream"
),
method: "POST",
headers: {
"xi-api-key":
(await core.Supplier.get(this._options.apiKey)) != null
? await core.Supplier.get(this._options.apiKey)
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await _maybeEncodedRequest.getHeaders()),
},
body: await _maybeEncodedRequest.getBody(),
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
return;
}

if (_response.error.reason === "status-code") {
switch (_response.error.statusCode) {
case 422:
throw new ElevenLabs.UnprocessableEntityError(
_response.error.body as ElevenLabs.HttpValidationError
);
default:
throw new errors.ElevenLabsError({
statusCode: _response.error.statusCode,
body: _response.error.body,
});
}
}

switch (_response.error.reason) {
case "non-json":
throw new errors.ElevenLabsError({
statusCode: _response.error.statusCode,
body: _response.error.rawBody,
});
case "timeout":
throw new errors.ElevenLabsTimeoutError();
case "unknown":
throw new errors.ElevenLabsError({
message: _response.error.errorMessage,
});
}
}
}
1 change: 1 addition & 0 deletions src/api/resources/audioIsolation/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./requests";
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as fs from "fs";

/**
* @example
* {
* audio: fs.createReadStream("/path/to/your/file")
* }
*/
export interface BodyAudioIsolationStreamV1AudioIsolationStreamPost {
audio: File | fs.ReadStream;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as fs from "fs";

/**
* @example
* {
* audio: fs.createReadStream("/path/to/your/file")
* }
*/
export interface BodyAudioIsolationV1AudioIsolationPost {
audio: File | fs.ReadStream;
}
2 changes: 2 additions & 0 deletions src/api/resources/audioIsolation/client/requests/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { type BodyAudioIsolationV1AudioIsolationPost } from "./BodyAudioIsolationV1AudioIsolationPost";
export { type BodyAudioIsolationStreamV1AudioIsolationStreamPost } from "./BodyAudioIsolationStreamV1AudioIsolationStreamPost";
1 change: 1 addition & 0 deletions src/api/resources/audioIsolation/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./client";
2 changes: 1 addition & 1 deletion src/api/resources/audioNative/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class AudioNative {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.2",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await _maybeEncodedRequest.getHeaders()),
Expand Down
12 changes: 6 additions & 6 deletions src/api/resources/chapters/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class Chapters {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.2",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -129,7 +129,7 @@ export class Chapters {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.2",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -201,7 +201,7 @@ export class Chapters {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.2",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -273,7 +273,7 @@ export class Chapters {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.2",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -345,7 +345,7 @@ export class Chapters {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.2",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -423,7 +423,7 @@ export class Chapters {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.2",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down
10 changes: 5 additions & 5 deletions src/api/resources/dubbing/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class Dubbing {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.2",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await _maybeEncodedRequest.getHeaders()),
Expand Down Expand Up @@ -190,7 +190,7 @@ export class Dubbing {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.2",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -257,7 +257,7 @@ export class Dubbing {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.2",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -321,7 +321,7 @@ export class Dubbing {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.2",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -402,7 +402,7 @@ export class Dubbing {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.2",
"X-Fern-SDK-Version": "0.9.0",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down
Loading

0 comments on commit 95d3803

Please sign in to comment.