Skip to content

Commit

Permalink
(feat): introduce text to sound effects (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] authored Jun 22, 2024
1 parent 6e0dd5b commit db991d3
Show file tree
Hide file tree
Showing 69 changed files with 1,365 additions and 142 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.0",
"version": "0.8.1",
"private": false,
"repository": "https://github.com/elevenlabs/elevenlabs-js",
"license": "MIT",
Expand Down
14 changes: 14 additions & 0 deletions src/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 { History } from "./api/resources/history/client/Client";
import { TextToSoundEffects } from "./api/resources/textToSoundEffects/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 All @@ -17,6 +18,7 @@ import { Dubbing } from "./api/resources/dubbing/client/Client";
import { Models } from "./api/resources/models/client/Client";
import { AudioNative } from "./api/resources/audioNative/client/Client";
import { PronunciationDictionary } from "./api/resources/pronunciationDictionary/client/Client";
import { Workspace } from "./api/resources/workspace/client/Client";

export declare namespace ElevenLabsClient {
interface Options {
Expand All @@ -40,6 +42,12 @@ export class ElevenLabsClient {
return (this._history ??= new History(this._options));
}

protected _textToSoundEffects: TextToSoundEffects | undefined;

public get textToSoundEffects(): TextToSoundEffects {
return (this._textToSoundEffects ??= new TextToSoundEffects(this._options));
}

protected _samples: Samples | undefined;

public get samples(): Samples {
Expand Down Expand Up @@ -111,4 +119,10 @@ export class ElevenLabsClient {
public get pronunciationDictionary(): PronunciationDictionary {
return (this._pronunciationDictionary ??= new PronunciationDictionary(this._options));
}

protected _workspace: Workspace | undefined;

public get workspace(): Workspace {
return (this._workspace ??= new Workspace(this._options));
}
}
9 changes: 5 additions & 4 deletions src/api/resources/audioNative/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 ElevenLabs from "../../../index";
import * as fs from "fs";
import urlJoin from "url-join";
import * as errors from "../../../../errors/index";

Expand Down Expand Up @@ -35,7 +34,6 @@ export class AudioNative {
*
* @example
* await elevenLabs.audioNative.create({
* file: fs.createReadStream("/path/to/your/file"),
* name: "name"
* })
*/
Expand Down Expand Up @@ -81,7 +79,10 @@ export class AudioNative {
await _request.append("model_id", request.model_id);
}

await _request.append("file", request.file);
if (request.file != null) {
await _request.append("file", request.file);
}

if (request.auto_convert != null) {
await _request.append("auto_convert", request.auto_convert.toString());
}
Expand All @@ -100,7 +101,7 @@ export class AudioNative {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await _maybeEncodedRequest.getHeaders()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import * as fs from "fs";
/**
* @example
* {
* file: fs.createReadStream("/path/to/your/file"),
* name: "name"
* }
*/
Expand All @@ -32,7 +31,7 @@ export interface BodyCreatesAudioNativeEnabledProjectV1AudioNativePost {
voice_id?: string;
/** TTS Model ID used in the player. If not provided, default model ID set in the Player settings is used. */
model_id?: string;
file: File | fs.ReadStream;
file?: File | fs.ReadStream | undefined;
/** Whether to auto convert the project to audio or not. */
auto_convert?: boolean;
}
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 @@ -52,7 +52,7 @@ export class Chapters {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -124,7 +124,7 @@ export class Chapters {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -196,7 +196,7 @@ export class Chapters {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -268,7 +268,7 @@ export class Chapters {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -340,7 +340,7 @@ export class Chapters {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -418,7 +418,7 @@ export class Chapters {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down
89 changes: 85 additions & 4 deletions src/api/resources/dubbing/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class Dubbing {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
...(await _maybeEncodedRequest.getHeaders()),
Expand Down Expand Up @@ -185,7 +185,7 @@ export class Dubbing {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -252,7 +252,7 @@ export class Dubbing {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -316,7 +316,7 @@ export class Dubbing {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -358,4 +358,85 @@ export class Dubbing {
});
}
}

/**
* Returns transcript for the dub as an SRT file.
*
* @param {string} dubbingId - ID of the dubbing project.
* @param {string} languageCode - ID of the language.
* @param {ElevenLabs.GetTranscriptForDubV1DubbingDubbingIdTranscriptLanguageCodeGetRequest} request
* @param {Dubbing.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link ElevenLabs.UnprocessableEntityError}
*
* @example
* await elevenLabs.dubbing.getTranscriptForDub("dubbing_id", "language_code")
*/
public async getTranscriptForDub(
dubbingId: string,
languageCode: string,
request: ElevenLabs.GetTranscriptForDubV1DubbingDubbingIdTranscriptLanguageCodeGetRequest = {},
requestOptions?: Dubbing.RequestOptions
): Promise<unknown> {
const { format_type: formatType } = request;
const _queryParams: Record<string, string | string[] | object | object[]> = {};
if (formatType != null) {
_queryParams["format_type"] = formatType;
}

const _response = await core.fetcher({
url: urlJoin(
(await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production,
`v1/dubbing/${encodeURIComponent(dubbingId)}/transcript/${encodeURIComponent(languageCode)}`
),
method: "GET",
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.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
contentType: "application/json",
queryParameters: _queryParams,
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
maxRetries: requestOptions?.maxRetries,
abortSignal: requestOptions?.abortSignal,
});
if (_response.ok) {
return _response.body;
}

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,
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as fs from "fs";
* }
*/
export interface BodyDubAVideoOrAnAudioFileV1DubbingPost {
/** automatic or manual. */
/** automatic or manual. Manual mode is only supported when creating a dubbing studio project */
mode?: string;
file?: File | fs.ReadStream | undefined;
csv_file?: File | fs.ReadStream | undefined;
Expand All @@ -25,7 +25,7 @@ export interface BodyDubAVideoOrAnAudioFileV1DubbingPost {
source_lang?: string;
/** The Target language to dub the content into. Can be none if dubbing studio editor is enabled and running manual mode */
target_lang: string;
/** Number of speakers to use for the dubbing. */
/** Number of speakers to use for the dubbing. Set to 0 to automatically detect the number of speakers */
num_speakers?: number;
/** Whether to apply watermark to the output video. */
watermark?: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

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

/**
* @example
* {}
*/
export interface GetTranscriptForDubV1DubbingDubbingIdTranscriptLanguageCodeGetRequest {
/**
* Format to use for the subtitle file, either 'srt' or 'webvtt'
*/
format_type?: ElevenLabs.GetTranscriptForDubV1DubbingDubbingIdTranscriptLanguageCodeGetRequestFormatType;
}
1 change: 1 addition & 0 deletions src/api/resources/dubbing/client/requests/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { type BodyDubAVideoOrAnAudioFileV1DubbingPost } from "./BodyDubAVideoOrAnAudioFileV1DubbingPost";
export { type GetTranscriptForDubV1DubbingDubbingIdTranscriptLanguageCodeGetRequest } from "./GetTranscriptForDubV1DubbingDubbingIdTranscriptLanguageCodeGetRequest";
1 change: 1 addition & 0 deletions src/api/resources/dubbing/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./types";
export * from "./client";
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

/**
* Format to use for the subtitle file, either 'srt' or 'webvtt'
*/
export type GetTranscriptForDubV1DubbingDubbingIdTranscriptLanguageCodeGetRequestFormatType = "srt" | "webvtt";

export const GetTranscriptForDubV1DubbingDubbingIdTranscriptLanguageCodeGetRequestFormatType = {
Srt: "srt",
Webvtt: "webvtt",
} as const;
1 change: 1 addition & 0 deletions src/api/resources/dubbing/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./GetTranscriptForDubV1DubbingDubbingIdTranscriptLanguageCodeGetRequestFormatType";
10 changes: 5 additions & 5 deletions src/api/resources/history/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class History {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -145,7 +145,7 @@ export class History {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -212,7 +212,7 @@ export class History {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -272,7 +272,7 @@ export class History {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down Expand Up @@ -345,7 +345,7 @@ export class History {
: undefined,
"X-Fern-Language": "JavaScript",
"X-Fern-SDK-Name": "elevenlabs",
"X-Fern-SDK-Version": "0.8.0",
"X-Fern-SDK-Version": "0.8.1",
"X-Fern-Runtime": core.RUNTIME.type,
"X-Fern-Runtime-Version": core.RUNTIME.version,
},
Expand Down
Loading

0 comments on commit db991d3

Please sign in to comment.