repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.getProjectById
public async getProjectById( projectId: string, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.ProjectExtendedResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.ProjectExtendedResponseModel; } 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("Timeout exceeded when calling GET /v1/projects/{project_id}."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Returns information about a specific project. This endpoint returns more detailed information about a project than `GET /v1/projects`. * * @param {string} projectId - The ID of the Studio project. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.getProjectById("21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L389-L451
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.editBasicProjectInfo
public async editBasicProjectInfo( projectId: string, request: ElevenLabs.BodyEditBasicProjectInfoV1ProjectsProjectIdPost, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.EditProjectResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.EditProjectResponseModel; } 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( "Timeout exceeded when calling POST /v1/projects/{project_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Edits basic project info. * * @param {string} projectId - The ID of the Studio project. * @param {ElevenLabs.BodyEditBasicProjectInfoV1ProjectsProjectIdPost} request * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.editBasicProjectInfo("21m00Tcm4TlvDq8ikWAM", { * name: "name", * default_title_voice_id: "default_title_voice_id", * default_paragraph_voice_id: "default_paragraph_voice_id" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L469-L535
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.deleteProject
public async deleteProject(projectId: string, requestOptions?: Projects.RequestOptions): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}`, ), method: "DELETE", 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", 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( "Timeout exceeded when calling DELETE /v1/projects/{project_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Deletes a project. * * @param {string} projectId - The ID of the Studio project. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.deleteProject("21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L548-L609
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.editProjectContent
public async editProjectContent( projectId: string, request: ElevenLabs.BodyEditProjectContentV1ProjectsProjectIdContentPost, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.EditProjectResponseModel> { const _request = await core.newFormData(); if (request.from_url != null) { _request.append("from_url", request.from_url); } if (request.from_document != null) { await _request.appendFile("from_document", request.from_document); } if (request.auto_convert != null) { _request.append("auto_convert", request.auto_convert.toString()); } const _maybeEncodedRequest = await _request.getRequest(); const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/content`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ..._maybeEncodedRequest.headers, ...requestOptions?.headers, }, requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.EditProjectResponseModel; } 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( "Timeout exceeded when calling POST /v1/projects/{project_id}/content.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Edits project content. * * @param {string} projectId * @param {ElevenLabs.BodyEditProjectContentV1ProjectsProjectIdContentPost} request * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.editProjectContent("21m00Tcm4TlvDq8ikWAM", {}) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L623-L704
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.convertProject
public async convertProject(projectId: string, requestOptions?: Projects.RequestOptions): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/convert`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", 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( "Timeout exceeded when calling POST /v1/projects/{project_id}/convert.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Starts conversion of a project and all of its chapters. * * @param {string} projectId - The ID of the Studio project. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.convertProject("21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L717-L778
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.getProjectSnapshots
public async getProjectSnapshots( projectId: string, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.ProjectSnapshotsResponse> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/snapshots`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.ProjectSnapshotsResponse; } 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( "Timeout exceeded when calling GET /v1/projects/{project_id}/snapshots.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Gets the snapshots of a project. * * @param {string} projectId - The ID of the Studio project. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.getProjectSnapshots("21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L791-L855
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.streamProjectAudio
public async streamProjectAudio( projectId: string, projectSnapshotId: string, request: ElevenLabs.BodyStreamProjectAudioV1ProjectsProjectIdSnapshotsProjectSnapshotIdStreamPost = {}, requestOptions?: Projects.RequestOptions, ): Promise<stream.Readable> { const _response = await core.fetcher<stream.Readable>({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/snapshots/${encodeURIComponent(projectSnapshotId)}/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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, responseType: "streaming", 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( "Timeout exceeded when calling POST /v1/projects/{project_id}/snapshots/{project_snapshot_id}/stream.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Stream the audio from a project snapshot. * @throws {@link ElevenLabs.UnprocessableEntityError} */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L861-L929
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.streamsArchiveWithProjectAudio
public async streamsArchiveWithProjectAudio( projectId: string, projectSnapshotId: string, requestOptions?: Projects.RequestOptions, ): Promise<void> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/snapshots/${encodeURIComponent(projectSnapshotId)}/archive`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", 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( "Timeout exceeded when calling POST /v1/projects/{project_id}/snapshots/{project_snapshot_id}/archive.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Streams archive with project audio. * * @param {string} projectId - The ID of the Studio project. * @param {string} projectSnapshotId - The ID of the Studio project snapshot. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.streamsArchiveWithProjectAudio("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L943-L1008
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.getChapters
public async getChapters( projectId: string, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.GetChaptersResponse> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/chapters`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.GetChaptersResponse; } 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( "Timeout exceeded when calling GET /v1/projects/{project_id}/chapters.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Returns a list of your chapters for a project together and its metadata. * * @param {string} projectId - The ID of the Studio project. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.getChapters("21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L1021-L1085
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.getChapterById
public async getChapterById( projectId: string, chapterId: string, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.ChapterWithContentResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/chapters/${encodeURIComponent(chapterId)}`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.ChapterWithContentResponseModel; } 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( "Timeout exceeded when calling GET /v1/projects/{project_id}/chapters/{chapter_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Returns information about a specific chapter. * * @param {string} projectId - The ID of the Studio project. * @param {string} chapterId - The ID of the chapter. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.getChapterById("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L1099-L1164
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.deleteChapter
public async deleteChapter( projectId: string, chapterId: string, requestOptions?: Projects.RequestOptions, ): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/chapters/${encodeURIComponent(chapterId)}`, ), method: "DELETE", 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", 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( "Timeout exceeded when calling DELETE /v1/projects/{project_id}/chapters/{chapter_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Deletes a chapter. * * @param {string} projectId - The ID of the Studio project. * @param {string} chapterId - The ID of the chapter. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.deleteChapter("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L1178-L1243
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.editChapter
public async editChapter( projectId: string, chapterId: string, request: ElevenLabs.BodyEditChapterV1ProjectsProjectIdChaptersChapterIdPatch = {}, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.EditChapterResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/chapters/${encodeURIComponent(chapterId)}`, ), method: "PATCH", 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.EditChapterResponseModel; } 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( "Timeout exceeded when calling PATCH /v1/projects/{project_id}/chapters/{chapter_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Edits a chapter. * * @param {string} projectId - The ID of the Studio project. * @param {string} chapterId - The ID of the chapter. * @param {ElevenLabs.BodyEditChapterV1ProjectsProjectIdChaptersChapterIdPatch} request * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.editChapter("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L1258-L1325
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.addChapterToAProject
public async addChapterToAProject( projectId: string, request: ElevenLabs.BodyAddChapterToAProjectV1ProjectsProjectIdChaptersAddPost, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.AddChapterResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/chapters/add`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.AddChapterResponseModel; } 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( "Timeout exceeded when calling POST /v1/projects/{project_id}/chapters/add.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Creates a new chapter either as blank or from a URL. * * @param {string} projectId - The ID of the Studio project. * @param {ElevenLabs.BodyAddChapterToAProjectV1ProjectsProjectIdChaptersAddPost} request * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.addChapterToAProject("21m00Tcm4TlvDq8ikWAM", { * name: "name" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L1341-L1407
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.convertChapter
public async convertChapter( projectId: string, chapterId: string, requestOptions?: Projects.RequestOptions, ): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/chapters/${encodeURIComponent(chapterId)}/convert`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", 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( "Timeout exceeded when calling POST /v1/projects/{project_id}/chapters/{chapter_id}/convert.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Starts conversion of a specific chapter. * * @param {string} projectId - The ID of the Studio project. * @param {string} chapterId - The ID of the chapter. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.convertChapter("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L1421-L1486
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.listChapterSnapshots
public async listChapterSnapshots( projectId: string, chapterId: string, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.ChapterSnapshotsResponse> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/chapters/${encodeURIComponent(chapterId)}/snapshots`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.ChapterSnapshotsResponse; } 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( "Timeout exceeded when calling GET /v1/projects/{project_id}/chapters/{chapter_id}/snapshots.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Gets information about all the snapshots of a chapter, each snapshot corresponds can be downloaded as audio. Whenever a chapter is converted a snapshot will be automatically created. * * @param {string} projectId - The ID of the Studio project. * @param {string} chapterId - The ID of the chapter. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.listChapterSnapshots("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L1500-L1565
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.streamChapterAudio
public async streamChapterAudio( projectId: string, chapterId: string, chapterSnapshotId: string, request: ElevenLabs.BodyStreamChapterAudioV1ProjectsProjectIdChaptersChapterIdSnapshotsChapterSnapshotIdStreamPost = {}, requestOptions?: Projects.RequestOptions, ): Promise<void> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/chapters/${encodeURIComponent(chapterId)}/snapshots/${encodeURIComponent(chapterSnapshotId)}/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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, 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( "Timeout exceeded when calling POST /v1/projects/{project_id}/chapters/{chapter_id}/snapshots/{chapter_snapshot_id}/stream.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Stream the audio from a chapter snapshot. Use `GET /v1/projects/{project_id}/chapters/{chapter_id}/snapshots` to return the chapter snapshots of a chapter. * * @param {string} projectId - The ID of the Studio project. * @param {string} chapterId - The ID of the chapter. * @param {string} chapterSnapshotId - The ID of the chapter snapshot. * @param {ElevenLabs.BodyStreamChapterAudioV1ProjectsProjectIdChaptersChapterIdSnapshotsChapterSnapshotIdStreamPost} request * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.streamChapterAudio("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L1581-L1649
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.updatePronunciationDictionaries
public async updatePronunciationDictionaries( projectId: string, request: ElevenLabs.UpdatePronunciationDictionariesRequest, requestOptions?: Projects.RequestOptions, ): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/projects/${encodeURIComponent(projectId)}/update-pronunciation-dictionaries`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, 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( "Timeout exceeded when calling POST /v1/projects/{project_id}/update-pronunciation-dictionaries.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Updates the set of pronunciation dictionaries acting on a project. This will automatically mark text within this project as requiring reconverting where the new dictionary would apply or the old one no longer does. * * @param {string} projectId - The ID of the Studio project. * @param {ElevenLabs.UpdatePronunciationDictionariesRequest} request * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.projects.updatePronunciationDictionaries("21m00Tcm4TlvDq8ikWAM", { * pronunciation_dictionary_locators: [{ * pronunciation_dictionary_id: "pronunciation_dictionary_id", * version_id: "version_id" * }] * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/projects/client/Client.ts#L1668-L1734
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
PronunciationDictionary.addFromFile
public async addFromFile( request: ElevenLabs.BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromFilePost, requestOptions?: PronunciationDictionary.RequestOptions, ): Promise<ElevenLabs.AddPronunciationDictionaryResponseModel> { const _request = await core.newFormData(); _request.append("name", request.name); if (request.file != null) { await _request.appendFile("file", request.file); } if (request.description != null) { _request.append("description", request.description); } if (request.workspace_access != null) { _request.append("workspace_access", request.workspace_access); } const _maybeEncodedRequest = await _request.getRequest(); const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/pronunciation-dictionaries/add-from-file", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ..._maybeEncodedRequest.headers, ...requestOptions?.headers, }, requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.AddPronunciationDictionaryResponseModel; } 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( "Timeout exceeded when calling POST /v1/pronunciation-dictionaries/add-from-file.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Creates a new pronunciation dictionary from a lexicon .PLS file * * @param {ElevenLabs.BodyAddAPronunciationDictionaryV1PronunciationDictionariesAddFromFilePost} request * @param {PronunciationDictionary.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.pronunciationDictionary.addFromFile({ * name: "name" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/pronunciationDictionary/client/Client.ts#L50-L131
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
PronunciationDictionary.addRules
public async addRules( pronunciationDictionaryId: string, request: ElevenLabs.PronunciationDictionary, requestOptions?: PronunciationDictionary.RequestOptions, ): Promise<ElevenLabs.AddPronunciationDictionaryRulesResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/pronunciation-dictionaries/${encodeURIComponent(pronunciationDictionaryId)}/add-rules`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.AddPronunciationDictionaryRulesResponseModel; } 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( "Timeout exceeded when calling POST /v1/pronunciation-dictionaries/{pronunciation_dictionary_id}/add-rules.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Add rules to the pronunciation dictionary * * @param {string} pronunciationDictionaryId - The id of the pronunciation dictionary * @param {ElevenLabs.PronunciationDictionary} request * @param {PronunciationDictionary.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.pronunciationDictionary.addRules("21m00Tcm4TlvDq8ikWAM", { * rules: [{ * type: "alias", * string_to_replace: "string_to_replace", * alias: "alias" * }] * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/pronunciationDictionary/client/Client.ts#L151-L217
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
PronunciationDictionary.removeRules
public async removeRules( pronunciationDictionaryId: string, request: ElevenLabs.BodyRemoveRulesFromThePronunciationDictionaryV1PronunciationDictionariesPronunciationDictionaryIdRemoveRulesPost, requestOptions?: PronunciationDictionary.RequestOptions, ): Promise<ElevenLabs.RemovePronunciationDictionaryRulesResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/pronunciation-dictionaries/${encodeURIComponent(pronunciationDictionaryId)}/remove-rules`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.RemovePronunciationDictionaryRulesResponseModel; } 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( "Timeout exceeded when calling POST /v1/pronunciation-dictionaries/{pronunciation_dictionary_id}/remove-rules.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Remove rules from the pronunciation dictionary * * @param {string} pronunciationDictionaryId - The id of the pronunciation dictionary * @param {ElevenLabs.BodyRemoveRulesFromThePronunciationDictionaryV1PronunciationDictionariesPronunciationDictionaryIdRemoveRulesPost} request * @param {PronunciationDictionary.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.pronunciationDictionary.removeRules("21m00Tcm4TlvDq8ikWAM", { * rule_strings: ["rule_strings"] * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/pronunciationDictionary/client/Client.ts#L233-L299
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
PronunciationDictionary.download
public async download( dictionaryId: string, versionId: string, requestOptions?: PronunciationDictionary.RequestOptions, ): Promise<string> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/pronunciation-dictionaries/${encodeURIComponent(dictionaryId)}/${encodeURIComponent(versionId)}/download`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", responseType: "text", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as string; } 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( "Timeout exceeded when calling GET /v1/pronunciation-dictionaries/{dictionary_id}/{version_id}/download.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Get PLS file with a pronunciation dictionary version rules * * @param {string} dictionaryId - The id of the pronunciation dictionary * @param {string} versionId - The id of the version of the pronunciation dictionary * @param {PronunciationDictionary.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.pronunciationDictionary.download("Fm6AvNgS53NXe6Kqxp3e", "KZFyRUq3R6kaqhKI146w") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/pronunciationDictionary/client/Client.ts#L313-L379
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
PronunciationDictionary.get
public async get( pronunciationDictionaryId: string, requestOptions?: PronunciationDictionary.RequestOptions, ): Promise<ElevenLabs.GetPronunciationDictionaryMetadataResponse> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/pronunciation-dictionaries/${encodeURIComponent(pronunciationDictionaryId)}/`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.GetPronunciationDictionaryMetadataResponse; } 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( "Timeout exceeded when calling GET /v1/pronunciation-dictionaries/{pronunciation_dictionary_id}/.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Get metadata for a pronunciation dictionary * * @param {string} pronunciationDictionaryId - The id of the pronunciation dictionary * @param {PronunciationDictionary.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.pronunciationDictionary.get("Fm6AvNgS53NXe6Kqxp3e") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/pronunciationDictionary/client/Client.ts#L392-L456
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
PronunciationDictionary.getAll
public async getAll( request: ElevenLabs.PronunciationDictionaryGetAllRequest = {}, requestOptions?: PronunciationDictionary.RequestOptions, ): Promise<ElevenLabs.GetPronunciationDictionariesMetadataResponseModel> { const { cursor, page_size: pageSize } = request; const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; if (cursor != null) { _queryParams["cursor"] = cursor; } if (pageSize != null) { _queryParams["page_size"] = pageSize.toString(); } const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/pronunciation-dictionaries/", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", queryParameters: _queryParams, requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.GetPronunciationDictionariesMetadataResponseModel; } 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( "Timeout exceeded when calling GET /v1/pronunciation-dictionaries/.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Get a list of the pronunciation dictionaries you have access to and their metadata * * @param {ElevenLabs.PronunciationDictionaryGetAllRequest} request * @param {PronunciationDictionary.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.pronunciationDictionary.getAll({ * page_size: 1 * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/pronunciationDictionary/client/Client.ts#L471-L546
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Samples.delete
public async delete(voiceId: string, sampleId: string, requestOptions?: Samples.RequestOptions): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/voices/${encodeURIComponent(voiceId)}/samples/${encodeURIComponent(sampleId)}`, ), method: "DELETE", 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", 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( "Timeout exceeded when calling DELETE /v1/voices/{voice_id}/samples/{sample_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Removes a sample by its ID. * * @param {string} voiceId - Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. * @param {string} sampleId - Sample ID to be used, you can use GET https://api.elevenlabs.io/v1/voices/{voice_id} to list all the available samples for a voice. * @param {Samples.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.samples.delete("VOICE_ID", "SAMPLE_ID") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/samples/client/Client.ts#L53-L114
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Samples.getAudio
public async getAudio( voiceId: string, sampleId: string, requestOptions?: Samples.RequestOptions, ): Promise<stream.Readable> { const _response = await core.fetcher<stream.Readable>({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/voices/${encodeURIComponent(voiceId)}/samples/${encodeURIComponent(sampleId)}/audio`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", responseType: "streaming", 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( "Timeout exceeded when calling GET /v1/voices/{voice_id}/samples/{sample_id}/audio.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Returns the audio corresponding to a sample attached to a voice. * @throws {@link ElevenLabs.UnprocessableEntityError} */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/samples/client/Client.ts#L120-L186
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
SpeechToSpeech.convert
public async convert( voiceId: string, request: ElevenLabs.BodySpeechToSpeechV1SpeechToSpeechVoiceIdPost, requestOptions?: SpeechToSpeech.RequestOptions, ): Promise<stream.Readable> { const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; if (request.enable_logging != null) { _queryParams["enable_logging"] = request.enable_logging.toString(); } if (request.optimize_streaming_latency != null) { _queryParams["optimize_streaming_latency"] = request.optimize_streaming_latency.toString(); } if (request.output_format != null) { _queryParams["output_format"] = request.output_format; } const _request = await core.newFormData(); await _request.appendFile("audio", request.audio); if (request.model_id != null) { _request.append("model_id", request.model_id); } if (request.voice_settings != null) { _request.append("voice_settings", request.voice_settings); } if (request.seed != null) { _request.append("seed", request.seed.toString()); } if (request.remove_background_noise != null) { _request.append("remove_background_noise", request.remove_background_noise.toString()); } const _maybeEncodedRequest = await _request.getRequest(); const _response = await core.fetcher<stream.Readable>({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/speech-to-speech/${encodeURIComponent(voiceId)}`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ..._maybeEncodedRequest.headers, ...requestOptions?.headers, }, queryParameters: _queryParams, requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, responseType: "streaming", 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( "Timeout exceeded when calling POST /v1/speech-to-speech/{voice_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Create speech by combining the content and emotion of the uploaded audio with a voice of your choice. * @throws {@link ElevenLabs.UnprocessableEntityError} */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/speechToSpeech/client/Client.ts#L42-L143
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
SpeechToSpeech.convertAsStream
public async convertAsStream( voiceId: string, request: ElevenLabs.BodySpeechToSpeechStreamingV1SpeechToSpeechVoiceIdStreamPost, requestOptions?: SpeechToSpeech.RequestOptions, ): Promise<stream.Readable> { const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; if (request.enable_logging != null) { _queryParams["enable_logging"] = request.enable_logging.toString(); } if (request.optimize_streaming_latency != null) { _queryParams["optimize_streaming_latency"] = request.optimize_streaming_latency.toString(); } if (request.output_format != null) { _queryParams["output_format"] = request.output_format; } const _request = await core.newFormData(); await _request.appendFile("audio", request.audio); if (request.model_id != null) { _request.append("model_id", request.model_id); } if (request.voice_settings != null) { _request.append("voice_settings", request.voice_settings); } if (request.seed != null) { _request.append("seed", request.seed.toString()); } if (request.remove_background_noise != null) { _request.append("remove_background_noise", request.remove_background_noise.toString()); } const _maybeEncodedRequest = await _request.getRequest(); const _response = await core.fetcher<stream.Readable>({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/speech-to-speech/${encodeURIComponent(voiceId)}/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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ..._maybeEncodedRequest.headers, ...requestOptions?.headers, }, queryParameters: _queryParams, requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, responseType: "streaming", 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( "Timeout exceeded when calling POST /v1/speech-to-speech/{voice_id}/stream.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Create speech by combining the content and emotion of the uploaded audio with a voice of your choice and returns an audio stream. * @throws {@link ElevenLabs.UnprocessableEntityError} */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/speechToSpeech/client/Client.ts#L149-L250
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
SpeechToText.convert
public async convert( request: ElevenLabs.BodySpeechToTextV1SpeechToTextPost, requestOptions?: SpeechToText.RequestOptions, ): Promise<ElevenLabs.SpeechToTextChunkResponseModel> { const _request = await core.newFormData(); _request.append("model_id", request.model_id); if (request.file != null) { await _request.appendFile("file", request.file); } if (request.language_code != null) { _request.append("language_code", request.language_code); } if (request.tag_audio_events != null) { _request.append("tag_audio_events", request.tag_audio_events.toString()); } if (request.num_speakers != null) { _request.append("num_speakers", request.num_speakers.toString()); } const _maybeEncodedRequest = await _request.getRequest(); const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/speech-to-text", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ..._maybeEncodedRequest.headers, ...requestOptions?.headers, }, requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.SpeechToTextChunkResponseModel; } 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("Timeout exceeded when calling POST /v1/speech-to-text."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Transcribe an audio or video file. * * @param {ElevenLabs.BodySpeechToTextV1SpeechToTextPost} request * @param {SpeechToText.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.speechToText.convert({ * model_id: "model_id" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/speechToText/client/Client.ts#L51-L134
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
SpeechToText.convertAsStream
public async convertAsStream( request: ElevenLabs.BodySpeechToTextStreamV1SpeechToTextStreamPost, requestOptions?: SpeechToText.RequestOptions, ): Promise<core.Stream<ElevenLabs.SpeechToTextStreamResponseModel>> { const _request = await core.newFormData(); _request.append("model_id", request.model_id); if (request.file != null) { await _request.appendFile("file", request.file); } if (request.language_code != null) { _request.append("language_code", request.language_code); } if (request.tag_audio_events != null) { _request.append("tag_audio_events", request.tag_audio_events.toString()); } if (request.num_speakers != null) { _request.append("num_speakers", request.num_speakers.toString()); } const _maybeEncodedRequest = await _request.getRequest(); const _response = await core.fetcher<stream.Readable>({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/speech-to-text/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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ..._maybeEncodedRequest.headers, ...requestOptions?.headers, }, requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, responseType: "sse", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return new core.Stream({ stream: _response.body, parse: (data) => data as any, signal: requestOptions?.abortSignal, eventShape: { type: "json", messageTerminator: "\n", }, }); } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: throw new ElevenLabs.BadRequestError(_response.error.body as unknown); 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( "Timeout exceeded when calling POST /v1/speech-to-text/stream.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Transcribe an audio or video file with streaming response. Returns chunks of transcription as they become available, with each chunk separated by double newlines (\n\n). */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/speechToText/client/Client.ts#L139-L235
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Studio.createPodcast
public async createPodcast( request: ElevenLabs.BodyCreatePodcastV1StudioPodcastsPost, requestOptions?: Studio.RequestOptions, ): Promise<ElevenLabs.PodcastProjectResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/studio/podcasts", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.PodcastProjectResponseModel; } 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("Timeout exceeded when calling POST /v1/studio/podcasts."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Create and auto-convert a podcast project. Currently, the LLM cost is covered by us but you will still be charged for the audio generation. In the future, you will be charged for both the LLM and audio generation costs. * * @param {ElevenLabs.BodyCreatePodcastV1StudioPodcastsPost} request * @param {Studio.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.createPodcast({ * model_id: "model_id", * mode: { * type: "conversation", * conversation: { * host_voice_id: "host_voice_id", * guest_voice_id: "guest_voice_id" * } * }, * source: { * text: "text" * } * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/client/Client.ts#L73-L136
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Chapters.getAll
public async getAll( projectId: string, requestOptions?: Chapters.RequestOptions, ): Promise<ElevenLabs.GetChaptersResponse> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/chapters`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.GetChaptersResponse; } 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( "Timeout exceeded when calling GET /v1/studio/projects/{project_id}/chapters.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Returns a list of a Studio project's chapters. * * @param {string} projectId - The ID of the Studio project. * @param {Chapters.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.chapters.getAll("21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/chapters/client/Client.ts#L48-L112
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Chapters.create
public async create( projectId: string, request: ElevenLabs.studio.BodyCreateChapterV1StudioProjectsProjectIdChaptersPost, requestOptions?: Chapters.RequestOptions, ): Promise<ElevenLabs.AddChapterResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/chapters`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.AddChapterResponseModel; } 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( "Timeout exceeded when calling POST /v1/studio/projects/{project_id}/chapters.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Creates a new chapter either as blank or from a URL. * * @param {string} projectId - The ID of the Studio project. * @param {ElevenLabs.studio.BodyCreateChapterV1StudioProjectsProjectIdChaptersPost} request * @param {Chapters.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.chapters.create("21m00Tcm4TlvDq8ikWAM", { * name: "name" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/chapters/client/Client.ts#L128-L194
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Chapters.get
public async get( projectId: string, chapterId: string, requestOptions?: Chapters.RequestOptions, ): Promise<ElevenLabs.ChapterWithContentResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/chapters/${encodeURIComponent(chapterId)}`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.ChapterWithContentResponseModel; } 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( "Timeout exceeded when calling GET /v1/studio/projects/{project_id}/chapters/{chapter_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Returns information about a specific chapter. * * @param {string} projectId - The ID of the Studio project. * @param {string} chapterId - The ID of the chapter. * @param {Chapters.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.chapters.get("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/chapters/client/Client.ts#L208-L273
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Chapters.edit
public async edit( projectId: string, chapterId: string, request: ElevenLabs.studio.BodyUpdateChapterV1StudioProjectsProjectIdChaptersChapterIdPost = {}, requestOptions?: Chapters.RequestOptions, ): Promise<ElevenLabs.EditChapterResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/chapters/${encodeURIComponent(chapterId)}`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.EditChapterResponseModel; } 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( "Timeout exceeded when calling POST /v1/studio/projects/{project_id}/chapters/{chapter_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Updates a chapter. * * @param {string} projectId - The ID of the Studio project. * @param {string} chapterId - The ID of the chapter. * @param {ElevenLabs.studio.BodyUpdateChapterV1StudioProjectsProjectIdChaptersChapterIdPost} request * @param {Chapters.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.chapters.edit("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/chapters/client/Client.ts#L288-L355
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Chapters.delete
public async delete( projectId: string, chapterId: string, requestOptions?: Chapters.RequestOptions, ): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/chapters/${encodeURIComponent(chapterId)}`, ), method: "DELETE", 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", 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( "Timeout exceeded when calling DELETE /v1/studio/projects/{project_id}/chapters/{chapter_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Deletes a chapter. * * @param {string} projectId - The ID of the Studio project. * @param {string} chapterId - The ID of the chapter. * @param {Chapters.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.chapters.delete("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/chapters/client/Client.ts#L369-L434
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Chapters.convert
public async convert( projectId: string, chapterId: string, requestOptions?: Chapters.RequestOptions, ): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/chapters/${encodeURIComponent(chapterId)}/convert`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", 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( "Timeout exceeded when calling POST /v1/studio/projects/{project_id}/chapters/{chapter_id}/convert.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Starts conversion of a specific chapter. * * @param {string} projectId - The ID of the Studio project. * @param {string} chapterId - The ID of the chapter. * @param {Chapters.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.chapters.convert("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/chapters/client/Client.ts#L448-L513
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Chapters.getAllSnapshots
public async getAllSnapshots( projectId: string, chapterId: string, requestOptions?: Chapters.RequestOptions, ): Promise<ElevenLabs.ChapterSnapshotsResponse> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/chapters/${encodeURIComponent(chapterId)}/snapshots`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.ChapterSnapshotsResponse; } 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( "Timeout exceeded when calling GET /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Gets information about all the snapshots of a chapter, each snapshot corresponds can be downloaded as audio. Whenever a chapter is converted a snapshot will be automatically created. * * @param {string} projectId - The ID of the Studio project. * @param {string} chapterId - The ID of the chapter. * @param {Chapters.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.chapters.getAllSnapshots("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/chapters/client/Client.ts#L527-L592
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Chapters.streamSnapshot
public async streamSnapshot( projectId: string, chapterId: string, chapterSnapshotId: string, request: ElevenLabs.studio.BodyStreamChapterAudioV1StudioProjectsProjectIdChaptersChapterIdSnapshotsChapterSnapshotIdStreamPost = {}, requestOptions?: Chapters.RequestOptions, ): Promise<void> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/chapters/${encodeURIComponent(chapterId)}/snapshots/${encodeURIComponent(chapterSnapshotId)}/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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, 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( "Timeout exceeded when calling POST /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots/{chapter_snapshot_id}/stream.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Stream the audio from a chapter snapshot. Use `GET /v1/studio/projects/{project_id}/chapters/{chapter_id}/snapshots` to return the snapshots of a chapter. * * @param {string} projectId - The ID of the Studio project. * @param {string} chapterId - The ID of the chapter. * @param {string} chapterSnapshotId - The ID of the chapter snapshot. * @param {ElevenLabs.studio.BodyStreamChapterAudioV1StudioProjectsProjectIdChaptersChapterIdSnapshotsChapterSnapshotIdStreamPost} request * @param {Chapters.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.chapters.streamSnapshot("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/chapters/client/Client.ts#L608-L676
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.getAll
public async getAll(requestOptions?: Projects.RequestOptions): Promise<ElevenLabs.GetProjectsResponse> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/studio/projects", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.GetProjectsResponse; } 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("Timeout exceeded when calling GET /v1/studio/projects."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Returns a list of your Studio projects with metadata. * * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.projects.getAll() */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/projects/client/Client.ts#L47-L106
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.add
public async add( request: ElevenLabs.studio.BodyCreateStudioProjectV1StudioProjectsPost, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.AddProjectResponseModel> { const _request = await core.newFormData(); _request.append("name", request.name); _request.append("default_title_voice_id", request.default_title_voice_id); _request.append("default_paragraph_voice_id", request.default_paragraph_voice_id); _request.append("default_model_id", request.default_model_id); if (request.from_url != null) { _request.append("from_url", request.from_url); } if (request.from_document != null) { await _request.appendFile("from_document", request.from_document); } if (request.quality_preset != null) { _request.append("quality_preset", request.quality_preset); } if (request.title != null) { _request.append("title", request.title); } if (request.author != null) { _request.append("author", request.author); } if (request.description != null) { _request.append("description", request.description); } if (request.genres != null) { for (const _item of request.genres) { _request.append("genres", _item); } } if (request.target_audience != null) { _request.append("target_audience", request.target_audience); } if (request.language != null) { _request.append("language", request.language); } if (request.content_type != null) { _request.append("content_type", request.content_type); } if (request.original_publication_date != null) { _request.append("original_publication_date", request.original_publication_date); } if (request.mature_content != null) { _request.append("mature_content", request.mature_content.toString()); } if (request.isbn_number != null) { _request.append("isbn_number", request.isbn_number); } if (request.acx_volume_normalization != null) { _request.append("acx_volume_normalization", request.acx_volume_normalization.toString()); } if (request.volume_normalization != null) { _request.append("volume_normalization", request.volume_normalization.toString()); } if (request.pronunciation_dictionary_locators != null) { for (const _item of request.pronunciation_dictionary_locators) { _request.append("pronunciation_dictionary_locators", _item); } } if (request.callback_url != null) { _request.append("callback_url", request.callback_url); } if (request.fiction != null) { _request.append("fiction", request.fiction); } if (request.quality_check_on != null) { _request.append("quality_check_on", request.quality_check_on.toString()); } if (request.apply_text_normalization != null) { _request.append("apply_text_normalization", request.apply_text_normalization); } if (request.auto_convert != null) { _request.append("auto_convert", request.auto_convert.toString()); } if (request.auto_assign_voices != null) { _request.append("auto_assign_voices", request.auto_assign_voices.toString()); } const _maybeEncodedRequest = await _request.getRequest(); const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/studio/projects", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ..._maybeEncodedRequest.headers, ...requestOptions?.headers, }, requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.AddProjectResponseModel; } 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("Timeout exceeded when calling POST /v1/studio/projects."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Creates a new Studio project, it can be either initialized as blank, from a document or from a URL. * * @param {ElevenLabs.studio.BodyCreateStudioProjectV1StudioProjectsPost} request * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.projects.add({ * name: "name", * default_title_voice_id: "default_title_voice_id", * default_paragraph_voice_id: "default_paragraph_voice_id", * default_model_id: "default_model_id" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/projects/client/Client.ts#L124-L286
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.get
public async get( projectId: string, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.ProjectExtendedResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.ProjectExtendedResponseModel; } 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( "Timeout exceeded when calling GET /v1/studio/projects/{project_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Returns information about a specific Studio project. This endpoint returns more detailed information about a project than `GET /v1/studio`. * * @param {string} projectId - The ID of the Studio project. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.projects.get("21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/projects/client/Client.ts#L299-L363
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.updateMetadata
public async updateMetadata( projectId: string, request: ElevenLabs.studio.BodyUpdateStudioProjectMetadataV1StudioProjectsProjectIdPost, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.EditProjectResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.EditProjectResponseModel; } 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( "Timeout exceeded when calling POST /v1/studio/projects/{project_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Updates Studio project metadata. * * @param {string} projectId - The ID of the Studio project. * @param {ElevenLabs.studio.BodyUpdateStudioProjectMetadataV1StudioProjectsProjectIdPost} request * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.projects.updateMetadata("21m00Tcm4TlvDq8ikWAM", { * name: "name", * default_title_voice_id: "default_title_voice_id", * default_paragraph_voice_id: "default_paragraph_voice_id" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/projects/client/Client.ts#L381-L447
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.delete
public async delete(projectId: string, requestOptions?: Projects.RequestOptions): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}`, ), method: "DELETE", 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", 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( "Timeout exceeded when calling DELETE /v1/studio/projects/{project_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Deletes a Studio project. * * @param {string} projectId - The ID of the Studio project. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.projects.delete("21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/projects/client/Client.ts#L460-L521
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.updateContent
public async updateContent( projectId: string, request: ElevenLabs.studio.BodyUpdateStudioProjectContentV1StudioProjectsProjectIdContentPost, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.EditProjectResponseModel> { const _request = await core.newFormData(); if (request.from_url != null) { _request.append("from_url", request.from_url); } if (request.from_document != null) { await _request.appendFile("from_document", request.from_document); } if (request.auto_convert != null) { _request.append("auto_convert", request.auto_convert.toString()); } const _maybeEncodedRequest = await _request.getRequest(); const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/content`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ..._maybeEncodedRequest.headers, ...requestOptions?.headers, }, requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.EditProjectResponseModel; } 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( "Timeout exceeded when calling POST /v1/studio/projects/{project_id}/content.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Updates Studio project content. * * @param {string} projectId * @param {ElevenLabs.studio.BodyUpdateStudioProjectContentV1StudioProjectsProjectIdContentPost} request * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.projects.updateContent("21m00Tcm4TlvDq8ikWAM", {}) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/projects/client/Client.ts#L535-L616
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.convert
public async convert(projectId: string, requestOptions?: Projects.RequestOptions): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/convert`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", 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( "Timeout exceeded when calling POST /v1/studio/projects/{project_id}/convert.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Starts conversion of a Studio project and all of its chapters. * * @param {string} projectId - The ID of the Studio project. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.projects.convert("21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/projects/client/Client.ts#L629-L690
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.getSnapshots
public async getSnapshots( projectId: string, requestOptions?: Projects.RequestOptions, ): Promise<ElevenLabs.ProjectSnapshotsResponse> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/snapshots`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.ProjectSnapshotsResponse; } 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( "Timeout exceeded when calling GET /v1/studio/projects/{project_id}/snapshots.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Gets the snapshots of a Studio project. * * @param {string} projectId - The ID of the Studio project. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.projects.getSnapshots("21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/projects/client/Client.ts#L703-L767
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.streamAudio
public async streamAudio( projectId: string, projectSnapshotId: string, request: ElevenLabs.studio.BodyStreamStudioProjectAudioV1StudioProjectsProjectIdSnapshotsProjectSnapshotIdStreamPost = {}, requestOptions?: Projects.RequestOptions, ): Promise<void> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/snapshots/${encodeURIComponent(projectSnapshotId)}/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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, 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( "Timeout exceeded when calling POST /v1/studio/projects/{project_id}/snapshots/{project_snapshot_id}/stream.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Stream the audio from a Studio project snapshot. * * @param {string} projectId - The ID of the Studio project. * @param {string} projectSnapshotId - The ID of the Studio project snapshot. * @param {ElevenLabs.studio.BodyStreamStudioProjectAudioV1StudioProjectsProjectIdSnapshotsProjectSnapshotIdStreamPost} request * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.projects.streamAudio("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/projects/client/Client.ts#L782-L849
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.streamArchive
public async streamArchive( projectId: string, projectSnapshotId: string, requestOptions?: Projects.RequestOptions, ): Promise<void> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/snapshots/${encodeURIComponent(projectSnapshotId)}/archive`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", 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( "Timeout exceeded when calling POST /v1/studio/projects/{project_id}/snapshots/{project_snapshot_id}/archive.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Returns a compressed archive of the Studio project's audio. * * @param {string} projectId - The ID of the Studio project. * @param {string} projectSnapshotId - The ID of the Studio project snapshot. * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.projects.streamArchive("21m00Tcm4TlvDq8ikWAM", "21m00Tcm4TlvDq8ikWAM") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/projects/client/Client.ts#L863-L928
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Projects.updatePronunciationDictionaries
public async updatePronunciationDictionaries( projectId: string, request: ElevenLabs.studio.BodyCreatePronunciationDictionariesV1StudioProjectsProjectIdPronunciationDictionariesPost, requestOptions?: Projects.RequestOptions, ): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/studio/projects/${encodeURIComponent(projectId)}/pronunciation-dictionaries`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, 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( "Timeout exceeded when calling POST /v1/studio/projects/{project_id}/pronunciation-dictionaries.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Create a set of pronunciation dictionaries acting on a project. This will automatically mark text within this project as requiring reconverting where the new dictionary would apply or the old one no longer does. * * @param {string} projectId - The ID of the Studio project. * @param {ElevenLabs.studio.BodyCreatePronunciationDictionariesV1StudioProjectsProjectIdPronunciationDictionariesPost} request * @param {Projects.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.studio.projects.updatePronunciationDictionaries("21m00Tcm4TlvDq8ikWAM", { * pronunciation_dictionary_locators: [{ * pronunciation_dictionary_id: "pronunciation_dictionary_id", * version_id: "version_id" * }] * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/studio/resources/projects/client/Client.ts#L947-L1013
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
TextToSoundEffects.convert
public async convert( request: ElevenLabs.BodySoundGenerationV1SoundGenerationPost, requestOptions?: TextToSoundEffects.RequestOptions, ): Promise<stream.Readable> { const _response = await core.fetcher<stream.Readable>({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/sound-generation", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, responseType: "streaming", 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("Timeout exceeded when calling POST /v1/sound-generation."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Converts a text of your choice into sound * @throws {@link ElevenLabs.UnprocessableEntityError} */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/textToSoundEffects/client/Client.ts#L42-L106
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
TextToSpeech.convert
public async convert( voiceId: string, request: ElevenLabs.TextToSpeechRequest, requestOptions?: TextToSpeech.RequestOptions, ): Promise<stream.Readable> { const { enable_logging: enableLogging, optimize_streaming_latency: optimizeStreamingLatency, output_format: outputFormat, ..._body } = request; const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; if (enableLogging != null) { _queryParams["enable_logging"] = enableLogging.toString(); } if (optimizeStreamingLatency != null) { _queryParams["optimize_streaming_latency"] = optimizeStreamingLatency.toString(); } if (outputFormat != null) { _queryParams["output_format"] = outputFormat; } const _response = await core.fetcher<stream.Readable>({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/text-to-speech/${encodeURIComponent(voiceId)}`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", queryParameters: _queryParams, requestType: "json", body: _body, responseType: "streaming", 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( "Timeout exceeded when calling POST /v1/text-to-speech/{voice_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Converts text into speech using a voice of your choice and returns audio. * @throws {@link ElevenLabs.UnprocessableEntityError} */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/textToSpeech/client/Client.ts#L42-L129
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
TextToSpeech.convertWithTimestamps
public async convertWithTimestamps( voiceId: string, request: ElevenLabs.TextToSpeechWithTimestampsRequest, requestOptions?: TextToSpeech.RequestOptions, ): Promise<unknown> { const { enable_logging: enableLogging, optimize_streaming_latency: optimizeStreamingLatency, output_format: outputFormat, ..._body } = request; const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; if (enableLogging != null) { _queryParams["enable_logging"] = enableLogging.toString(); } if (optimizeStreamingLatency != null) { _queryParams["optimize_streaming_latency"] = optimizeStreamingLatency.toString(); } if (outputFormat != null) { _queryParams["output_format"] = outputFormat; } const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/text-to-speech/${encodeURIComponent(voiceId)}/with-timestamps`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", queryParameters: _queryParams, requestType: "json", body: _body, 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( "Timeout exceeded when calling POST /v1/text-to-speech/{voice_id}/with-timestamps.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Converts text into speech using a voice of your choice and returns JSON containing audio as a base64 encoded string together with information on when which character was spoken. * * @param {string} voiceId - Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. * @param {ElevenLabs.TextToSpeechWithTimestampsRequest} request * @param {TextToSpeech.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.textToSpeech.convertWithTimestamps("JBFqnCBsd6RMkjVDRZzb", { * output_format: "mp3_44100_128", * text: "The first move is what sets everything in motion.", * model_id: "eleven_multilingual_v2" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/textToSpeech/client/Client.ts#L147-L233
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
TextToSpeech.convertAsStream
public async convertAsStream( voiceId: string, request: ElevenLabs.StreamTextToSpeechRequest, requestOptions?: TextToSpeech.RequestOptions, ): Promise<stream.Readable> { const { enable_logging: enableLogging, optimize_streaming_latency: optimizeStreamingLatency, output_format: outputFormat, ..._body } = request; const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; if (enableLogging != null) { _queryParams["enable_logging"] = enableLogging.toString(); } if (optimizeStreamingLatency != null) { _queryParams["optimize_streaming_latency"] = optimizeStreamingLatency.toString(); } if (outputFormat != null) { _queryParams["output_format"] = outputFormat; } const _response = await core.fetcher<stream.Readable>({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/text-to-speech/${encodeURIComponent(voiceId)}/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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", queryParameters: _queryParams, requestType: "json", body: _body, responseType: "streaming", 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( "Timeout exceeded when calling POST /v1/text-to-speech/{voice_id}/stream.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Converts text into speech using a voice of your choice and returns audio as an audio stream. * @throws {@link ElevenLabs.UnprocessableEntityError} */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/textToSpeech/client/Client.ts#L239-L326
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
TextToSpeech.streamWithTimestamps
public async streamWithTimestamps( voiceId: string, request: ElevenLabs.StreamTextToSpeechWithTimstampsRequest, requestOptions?: TextToSpeech.RequestOptions, ): Promise<core.Stream<ElevenLabs.TextToSpeechStreamWithTimestampsResponse>> { const { enable_logging: enableLogging, optimize_streaming_latency: optimizeStreamingLatency, output_format: outputFormat, ..._body } = request; const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; if (enableLogging != null) { _queryParams["enable_logging"] = enableLogging.toString(); } if (optimizeStreamingLatency != null) { _queryParams["optimize_streaming_latency"] = optimizeStreamingLatency.toString(); } if (outputFormat != null) { _queryParams["output_format"] = outputFormat; } const _response = await core.fetcher<stream.Readable>({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/text-to-speech/${encodeURIComponent(voiceId)}/stream/with-timestamps`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", queryParameters: _queryParams, requestType: "json", body: _body, responseType: "sse", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return new core.Stream({ stream: _response.body, parse: (data) => data as any, signal: requestOptions?.abortSignal, eventShape: { type: "json", messageTerminator: "\n", }, }); } 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( "Timeout exceeded when calling POST /v1/text-to-speech/{voice_id}/stream/with-timestamps.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Converts text into speech using a voice of your choice and returns a stream of JSONs containing audio as a base64 encoded string together with information on when which character was spoken. */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/textToSpeech/client/Client.ts#L331-L426
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
TextToVoice.createPreviews
public async createPreviews( request: ElevenLabs.VoicePreviewsRequestModel, requestOptions?: TextToVoice.RequestOptions, ): Promise<ElevenLabs.VoicePreviewsResponseModel> { const { output_format: outputFormat, ..._body } = request; const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; if (outputFormat != null) { _queryParams["output_format"] = outputFormat; } const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/text-to-voice/create-previews", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", queryParameters: _queryParams, requestType: "json", body: _body, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.VoicePreviewsResponseModel; } 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( "Timeout exceeded when calling POST /v1/text-to-voice/create-previews.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Generate a custom voice based on voice description. This method returns a list of voice previews. Each preview has a generated_voice_id and a sample of the voice as base64 encoded mp3 audio. If you like the a voice previewand want to create the voice call /v1/text-to-voice/create-voice-from-preview with the generated_voice_id to create the voice. * * @param {ElevenLabs.VoicePreviewsRequestModel} request * @param {TextToVoice.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.textToVoice.createPreviews({ * voice_description: "A sassy little squeaky mouse", * text: "Every act of kindness, no matter how small, carries value and can make a difference, as no gesture of goodwill is ever wasted." * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/textToVoice/client/Client.ts#L51-L123
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
TextToVoice.createVoiceFromPreview
public async createVoiceFromPreview( request: ElevenLabs.BodyCreateANewVoiceFromVoicePreviewV1TextToVoiceCreateVoiceFromPreviewPost, requestOptions?: TextToVoice.RequestOptions, ): Promise<ElevenLabs.Voice> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/text-to-voice/create-voice-from-preview", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.Voice; } 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( "Timeout exceeded when calling POST /v1/text-to-voice/create-voice-from-preview.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Create a voice from previously generated voice preview. This endpoint should be called after you fetched a generated_voice_id using /v1/text-to-voice/create-previews. * * @param {ElevenLabs.BodyCreateANewVoiceFromVoicePreviewV1TextToVoiceCreateVoiceFromPreviewPost} request * @param {TextToVoice.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.textToVoice.createVoiceFromPreview({ * voice_name: "Little squeaky mouse", * voice_description: "A sassy little squeaky mouse", * generated_voice_id: "37HceQefKmEi3bGovXjL" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/textToVoice/client/Client.ts#L140-L205
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Usage.getCharactersUsageMetrics
public async getCharactersUsageMetrics( request: ElevenLabs.UsageGetCharactersUsageMetricsRequest, requestOptions?: Usage.RequestOptions, ): Promise<ElevenLabs.UsageCharactersResponseModel> { const { start_unix: startUnix, end_unix: endUnix, include_workspace_metrics: includeWorkspaceMetrics, breakdown_type: breakdownType, } = request; const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; _queryParams["start_unix"] = startUnix.toString(); _queryParams["end_unix"] = endUnix.toString(); if (includeWorkspaceMetrics != null) { _queryParams["include_workspace_metrics"] = includeWorkspaceMetrics.toString(); } if (breakdownType != null) { _queryParams["breakdown_type"] = breakdownType; } const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/usage/character-stats", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", queryParameters: _queryParams, requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.UsageCharactersResponseModel; } 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("Timeout exceeded when calling GET /v1/usage/character-stats."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Returns the credit usage metrics for the current user or the entire workspace they are part of. The response will return a time axis with unix timestamps for each day and daily usage along that axis. The usage will be broken down by the specified breakdown type. For example, breakdown type "voice" will return the usage of each voice along the time axis. * * @param {ElevenLabs.UsageGetCharactersUsageMetricsRequest} request * @param {Usage.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.usage.getCharactersUsageMetrics({ * start_unix: 1, * end_unix: 1 * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/usage/client/Client.ts#L51-L131
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
User.getSubscription
public async getSubscription(requestOptions?: User.RequestOptions): Promise<ElevenLabs.Subscription> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/user/subscription", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.Subscription; } 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("Timeout exceeded when calling GET /v1/user/subscription."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Gets extended information about the users subscription * * @param {User.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.user.getSubscription() */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/user/client/Client.ts#L47-L106
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
User.get
public async get(requestOptions?: User.RequestOptions): Promise<ElevenLabs.User> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/user", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.User; } 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("Timeout exceeded when calling GET /v1/user."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Gets information about the user * * @param {User.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.user.get() */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/user/client/Client.ts#L118-L177
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
VoiceGeneration.generateParameters
public async generateParameters( requestOptions?: VoiceGeneration.RequestOptions, ): Promise<ElevenLabs.VoiceGenerationParameterResponse> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/voice-generation/generate-voice/parameters", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.VoiceGenerationParameterResponse; } if (_response.error.reason === "status-code") { 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( "Timeout exceeded when calling GET /v1/voice-generation/generate-voice/parameters.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Get possible parameters for the /v1/voice-generation/generate-voice endpoint. * * @param {VoiceGeneration.RequestOptions} requestOptions - Request-specific configuration. * * @example * await client.voiceGeneration.generateParameters() */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voiceGeneration/client/Client.ts#L46-L102
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
VoiceGeneration.generate
public async generate( request: ElevenLabs.GenerateVoiceRequest, requestOptions?: VoiceGeneration.RequestOptions, ): Promise<stream.Readable> { const _response = await core.fetcher<stream.Readable>({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/voice-generation/generate-voice", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, responseType: "streaming", 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( "Timeout exceeded when calling POST /v1/voice-generation/generate-voice.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Generate a random voice based on parameters. This method returns a generated_voice_id in the response header, and a sample of the voice in the body. If you like the generated voice call /v1/voice-generation/create-voice with the generated_voice_id to create the voice. * @throws {@link ElevenLabs.UnprocessableEntityError} */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voiceGeneration/client/Client.ts#L108-L174
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
VoiceGeneration.createAPreviouslyGeneratedVoice
public async createAPreviouslyGeneratedVoice( request: ElevenLabs.CreatePreviouslyGenertedVoiceRequest, requestOptions?: VoiceGeneration.RequestOptions, ): Promise<ElevenLabs.Voice> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/voice-generation/create-voice", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.Voice; } 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( "Timeout exceeded when calling POST /v1/voice-generation/create-voice.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Create a previously generated voice. This endpoint should be called after you fetched a generated_voice_id using /v1/voice-generation/generate-voice. * * @param {ElevenLabs.CreatePreviouslyGenertedVoiceRequest} request * @param {VoiceGeneration.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.voiceGeneration.createAPreviouslyGeneratedVoice({ * voice_name: "Alex", * voice_description: "Middle-aged American woman", * generated_voice_id: "rbVJFu6SGRD1dbWpKnWl" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voiceGeneration/client/Client.ts#L191-L256
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Voices.getAll
public async getAll( request: ElevenLabs.VoicesGetAllRequest = {}, requestOptions?: Voices.RequestOptions, ): Promise<ElevenLabs.GetVoicesResponse> { const { show_legacy: showLegacy } = request; const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; if (showLegacy != null) { _queryParams["show_legacy"] = showLegacy.toString(); } const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/voices", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", queryParameters: _queryParams, requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.GetVoicesResponse; } 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("Timeout exceeded when calling GET /v1/voices."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Gets a list of all available voices for a user. * * @param {ElevenLabs.VoicesGetAllRequest} request * @param {Voices.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.voices.getAll() */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voices/client/Client.ts#L52-L121
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Voices.getDefaultSettings
public async getDefaultSettings(requestOptions?: Voices.RequestOptions): Promise<ElevenLabs.VoiceSettings> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/voices/settings/default", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.VoiceSettings; } if (_response.error.reason === "status-code") { 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( "Timeout exceeded when calling GET /v1/voices/settings/default.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Gets the default settings for voices. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. * * @param {Voices.RequestOptions} requestOptions - Request-specific configuration. * * @example * await client.voices.getDefaultSettings() */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voices/client/Client.ts#L131-L185
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Voices.getSettings
public async getSettings( voiceId: string, requestOptions?: Voices.RequestOptions, ): Promise<ElevenLabs.VoiceSettings> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/voices/${encodeURIComponent(voiceId)}/settings`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.VoiceSettings; } 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( "Timeout exceeded when calling GET /v1/voices/{voice_id}/settings.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Returns the settings for a specific voice. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. * * @param {string} voiceId - Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. * @param {Voices.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.voices.getSettings("JBFqnCBsd6RMkjVDRZzb") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voices/client/Client.ts#L198-L262
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Voices.get
public async get( voiceId: string, request: ElevenLabs.VoicesGetRequest = {}, requestOptions?: Voices.RequestOptions, ): Promise<ElevenLabs.Voice> { const { with_settings: withSettings } = request; const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; if (withSettings != null) { _queryParams["with_settings"] = withSettings.toString(); } const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/voices/${encodeURIComponent(voiceId)}`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", queryParameters: _queryParams, requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.Voice; } 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("Timeout exceeded when calling GET /v1/voices/{voice_id}."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Returns metadata about a specific voice. * * @param {string} voiceId - Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. * @param {ElevenLabs.VoicesGetRequest} request * @param {Voices.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.voices.get("JBFqnCBsd6RMkjVDRZzb") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voices/client/Client.ts#L276-L346
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Voices.delete
public async delete(voiceId: string, requestOptions?: Voices.RequestOptions): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/voices/${encodeURIComponent(voiceId)}`, ), method: "DELETE", 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", 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("Timeout exceeded when calling DELETE /v1/voices/{voice_id}."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Deletes a voice by its ID. * * @param {string} voiceId - Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. * @param {Voices.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.voices.delete("VOICE_ID") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voices/client/Client.ts#L359-L418
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Voices.editSettings
public async editSettings( voiceId: string, request: ElevenLabs.VoiceSettings, requestOptions?: Voices.RequestOptions, ): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/voices/${encodeURIComponent(voiceId)}/settings/edit`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, 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( "Timeout exceeded when calling POST /v1/voices/{voice_id}/settings/edit.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Edit your settings for a specific voice. "similarity_boost" corresponds to"Clarity + Similarity Enhancement" in the web app and "stability" corresponds to "Stability" slider in the web app. * * @param {string} voiceId - Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. * @param {ElevenLabs.VoiceSettings} request * @param {Voices.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.voices.editSettings("VOICE_ID", { * stability: 0.1, * similarity_boost: 0.3, * style: 0.2 * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voices/client/Client.ts#L436-L502
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Voices.add
public async add( request: ElevenLabs.BodyAddVoiceV1VoicesAddPost, requestOptions?: Voices.RequestOptions, ): Promise<ElevenLabs.AddVoiceIvcResponseModel> { const _request = await core.newFormData(); _request.append("name", request.name); for (const _file of request.files) { await _request.appendFile("files", _file); } if (request.remove_background_noise != null) { _request.append("remove_background_noise", request.remove_background_noise.toString()); } if (request.description != null) { _request.append("description", request.description); } if (request.labels != null) { _request.append("labels", request.labels); } const _maybeEncodedRequest = await _request.getRequest(); const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/voices/add", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ..._maybeEncodedRequest.headers, ...requestOptions?.headers, }, requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.AddVoiceIvcResponseModel; } 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("Timeout exceeded when calling POST /v1/voices/add."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Add a new voice to your collection of voices in VoiceLab. * * @param {ElevenLabs.BodyAddVoiceV1VoicesAddPost} request * @param {Voices.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.voices.add({ * files: [fs.createReadStream("/path/to/your/file")], * name: "Alex" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voices/client/Client.ts#L518-L601
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Voices.edit
public async edit( voiceId: string, request: ElevenLabs.BodyEditVoiceV1VoicesVoiceIdEditPost, requestOptions?: Voices.RequestOptions, ): Promise<unknown> { const _request = await core.newFormData(); _request.append("name", request.name); if (request.files != null) { for (const _file of request.files) { await _request.appendFile("files", _file); } } if (request.remove_background_noise != null) { _request.append("remove_background_noise", request.remove_background_noise.toString()); } if (request.description != null) { _request.append("description", request.description); } if (request.labels != null) { _request.append("labels", request.labels); } const _maybeEncodedRequest = await _request.getRequest(); const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/voices/${encodeURIComponent(voiceId)}/edit`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ..._maybeEncodedRequest.headers, ...requestOptions?.headers, }, requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, 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( "Timeout exceeded when calling POST /v1/voices/{voice_id}/edit.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Edit a voice created by you. * * @param {string} voiceId * @param {ElevenLabs.BodyEditVoiceV1VoicesVoiceIdEditPost} request * @param {Voices.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.voices.edit("VOICE_ID", { * name: "George" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voices/client/Client.ts#L617-L705
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Voices.addSharingVoice
public async addSharingVoice( publicUserId: string, voiceId: string, request: ElevenLabs.AddSharingVoiceRequest, requestOptions?: Voices.RequestOptions, ): Promise<ElevenLabs.AddVoiceResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/voices/add/${encodeURIComponent(publicUserId)}/${encodeURIComponent(voiceId)}`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.AddVoiceResponseModel; } 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( "Timeout exceeded when calling POST /v1/voices/add/{public_user_id}/{voice_id}.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Add a sharing voice to your collection of voices in VoiceLab. * * @param {string} publicUserId - Public user ID used to publicly identify ElevenLabs users. * @param {string} voiceId - Voice ID to be used, you can use https://api.elevenlabs.io/v1/voices to list all the available voices. * @param {ElevenLabs.AddSharingVoiceRequest} request * @param {Voices.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.voices.addSharingVoice("63e84100a6bf7874ba37a1bab9a31828a379ec94b891b401653b655c5110880f", "sB1b5zUrxQVAFl2PhZFp", { * new_name: "Alita" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voices/client/Client.ts#L722-L789
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Voices.getShared
public async getShared( request: ElevenLabs.VoicesGetSharedRequest = {}, requestOptions?: Voices.RequestOptions, ): Promise<ElevenLabs.GetLibraryVoicesResponse> { const { page_size: pageSize, category, gender, age, accent, language, search, use_cases: useCases, descriptives, featured, reader_app_enabled: readerAppEnabled, owner_id: ownerId, sort, page, } = request; const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; if (pageSize != null) { _queryParams["page_size"] = pageSize.toString(); } if (category != null) { _queryParams["category"] = category; } if (gender != null) { _queryParams["gender"] = gender; } if (age != null) { _queryParams["age"] = age; } if (accent != null) { _queryParams["accent"] = accent; } if (language != null) { _queryParams["language"] = language; } if (search != null) { _queryParams["search"] = search; } if (useCases != null) { if (Array.isArray(useCases)) { _queryParams["use_cases"] = useCases.map((item) => item); } else { _queryParams["use_cases"] = useCases; } } if (descriptives != null) { if (Array.isArray(descriptives)) { _queryParams["descriptives"] = descriptives.map((item) => item); } else { _queryParams["descriptives"] = descriptives; } } if (featured != null) { _queryParams["featured"] = featured.toString(); } if (readerAppEnabled != null) { _queryParams["reader_app_enabled"] = readerAppEnabled.toString(); } if (ownerId != null) { _queryParams["owner_id"] = ownerId; } if (sort != null) { _queryParams["sort"] = sort; } if (page != null) { _queryParams["page"] = page.toString(); } const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/shared-voices", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", queryParameters: _queryParams, requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.GetLibraryVoicesResponse; } 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("Timeout exceeded when calling GET /v1/shared-voices."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Gets a list of shared voices. * * @param {ElevenLabs.VoicesGetSharedRequest} request * @param {Voices.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.voices.getShared({ * page_size: 1, * gender: "female", * language: "en" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voices/client/Client.ts#L806-L950
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Voices.getSimilarLibraryVoices
public async getSimilarLibraryVoices( request: ElevenLabs.BodyGetSimilarLibraryVoicesV1SimilarVoicesPost, requestOptions?: Voices.RequestOptions, ): Promise<ElevenLabs.GetLibraryVoicesResponse> { const _request = await core.newFormData(); if (request.audio_file != null) { await _request.appendFile("audio_file", request.audio_file); } if (request.similarity_threshold != null) { _request.append("similarity_threshold", request.similarity_threshold.toString()); } if (request.top_k != null) { _request.append("top_k", request.top_k.toString()); } const _maybeEncodedRequest = await _request.getRequest(); const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/similar-voices", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ..._maybeEncodedRequest.headers, ...requestOptions?.headers, }, requestType: "file", duplex: _maybeEncodedRequest.duplex, body: _maybeEncodedRequest.body, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.GetLibraryVoicesResponse; } 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("Timeout exceeded when calling POST /v1/similar-voices."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Returns a list of shared voices similar to the provided audio sample. If neither similarity_threshold nor top_k is provided, we will apply default values. * * @param {ElevenLabs.BodyGetSimilarLibraryVoicesV1SimilarVoicesPost} request * @param {Voices.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.voices.getSimilarLibraryVoices({}) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voices/client/Client.ts#L963-L1041
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Voices.getAProfilePage
public async getAProfilePage( handle: string, requestOptions?: Voices.RequestOptions, ): Promise<ElevenLabs.ProfilePageResponseModel> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `profile/${encodeURIComponent(handle)}`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.ProfilePageResponseModel; } 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("Timeout exceeded when calling GET /profile/{handle}."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Gets a profile page based on a handle * * @param {string} handle - Handle for a VA's profile page * @param {Voices.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.voices.getAProfilePage("talexgeorge") */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/voices/client/Client.ts#L1054-L1116
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Workspace.searchUserGroups
public async searchUserGroups( request: ElevenLabs.SearchUserGroupsV1WorkspaceGroupsSearchGetRequest, requestOptions?: Workspace.RequestOptions, ): Promise<ElevenLabs.WorkspaceGroupByNameResponseModel[]> { const { name } = request; const _queryParams: Record<string, string | string[] | object | object[] | null> = {}; _queryParams["name"] = name; const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/workspace/groups/search", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", queryParameters: _queryParams, requestType: "json", timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { return _response.body as ElevenLabs.WorkspaceGroupByNameResponseModel[]; } 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( "Timeout exceeded when calling GET /v1/workspace/groups/search.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Searches for user groups in the workspace. Multiple or no groups may be returned. * * @param {ElevenLabs.SearchUserGroupsV1WorkspaceGroupsSearchGetRequest} request * @param {Workspace.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.workspace.searchUserGroups({ * name: "name" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/workspace/client/Client.ts#L50-L118
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Workspace.deleteMemberFromUserGroup
public async deleteMemberFromUserGroup( groupId: string, request: ElevenLabs.BodyDeleteMemberFromUserGroupV1WorkspaceGroupsGroupIdMembersRemovePost, requestOptions?: Workspace.RequestOptions, ): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/workspace/groups/${encodeURIComponent(groupId)}/members/remove`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, 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( "Timeout exceeded when calling POST /v1/workspace/groups/{group_id}/members/remove.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Removes a member from the specified group. This endpoint may only be called by workspace administrators. * * @param {string} groupId - The ID of the target group. * @param {ElevenLabs.BodyDeleteMemberFromUserGroupV1WorkspaceGroupsGroupIdMembersRemovePost} request * @param {Workspace.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.workspace.deleteMemberFromUserGroup("group_id", { * email: "email" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/workspace/client/Client.ts#L134-L200
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Workspace.addMemberToUserGroup
public async addMemberToUserGroup( groupId: string, request: ElevenLabs.BodyAddMemberToUserGroupV1WorkspaceGroupsGroupIdMembersPost, requestOptions?: Workspace.RequestOptions, ): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, `v1/workspace/groups/${encodeURIComponent(groupId)}/members`, ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, 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( "Timeout exceeded when calling POST /v1/workspace/groups/{group_id}/members.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Adds a member of your workspace to the specified group. This endpoint may only be called by workspace administrators. * * @param {string} groupId - The ID of the target group. * @param {ElevenLabs.BodyAddMemberToUserGroupV1WorkspaceGroupsGroupIdMembersPost} request * @param {Workspace.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.workspace.addMemberToUserGroup("group_id", { * email: "email" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/workspace/client/Client.ts#L216-L282
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Workspace.inviteUser
public async inviteUser( request: ElevenLabs.BodyInviteUserV1WorkspaceInvitesAddPost, requestOptions?: Workspace.RequestOptions, ): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/workspace/invites/add", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, 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( "Timeout exceeded when calling POST /v1/workspace/invites/add.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Sends an email invitation to join your workspace to the provided email. If the user doesn't have an account they will be prompted to create one. If the user accepts this invite they will be added as a user to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. If the user is already in the workspace a 400 error will be returned. * * @param {ElevenLabs.BodyInviteUserV1WorkspaceInvitesAddPost} request * @param {Workspace.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.workspace.inviteUser({ * email: "email" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/workspace/client/Client.ts#L297-L362
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Workspace.inviteMultipleUsers
public async inviteMultipleUsers( request: ElevenLabs.BodyInviteMultipleUsersV1WorkspaceInvitesAddBulkPost, requestOptions?: Workspace.RequestOptions, ): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/workspace/invites/add-bulk", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, 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( "Timeout exceeded when calling POST /v1/workspace/invites/add-bulk.", ); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Sends email invitations to join your workspace to the provided emails. Requires all email addresses to be part of a verified domain. If the users don't have an account they will be prompted to create one. If the users accept these invites they will be added as users to your workspace and your subscription using one of your seats. This endpoint may only be called by workspace administrators. * * @param {ElevenLabs.BodyInviteMultipleUsersV1WorkspaceInvitesAddBulkPost} request * @param {Workspace.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.workspace.inviteMultipleUsers({ * emails: ["emails"] * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/workspace/client/Client.ts#L377-L442
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Workspace.deleteExistingInvitation
public async deleteExistingInvitation( request: ElevenLabs.BodyDeleteExistingInvitationV1WorkspaceInvitesDelete, requestOptions?: Workspace.RequestOptions, ): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/workspace/invites", ), method: "DELETE", 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, 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("Timeout exceeded when calling DELETE /v1/workspace/invites."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Invalidates an existing email invitation. The invitation will still show up in the inbox it has been delivered to, but activating it to join the workspace won't work. This endpoint may only be called by workspace administrators. * * @param {ElevenLabs.BodyDeleteExistingInvitationV1WorkspaceInvitesDelete} request * @param {Workspace.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.workspace.deleteExistingInvitation({ * email: "email" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/workspace/client/Client.ts#L457-L520
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
Workspace.updateMember
public async updateMember( request: ElevenLabs.BodyUpdateMemberV1WorkspaceMembersPost, requestOptions?: Workspace.RequestOptions, ): Promise<unknown> { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ElevenLabsEnvironment.Production, "v1/workspace/members", ), 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": "1.51.0", "User-Agent": "elevenlabs/1.51.0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, contentType: "application/json", requestType: "json", body: request, 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("Timeout exceeded when calling POST /v1/workspace/members."); case "unknown": throw new errors.ElevenLabsError({ message: _response.error.errorMessage, }); } }
/** * Updates attributes of a workspace member. Apart from the email identifier, all parameters will remain unchanged unless specified. This endpoint may only be called by workspace administrators. * * @param {ElevenLabs.BodyUpdateMemberV1WorkspaceMembersPost} request * @param {Workspace.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link ElevenLabs.UnprocessableEntityError} * * @example * await client.workspace.updateMember({ * email: "email" * }) */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/api/resources/workspace/client/Client.ts#L535-L598
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
addJitter
function addJitter(delay: number): number { // Generate a random value between -JITTER_FACTOR and +JITTER_FACTOR const jitterMultiplier = 1 + (Math.random() * 2 - 1) * JITTER_FACTOR; return delay * jitterMultiplier; }
// 20% random jitter
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/core/fetcher/requestWithRetries.ts#L6-L10
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
elevenlabs-js
github_2023
elevenlabs
typescript
ElevenLabsClient.generate
async generate( request: (ElevenLabsClient.GeneratAudioBulk | ElevenLabsClient.GenerateAudioStream) & { voice?: string }, requestOptions: FernClient.RequestOptions = {} ): Promise<stream.Readable> { const voiceIdOrName = request.voice ?? "Sarah"; const voiceId = isVoiceId(voiceIdOrName) ? voiceIdOrName : ( await this.voices.getAll({ show_legacy: true, }) ).voices.filter((voice) => voice.name === voiceIdOrName)[0]?.voice_id; if (voiceId == null) { throw new errors.ElevenLabsError({ message: `${voiceIdOrName} is not a valid voice name`, }); } if (isGenerateAudioStream(request)) { return await this.textToSpeech.convertAsStream(voiceId, request, requestOptions); } else { return await this.textToSpeech.convert(voiceId, request, requestOptions); } }
/** * Generates audio for a voice. * * @example Generate the entire audio * import { play } from "elevenlabs"; * * const audio = eleven.generate({ * voiceId: "Matilda" // defaults to Sarah * }) * await play(audio); * * @example * import { stream } from "elevenlabs" * * const audioStream = eleven.generate({ * stream: true, * voice: "Sarah" * }) * await stream(audioStream); */
https://github.com/elevenlabs/elevenlabs-js/blob/89894c5601806e8c95e7eb3931a7d674e5ad9a8d/src/wrapper/ElevenLabsClient.ts#L56-L78
89894c5601806e8c95e7eb3931a7d674e5ad9a8d
astro-font
github_2023
rishi-raj-jain
typescript
getWeightNumber
function getWeightNumber(weight: string) { return weight === 'normal' ? NORMAL_WEIGHT : weight === 'bold' ? BOLD_WEIGHT : Number(weight) }
/** * Convert the weight string to a number so it can be used for comparison. * Weights can be defined as a number, 'normal' or 'bold'. https://developer.mozilla.org/docs/Web/CSS/@font-face/font-weight */
https://github.com/rishi-raj-jain/astro-font/blob/e567d89067bc00b2c570f0215e9bf16060119b0f/packages/astro-font/fallback.ts#L13-L15
e567d89067bc00b2c570f0215e9bf16060119b0f
astro-font
github_2023
rishi-raj-jain
typescript
getDistanceFromNormalWeight
function getDistanceFromNormalWeight(weight?: string) { if (!weight) { return 0 } // If it's a variable font the weight is defined with two numbers "100 900", rather than just one "400" const [firstWeight, secondWeight] = weight.trim().split(/ +/).map(getWeightNumber) if (Number.isNaN(firstWeight) || Number.isNaN(secondWeight)) { console.error(`Invalid weight value in src array: \`${weight}\`.\nExpected \`normal\`, \`bold\` or a number.`) } // If the weight doesn't have have a second value, it's not a variable font // If that's the case, just return the distance from normal weight if (!secondWeight) { return firstWeight - NORMAL_WEIGHT } // Normal weight is within variable font range if (firstWeight <= NORMAL_WEIGHT && secondWeight >= NORMAL_WEIGHT) { return 0 } // Normal weight is outside variable font range // Return the distance of normal weight to the variable font range const firstWeightDistance = firstWeight - NORMAL_WEIGHT const secondWeightDistance = secondWeight - NORMAL_WEIGHT if (Math.abs(firstWeightDistance) < Math.abs(secondWeightDistance)) { return firstWeightDistance } return secondWeightDistance }
/** * Get the distance from normal (400) weight for the provided weight. * If it's not a variable font we can just return the distance. * If it's a variable font we need to compare its weight range to 400. */
https://github.com/rishi-raj-jain/astro-font/blob/e567d89067bc00b2c570f0215e9bf16060119b0f/packages/astro-font/fallback.ts#L22-L48
e567d89067bc00b2c570f0215e9bf16060119b0f
astro-font
github_2023
rishi-raj-jain
typescript
calcAverageWidth
function calcAverageWidth(font: Font): number | undefined { try { /** * Finding the right characters to use when calculating the average width is tricky. * We can't just use the average width of all characters, because we have to take letter frequency into account. * We also have to take word length into account, because the font's space width usually differ a lot from other characters. * The goal is to find a string that'll give you a good average width, given most texts in most languages. * * TODO: Currently only works for the latin alphabet. Support more languages by finding the right characters for additional languages. * * The used characters were decided through trial and error with letter frequency and word length tables as a guideline. * E.g. https://en.wikipedia.org/wiki/Letter_frequency */ const avgCharacters = 'aaabcdeeeefghiijklmnnoopqrrssttuvwxyz ' // Check if the font file has all the characters we need to calculate the average width const hasAllChars = font .glyphsForString(avgCharacters) .flatMap((glyph) => glyph.codePoints) .every((codePoint) => font.hasGlyphForCodePoint(codePoint)) if (!hasAllChars) return undefined const widths = font.glyphsForString(avgCharacters).map((glyph) => glyph.advanceWidth) const totalWidth = widths.reduce((sum, width) => sum + width, 0) return totalWidth / widths.length } catch { // Could not calculate average width from the font file, skip size-adjust return undefined } }
/** * Calculate the average character width of a font file. * Used to calculate the size-adjust property by comparing the fallback average with the loaded font average. */
https://github.com/rishi-raj-jain/astro-font/blob/e567d89067bc00b2c570f0215e9bf16060119b0f/packages/astro-font/font.ts#L31-L58
e567d89067bc00b2c570f0215e9bf16060119b0f
astro-font
github_2023
rishi-raj-jain
typescript
getFS
async function getFS(): Promise<typeof import('node:fs') | undefined> { let fs try { fs = await import('node:fs') return fs } catch (e) {} }
// Check if file system can be accessed
https://github.com/rishi-raj-jain/astro-font/blob/e567d89067bc00b2c570f0215e9bf16060119b0f/packages/astro-font/utils.ts#L84-L90
e567d89067bc00b2c570f0215e9bf16060119b0f
astro-font
github_2023
rishi-raj-jain
typescript
ifFSOSWrites
async function ifFSOSWrites(dir: string): Promise<string | undefined> { try { const fs = await getFS() if (fs) { const testDir = join(dir, '.astro_font') if (!fs.existsSync(testDir)) fs.mkdirSync(testDir, { recursive: true }) fs.rmSync(testDir, { recursive: true, force: true }) return dir } } catch (e) {} }
// Check if writing is permitted by the file system
https://github.com/rishi-raj-jain/astro-font/blob/e567d89067bc00b2c570f0215e9bf16060119b0f/packages/astro-font/utils.ts#L101-L111
e567d89067bc00b2c570f0215e9bf16060119b0f
astro-font
github_2023
rishi-raj-jain
typescript
getFontBuffer
async function getFontBuffer(path: string): Promise<Buffer | undefined> { const fs = await getFS() if (path.includes('https:') || path.includes('http:')) { let tmp = await fetch(path) return Buffer.from(await tmp.arrayBuffer()) } else { // If the file system has the access to the *local* font if (fs && fs.existsSync(path)) { return fs.readFileSync(path) } } }
// Get the font whether remote or local buffer
https://github.com/rishi-raj-jain/astro-font/blob/e567d89067bc00b2c570f0215e9bf16060119b0f/packages/astro-font/utils.ts#L121-L132
e567d89067bc00b2c570f0215e9bf16060119b0f
astro-font
github_2023
rishi-raj-jain
typescript
extractFileNameFromPath
function extractFileNameFromPath(path: string): string { const lastSlashIndex = path.lastIndexOf('/') if (lastSlashIndex !== -1) return path.substring(lastSlashIndex + 1) return path }
// Get everything after the last forward slash
https://github.com/rishi-raj-jain/astro-font/blob/e567d89067bc00b2c570f0215e9bf16060119b0f/packages/astro-font/utils.ts#L135-L139
e567d89067bc00b2c570f0215e9bf16060119b0f
astro-font
github_2023
rishi-raj-jain
typescript
parseGoogleCSS
function parseGoogleCSS(tmp: string) { let match const fontFaceMatches = [] const fontFaceRegex = /@font-face\s*{([^}]+)}/g while ((match = fontFaceRegex.exec(tmp)) !== null) { const fontFaceRule = match[1] const fontFaceObject: any = {} fontFaceRule.split(';').forEach((property) => { if (property.includes('src') && property.includes('url')) { try { fontFaceObject['path'] = property .trim() .split(/\(|\)|(url\()/) .find((each) => each.trim().includes('https:')) ?.trim() } catch (e) {} } if (property.includes('-style')) { fontFaceObject['style'] = property.split(':').map((i) => i.trim())[1] } if (property.includes('-weight')) { fontFaceObject['weight'] = property.split(':').map((i) => i.trim())[1] } if (property.includes('unicode-range')) { if (!fontFaceObject['css']) fontFaceObject['css'] = {} fontFaceObject['css']['unicode-range'] = property.split(':').map((i) => i.trim())[1] } }) fontFaceMatches.push(fontFaceObject) } return fontFaceMatches }
// Custom script to parseGoogleCSS
https://github.com/rishi-raj-jain/astro-font/blob/e567d89067bc00b2c570f0215e9bf16060119b0f/packages/astro-font/utils.ts#L191-L222
e567d89067bc00b2c570f0215e9bf16060119b0f
astro-font
github_2023
rishi-raj-jain
typescript
slugifyPath
const slugifyPath = (i: Source) => `${i.path}_${i.style}_${i.weight}`
// Create a json based on slugified path, style and weight
https://github.com/rishi-raj-jain/astro-font/blob/e567d89067bc00b2c570f0215e9bf16060119b0f/packages/astro-font/utils.ts#L272-L272
e567d89067bc00b2c570f0215e9bf16060119b0f
unruggable.meme
github_2023
keep-starknet-strange
typescript
Factory.getBaseMemecoin
public async getBaseMemecoin(address: string): Promise<BaseMemecoin | undefined> { const result = await multiCallContract(this.config.provider, this.config.chainId, [ { contractAddress: FACTORY_ADDRESSES[this.config.chainId], entrypoint: Entrypoint.IS_MEMECOIN, calldata: [address], }, { contractAddress: address, entrypoint: Entrypoint.NAME, }, { contractAddress: address, entrypoint: Entrypoint.SYMBOL, }, { contractAddress: address, entrypoint: Entrypoint.OWNER, }, { contractAddress: address, entrypoint: Entrypoint.TOTAL_SUPPLY, }, ]) const [[isMemecoin], [name], [symbol], [owner], totalSupply] = result if (!+isMemecoin) return undefined return { address, name: shortString.decodeShortString(name), symbol: shortString.decodeShortString(symbol), owner: getChecksumAddress(owner), decimals: DECIMALS, totalSupply: uint256.uint256ToBN({ low: totalSupply[0], high: totalSupply[1] }).toString(), } }
//
https://github.com/keep-starknet-strange/unruggable.meme/blob/1cfa8a5b7ed00eb63f9b7bba537233e162086e9b/packages/core/src/factory/default.ts#L56-L93
1cfa8a5b7ed00eb63f9b7bba537233e162086e9b
unruggable.meme
github_2023
keep-starknet-strange
typescript
Factory.getMemecoinLaunchData
public async getMemecoinLaunchData(address: string): Promise<LaunchedMemecoin> { const result = await multiCallContract(this.config.provider, this.config.chainId, [ { contractAddress: address, entrypoint: Entrypoint.GET_TEAM_ALLOCATION, }, { contractAddress: address, entrypoint: Entrypoint.LAUNCHED_AT_BLOCK_NUMBER, }, { contractAddress: address, entrypoint: Entrypoint.IS_LAUNCHED, }, { contractAddress: FACTORY_ADDRESSES[this.config.chainId], entrypoint: Entrypoint.LOCKED_LIQUIDITY, calldata: [address], }, { contractAddress: address, entrypoint: Entrypoint.LAUNCHED_WITH_LIQUIDITY_PARAMETERS, }, ]) const [ teamAllocation, [launchBlockNumber], [launched], [dontHaveLiq, lockManager, liqTypeIndex, ekuboId], launchParams, ] = result const liquidityType = Object.values(LiquidityType)[+liqTypeIndex] as LiquidityType const isLaunched = !!+launched && !+dontHaveLiq && !+launchParams[0] && liquidityType if (!isLaunched) { return { isLaunched: false, } } let liquidity switch (liquidityType) { case LiquidityType.STARKDEFI_ERC20: case LiquidityType.JEDISWAP_ERC20: { const baseLiquidity = { type: liquidityType, lockManager, lockPosition: launchParams[5], quoteToken: getChecksumAddress(launchParams[2]), quoteAmount: uint256.uint256ToBN({ low: launchParams[3], high: launchParams[4] }).toString(), } satisfies Partial<JediswapLiquidity> liquidity = { ...baseLiquidity, ...(await this.getJediswapLiquidityLockPosition(baseLiquidity)), } break } case LiquidityType.EKUBO_NFT: { const baseLiquidity = { type: liquidityType, lockManager, ekuboId, quoteToken: getChecksumAddress(launchParams[7]), startingTick: +launchParams[4] * (+launchParams[5] ? -1 : 1), // mag * sign } satisfies Partial<EkuboLiquidity> liquidity = { ...baseLiquidity, ...(await this.getEkuboLiquidityLockPosition(baseLiquidity)), } } } return { isLaunched: true, quoteToken: QUOTE_TOKENS[this.config.chainId][liquidity.quoteToken], launch: { teamAllocation: uint256.uint256ToBN({ low: teamAllocation[0], high: teamAllocation[1] }).toString(), blockNumber: Number(launchBlockNumber), }, liquidity, } }
//
https://github.com/keep-starknet-strange/unruggable.meme/blob/1cfa8a5b7ed00eb63f9b7bba537233e162086e9b/packages/core/src/factory/default.ts#L99-L186
1cfa8a5b7ed00eb63f9b7bba537233e162086e9b
unruggable.meme
github_2023
keep-starknet-strange
typescript
Factory.getJediswapLiquidityLockPosition
private async getJediswapLiquidityLockPosition(liquidity: Pick<JediswapLiquidity, 'lockManager' | 'lockPosition'>) { const { result } = await this.config.provider.callContract({ contractAddress: liquidity.lockManager, entrypoint: Entrypoint.GET_LOCK_DETAILS, calldata: [liquidity.lockPosition], }) // TODO: deconstruct result array in cleaner way return { unlockTime: +result[4], owner: getChecksumAddress(result[3]), } satisfies Partial<JediswapLiquidity> }
//
https://github.com/keep-starknet-strange/unruggable.meme/blob/1cfa8a5b7ed00eb63f9b7bba537233e162086e9b/packages/core/src/factory/default.ts#L192-L205
1cfa8a5b7ed00eb63f9b7bba537233e162086e9b
unruggable.meme
github_2023
keep-starknet-strange
typescript
Factory.getEkuboFees
public async getEkuboFees(memecoin: Memecoin): Promise<Fraction | undefined> { if (!memecoin.isLaunched || memecoin.liquidity.type !== LiquidityType.EKUBO_NFT || !memecoin.quoteToken) return const calldata = CallData.compile([ memecoin.liquidity.ekuboId, memecoin.liquidity.poolKey, memecoin.liquidity.bounds, ]) // call ekubo position to get collectable fees details const { result } = await this.config.provider.callContract({ contractAddress: EKUBO_POSITIONS_ADDRESSES[this.config.chainId], entrypoint: Entrypoint.GET_TOKEN_INFOS, calldata, }) const [, , , , , , , fees0, fees1] = result // parse fees amount return new Fraction( (new Fraction(memecoin.address).lessThan(memecoin.quoteToken.address) ? fees1 : fees0).toString(), decimalsScale(memecoin.quoteToken.decimals), ) }
//
https://github.com/keep-starknet-strange/unruggable.meme/blob/1cfa8a5b7ed00eb63f9b7bba537233e162086e9b/packages/core/src/factory/default.ts#L243-L266
1cfa8a5b7ed00eb63f9b7bba537233e162086e9b
unruggable.meme
github_2023
keep-starknet-strange
typescript
Factory.getCollectEkuboFeesCalldata
public getCollectEkuboFeesCalldata(memecoin: Memecoin) { if (!memecoin.isLaunched || memecoin.liquidity.type !== LiquidityType.EKUBO_NFT) return const collectFeesCalldata = CallData.compile([ memecoin.liquidity.ekuboId, // ekubo pool id memecoin.liquidity.owner, ]) const calls = [ { contractAddress: memecoin.liquidity.lockManager, entrypoint: Entrypoint.WITHDRAW_FEES, calldata: collectFeesCalldata, }, ] return { calls } }
//
https://github.com/keep-starknet-strange/unruggable.meme/blob/1cfa8a5b7ed00eb63f9b7bba537233e162086e9b/packages/core/src/factory/default.ts#L272-L289
1cfa8a5b7ed00eb63f9b7bba537233e162086e9b
unruggable.meme
github_2023
keep-starknet-strange
typescript
Factory.getExtendLiquidityLockCalldata
public getExtendLiquidityLockCalldata(memecoin: Memecoin, seconds: number) { if (!memecoin?.isLaunched || memecoin.liquidity.type === LiquidityType.EKUBO_NFT) return const extendCalldata = CallData.compile([ memecoin.liquidity.lockPosition, // liquidity position seconds, ]) const calls = [ { contractAddress: memecoin.liquidity.lockManager, entrypoint: Entrypoint.EXTEND_LOCK, calldata: extendCalldata, }, ] return { calls } }
//
https://github.com/keep-starknet-strange/unruggable.meme/blob/1cfa8a5b7ed00eb63f9b7bba537233e162086e9b/packages/core/src/factory/default.ts#L295-L312
1cfa8a5b7ed00eb63f9b7bba537233e162086e9b
unruggable.meme
github_2023
keep-starknet-strange
typescript
Factory.getDeployCalldata
public getDeployCalldata(data: DeployData) { const salt = stark.randomAddress() const constructorCalldata = CallData.compile([ data.owner, data.name, data.symbol, uint256.bnToUint256(BigInt(data.initialSupply) * BigInt(decimalsScale(DECIMALS))), salt, ]) const tokenAddress = hash.calculateContractAddressFromHash( salt, TOKEN_CLASS_HASH[this.config.chainId], constructorCalldata.slice(0, -1), FACTORY_ADDRESSES[this.config.chainId], ) const calls = [ { contractAddress: FACTORY_ADDRESSES[this.config.chainId], entrypoint: Entrypoint.CREATE_MEMECOIN, calldata: constructorCalldata, }, ] return { tokenAddress, calls } }
//
https://github.com/keep-starknet-strange/unruggable.meme/blob/1cfa8a5b7ed00eb63f9b7bba537233e162086e9b/packages/core/src/factory/default.ts#L318-L345
1cfa8a5b7ed00eb63f9b7bba537233e162086e9b
unruggable.meme
github_2023
keep-starknet-strange
typescript
Factory.getEkuboLaunchCalldata
public async getEkuboLaunchCalldata(memecoin: Memecoin, data: EkuboLaunchData) { // get quote token current price const quoteTokenPrice = await getPairPrice(this.config.provider, data.quoteToken.usdcPair) // get the team allocation amount const teamAllocationFraction = data.teamAllocations.reduce((acc, { amount }) => acc.add(amount), new Fraction(0)) const teamAllocationPercentage = new Percent( teamAllocationFraction.quotient, new Fraction(memecoin.totalSupply, decimalsScale(DECIMALS)).quotient, ) // get the team allocation value in quote token at launch const teamAllocationQuoteAmount = new Fraction(data.startingMarketCap) .divide(quoteTokenPrice) .multiply(teamAllocationPercentage.multiply(data.fees.add(1))) const uin256TeamAllocationQuoteAmount = uint256.bnToUint256( BigInt(teamAllocationQuoteAmount.multiply(decimalsScale(data.quoteToken.decimals)).quotient.toString()), ) // get initial price based on mcap and quote token price const initialPrice = +new Fraction(data.startingMarketCap) .divide(quoteTokenPrice) .multiply(decimalsScale(DECIMALS)) .divide(new Fraction(memecoin.totalSupply)) .toFixed(DECIMALS) // convert initial price to an Ekubo tick const startingTickMag = getStartingTick(initialPrice) const i129StartingTick = { mag: Math.abs(startingTickMag), sign: startingTickMag < 0, } // get ekubo fees const fees = data.fees.multiply(EKUBO_FEES_MULTIPLICATOR).quotient.toString() // get quote token transfer calldata to buy the team allocation const transferCalldata = CallData.compile([ FACTORY_ADDRESSES[this.config.chainId], // recipient uin256TeamAllocationQuoteAmount, // amount ]) // get initial holders informations const initialHolders = data.teamAllocations.map(({ address }) => address) const initialHoldersAmounts = data.teamAllocations.map(({ amount }) => uint256.bnToUint256(BigInt(amount) * BigInt(decimalsScale(DECIMALS))), ) // get launch calldata const launchCalldata = CallData.compile([ memecoin.address, // memecoin address data.antiBotPeriod, // anti bot period in seconds +data.holdLimit.toFixed(1) * 100, // hold limit data.quoteToken.address, // quote token address initialHolders, // initial holders initialHoldersAmounts, // initial holders amounts fees, // ekubo fees EKUBO_TICK_SPACING, // tick spacing i129StartingTick, // starting tick EKUBO_BOUND, // bound ]) const calls = [ { contractAddress: data.quoteToken.address, entrypoint: Entrypoint.TRANSFER, calldata: transferCalldata, }, { contractAddress: FACTORY_ADDRESSES[this.config.chainId], entrypoint: Entrypoint.LAUNCH_ON_EKUBO, calldata: launchCalldata, }, ] return { calls, } }
//
https://github.com/keep-starknet-strange/unruggable.meme/blob/1cfa8a5b7ed00eb63f9b7bba537233e162086e9b/packages/core/src/factory/default.ts#L351-L429
1cfa8a5b7ed00eb63f9b7bba537233e162086e9b