/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../../lib/schemas.js"; import { blobLikeSchema } from "../../types/blobs.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type Files = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; /** * Audio file and voice metadata */ export type CreateClonedVoiceRequest = { /** * Audio file to clone voice from (all common audio formats accepted, max 3MB) */ files: Files | Blob; /** * Name of the cloned voice */ name: string; /** * Description of the cloned voice */ description?: string | undefined; }; /** @internal */ export const Files$inboundSchema: z.ZodType = z .object({ fileName: z.string(), content: z.union([ z.instanceof(ReadableStream), z.instanceof(Blob), z.instanceof(ArrayBuffer), z.instanceof(Uint8Array), ]), }); /** @internal */ export type Files$Outbound = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; /** @internal */ export const Files$outboundSchema: z.ZodType< Files$Outbound, z.ZodTypeDef, Files > = z.object({ fileName: z.string(), content: z.union([ z.instanceof(ReadableStream), z.instanceof(Blob), z.instanceof(ArrayBuffer), z.instanceof(Uint8Array), ]), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Files$ { /** @deprecated use `Files$inboundSchema` instead. */ export const inboundSchema = Files$inboundSchema; /** @deprecated use `Files$outboundSchema` instead. */ export const outboundSchema = Files$outboundSchema; /** @deprecated use `Files$Outbound` instead. */ export type Outbound = Files$Outbound; } export function filesToJSON(files: Files): string { return JSON.stringify(Files$outboundSchema.parse(files)); } export function filesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Files$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Files' from JSON`, ); } /** @internal */ export const CreateClonedVoiceRequest$inboundSchema: z.ZodType< CreateClonedVoiceRequest, z.ZodTypeDef, unknown > = z.object({ files: z.lazy(() => Files$inboundSchema), name: z.string(), description: z.string().optional(), }); /** @internal */ export type CreateClonedVoiceRequest$Outbound = { files: Files$Outbound | Blob; name: string; description?: string | undefined; }; /** @internal */ export const CreateClonedVoiceRequest$outboundSchema: z.ZodType< CreateClonedVoiceRequest$Outbound, z.ZodTypeDef, CreateClonedVoiceRequest > = z.object({ files: z.lazy(() => Files$outboundSchema).or(blobLikeSchema), name: z.string(), description: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CreateClonedVoiceRequest$ { /** @deprecated use `CreateClonedVoiceRequest$inboundSchema` instead. */ export const inboundSchema = CreateClonedVoiceRequest$inboundSchema; /** @deprecated use `CreateClonedVoiceRequest$outboundSchema` instead. */ export const outboundSchema = CreateClonedVoiceRequest$outboundSchema; /** @deprecated use `CreateClonedVoiceRequest$Outbound` instead. */ export type Outbound = CreateClonedVoiceRequest$Outbound; } export function createClonedVoiceRequestToJSON( createClonedVoiceRequest: CreateClonedVoiceRequest, ): string { return JSON.stringify( CreateClonedVoiceRequest$outboundSchema.parse(createClonedVoiceRequest), ); } export function createClonedVoiceRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateClonedVoiceRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateClonedVoiceRequest' from JSON`, ); }