-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
- Loading branch information
1 parent
e950909
commit 95d3803
Showing
28 changed files
with
343 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./requests"; |
15 changes: 15 additions & 0 deletions
15
...rces/audioIsolation/client/requests/BodyAudioIsolationStreamV1AudioIsolationStreamPost.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/api/resources/audioIsolation/client/requests/BodyAudioIsolationV1AudioIsolationPost.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { type BodyAudioIsolationV1AudioIsolationPost } from "./BodyAudioIsolationV1AudioIsolationPost"; | ||
export { type BodyAudioIsolationStreamV1AudioIsolationStreamPost } from "./BodyAudioIsolationStreamV1AudioIsolationStreamPost"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./client"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.