/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import * as models from "../index.js"; export type CreateSpeechRequest = { voiceId: string; apiConvertTextToSpeechUsingCharacterRequest: models.APIConvertTextToSpeechUsingCharacterRequest; }; /** * Phoneme timing data with IPA symbols */ export type Phonemes = { /** * List of IPA phonetic symbols */ symbols?: Array | undefined; /** * Start times for each phoneme in seconds */ startTimesSeconds?: Array | undefined; /** * Duration for each phoneme in seconds */ durationsSeconds?: Array | undefined; }; /** * JSON response with base64 audio and phoneme data (when include_phonemes=true) */ export type CreateSpeechResponseBody = { /** * Base64 encoded audio data */ audioBase64: string; /** * Phoneme timing data with IPA symbols */ phonemes?: Phonemes | undefined; }; export type CreateSpeechResponseResult = | CreateSpeechResponseBody | ReadableStream | ReadableStream; export type CreateSpeechResponse = { headers: { [k: string]: Array }; result: | CreateSpeechResponseBody | ReadableStream | ReadableStream; }; /** @internal */ export const CreateSpeechRequest$inboundSchema: z.ZodType< CreateSpeechRequest, z.ZodTypeDef, unknown > = z.object({ voice_id: z.string(), APIConvertTextToSpeechUsingCharacterRequest: models.APIConvertTextToSpeechUsingCharacterRequest$inboundSchema, }).transform((v) => { return remap$(v, { "voice_id": "voiceId", "APIConvertTextToSpeechUsingCharacterRequest": "apiConvertTextToSpeechUsingCharacterRequest", }); }); /** @internal */ export type CreateSpeechRequest$Outbound = { voice_id: string; APIConvertTextToSpeechUsingCharacterRequest: models.APIConvertTextToSpeechUsingCharacterRequest$Outbound; }; /** @internal */ export const CreateSpeechRequest$outboundSchema: z.ZodType< CreateSpeechRequest$Outbound, z.ZodTypeDef, CreateSpeechRequest > = z.object({ voiceId: z.string(), apiConvertTextToSpeechUsingCharacterRequest: models.APIConvertTextToSpeechUsingCharacterRequest$outboundSchema, }).transform((v) => { return remap$(v, { voiceId: "voice_id", apiConvertTextToSpeechUsingCharacterRequest: "APIConvertTextToSpeechUsingCharacterRequest", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CreateSpeechRequest$ { /** @deprecated use `CreateSpeechRequest$inboundSchema` instead. */ export const inboundSchema = CreateSpeechRequest$inboundSchema; /** @deprecated use `CreateSpeechRequest$outboundSchema` instead. */ export const outboundSchema = CreateSpeechRequest$outboundSchema; /** @deprecated use `CreateSpeechRequest$Outbound` instead. */ export type Outbound = CreateSpeechRequest$Outbound; } export function createSpeechRequestToJSON( createSpeechRequest: CreateSpeechRequest, ): string { return JSON.stringify( CreateSpeechRequest$outboundSchema.parse(createSpeechRequest), ); } export function createSpeechRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateSpeechRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateSpeechRequest' from JSON`, ); } /** @internal */ export const Phonemes$inboundSchema: z.ZodType< Phonemes, z.ZodTypeDef, unknown > = z.object({ symbols: z.array(z.string()).optional(), start_times_seconds: z.array(z.number()).optional(), durations_seconds: z.array(z.number()).optional(), }).transform((v) => { return remap$(v, { "start_times_seconds": "startTimesSeconds", "durations_seconds": "durationsSeconds", }); }); /** @internal */ export type Phonemes$Outbound = { symbols?: Array | undefined; start_times_seconds?: Array | undefined; durations_seconds?: Array | undefined; }; /** @internal */ export const Phonemes$outboundSchema: z.ZodType< Phonemes$Outbound, z.ZodTypeDef, Phonemes > = z.object({ symbols: z.array(z.string()).optional(), startTimesSeconds: z.array(z.number()).optional(), durationsSeconds: z.array(z.number()).optional(), }).transform((v) => { return remap$(v, { startTimesSeconds: "start_times_seconds", durationsSeconds: "durations_seconds", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Phonemes$ { /** @deprecated use `Phonemes$inboundSchema` instead. */ export const inboundSchema = Phonemes$inboundSchema; /** @deprecated use `Phonemes$outboundSchema` instead. */ export const outboundSchema = Phonemes$outboundSchema; /** @deprecated use `Phonemes$Outbound` instead. */ export type Outbound = Phonemes$Outbound; } export function phonemesToJSON(phonemes: Phonemes): string { return JSON.stringify(Phonemes$outboundSchema.parse(phonemes)); } export function phonemesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Phonemes$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Phonemes' from JSON`, ); } /** @internal */ export const CreateSpeechResponseBody$inboundSchema: z.ZodType< CreateSpeechResponseBody, z.ZodTypeDef, unknown > = z.object({ audio_base64: z.string(), phonemes: z.lazy(() => Phonemes$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "audio_base64": "audioBase64", }); }); /** @internal */ export type CreateSpeechResponseBody$Outbound = { audio_base64: string; phonemes?: Phonemes$Outbound | undefined; }; /** @internal */ export const CreateSpeechResponseBody$outboundSchema: z.ZodType< CreateSpeechResponseBody$Outbound, z.ZodTypeDef, CreateSpeechResponseBody > = z.object({ audioBase64: z.string(), phonemes: z.lazy(() => Phonemes$outboundSchema).optional(), }).transform((v) => { return remap$(v, { audioBase64: "audio_base64", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CreateSpeechResponseBody$ { /** @deprecated use `CreateSpeechResponseBody$inboundSchema` instead. */ export const inboundSchema = CreateSpeechResponseBody$inboundSchema; /** @deprecated use `CreateSpeechResponseBody$outboundSchema` instead. */ export const outboundSchema = CreateSpeechResponseBody$outboundSchema; /** @deprecated use `CreateSpeechResponseBody$Outbound` instead. */ export type Outbound = CreateSpeechResponseBody$Outbound; } export function createSpeechResponseBodyToJSON( createSpeechResponseBody: CreateSpeechResponseBody, ): string { return JSON.stringify( CreateSpeechResponseBody$outboundSchema.parse(createSpeechResponseBody), ); } export function createSpeechResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateSpeechResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateSpeechResponseBody' from JSON`, ); } /** @internal */ export const CreateSpeechResponseResult$inboundSchema: z.ZodType< CreateSpeechResponseResult, z.ZodTypeDef, unknown > = z.union([ z.lazy(() => CreateSpeechResponseBody$inboundSchema), z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]); /** @internal */ export type CreateSpeechResponseResult$Outbound = | CreateSpeechResponseBody$Outbound | ReadableStream | ReadableStream; /** @internal */ export const CreateSpeechResponseResult$outboundSchema: z.ZodType< CreateSpeechResponseResult$Outbound, z.ZodTypeDef, CreateSpeechResponseResult > = z.union([ z.lazy(() => CreateSpeechResponseBody$outboundSchema), z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CreateSpeechResponseResult$ { /** @deprecated use `CreateSpeechResponseResult$inboundSchema` instead. */ export const inboundSchema = CreateSpeechResponseResult$inboundSchema; /** @deprecated use `CreateSpeechResponseResult$outboundSchema` instead. */ export const outboundSchema = CreateSpeechResponseResult$outboundSchema; /** @deprecated use `CreateSpeechResponseResult$Outbound` instead. */ export type Outbound = CreateSpeechResponseResult$Outbound; } export function createSpeechResponseResultToJSON( createSpeechResponseResult: CreateSpeechResponseResult, ): string { return JSON.stringify( CreateSpeechResponseResult$outboundSchema.parse(createSpeechResponseResult), ); } export function createSpeechResponseResultFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateSpeechResponseResult$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateSpeechResponseResult' from JSON`, ); } /** @internal */ export const CreateSpeechResponse$inboundSchema: z.ZodType< CreateSpeechResponse, z.ZodTypeDef, unknown > = z.object({ Headers: z.record(z.array(z.string())), Result: z.union([ z.lazy(() => CreateSpeechResponseBody$inboundSchema), z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]), }).transform((v) => { return remap$(v, { "Headers": "headers", "Result": "result", }); }); /** @internal */ export type CreateSpeechResponse$Outbound = { Headers: { [k: string]: Array }; Result: | CreateSpeechResponseBody$Outbound | ReadableStream | ReadableStream; }; /** @internal */ export const CreateSpeechResponse$outboundSchema: z.ZodType< CreateSpeechResponse$Outbound, z.ZodTypeDef, CreateSpeechResponse > = z.object({ headers: z.record(z.array(z.string())), result: z.union([ z.lazy(() => CreateSpeechResponseBody$outboundSchema), z.instanceof(ReadableStream), z.instanceof(ReadableStream), ]), }).transform((v) => { return remap$(v, { headers: "Headers", result: "Result", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CreateSpeechResponse$ { /** @deprecated use `CreateSpeechResponse$inboundSchema` instead. */ export const inboundSchema = CreateSpeechResponse$inboundSchema; /** @deprecated use `CreateSpeechResponse$outboundSchema` instead. */ export const outboundSchema = CreateSpeechResponse$outboundSchema; /** @deprecated use `CreateSpeechResponse$Outbound` instead. */ export type Outbound = CreateSpeechResponse$Outbound; } export function createSpeechResponseToJSON( createSpeechResponse: CreateSpeechResponse, ): string { return JSON.stringify( CreateSpeechResponse$outboundSchema.parse(createSpeechResponse), ); } export function createSpeechResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateSpeechResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateSpeechResponse' from JSON`, ); }