/* * 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 StreamSpeechRequest = { voiceId: string; apiConvertTextToSpeechUsingCharacterRequest: models.APIConvertTextToSpeechUsingCharacterRequest; }; export type StreamSpeechResponseResult = | ReadableStream | ReadableStream | string; export type StreamSpeechResponse = { headers: { [k: string]: Array }; result: ReadableStream | ReadableStream | string; }; /** @internal */ export const StreamSpeechRequest$inboundSchema: z.ZodType< StreamSpeechRequest, 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 StreamSpeechRequest$Outbound = { voice_id: string; APIConvertTextToSpeechUsingCharacterRequest: models.APIConvertTextToSpeechUsingCharacterRequest$Outbound; }; /** @internal */ export const StreamSpeechRequest$outboundSchema: z.ZodType< StreamSpeechRequest$Outbound, z.ZodTypeDef, StreamSpeechRequest > = 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 StreamSpeechRequest$ { /** @deprecated use `StreamSpeechRequest$inboundSchema` instead. */ export const inboundSchema = StreamSpeechRequest$inboundSchema; /** @deprecated use `StreamSpeechRequest$outboundSchema` instead. */ export const outboundSchema = StreamSpeechRequest$outboundSchema; /** @deprecated use `StreamSpeechRequest$Outbound` instead. */ export type Outbound = StreamSpeechRequest$Outbound; } export function streamSpeechRequestToJSON( streamSpeechRequest: StreamSpeechRequest, ): string { return JSON.stringify( StreamSpeechRequest$outboundSchema.parse(streamSpeechRequest), ); } export function streamSpeechRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => StreamSpeechRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'StreamSpeechRequest' from JSON`, ); } /** @internal */ export const StreamSpeechResponseResult$inboundSchema: z.ZodType< StreamSpeechResponseResult, z.ZodTypeDef, unknown > = z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), z.string(), ]); /** @internal */ export type StreamSpeechResponseResult$Outbound = | ReadableStream | ReadableStream | string; /** @internal */ export const StreamSpeechResponseResult$outboundSchema: z.ZodType< StreamSpeechResponseResult$Outbound, z.ZodTypeDef, StreamSpeechResponseResult > = z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), z.string(), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace StreamSpeechResponseResult$ { /** @deprecated use `StreamSpeechResponseResult$inboundSchema` instead. */ export const inboundSchema = StreamSpeechResponseResult$inboundSchema; /** @deprecated use `StreamSpeechResponseResult$outboundSchema` instead. */ export const outboundSchema = StreamSpeechResponseResult$outboundSchema; /** @deprecated use `StreamSpeechResponseResult$Outbound` instead. */ export type Outbound = StreamSpeechResponseResult$Outbound; } export function streamSpeechResponseResultToJSON( streamSpeechResponseResult: StreamSpeechResponseResult, ): string { return JSON.stringify( StreamSpeechResponseResult$outboundSchema.parse(streamSpeechResponseResult), ); } export function streamSpeechResponseResultFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => StreamSpeechResponseResult$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'StreamSpeechResponseResult' from JSON`, ); } /** @internal */ export const StreamSpeechResponse$inboundSchema: z.ZodType< StreamSpeechResponse, z.ZodTypeDef, unknown > = z.object({ Headers: z.record(z.array(z.string())), Result: z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), z.string(), ]), }).transform((v) => { return remap$(v, { "Headers": "headers", "Result": "result", }); }); /** @internal */ export type StreamSpeechResponse$Outbound = { Headers: { [k: string]: Array }; Result: ReadableStream | ReadableStream | string; }; /** @internal */ export const StreamSpeechResponse$outboundSchema: z.ZodType< StreamSpeechResponse$Outbound, z.ZodTypeDef, StreamSpeechResponse > = z.object({ headers: z.record(z.array(z.string())), result: z.union([ z.instanceof(ReadableStream), z.instanceof(ReadableStream), z.string(), ]), }).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 StreamSpeechResponse$ { /** @deprecated use `StreamSpeechResponse$inboundSchema` instead. */ export const inboundSchema = StreamSpeechResponse$inboundSchema; /** @deprecated use `StreamSpeechResponse$outboundSchema` instead. */ export const outboundSchema = StreamSpeechResponse$outboundSchema; /** @deprecated use `StreamSpeechResponse$Outbound` instead. */ export type Outbound = StreamSpeechResponse$Outbound; } export function streamSpeechResponseToJSON( streamSpeechResponse: StreamSpeechResponse, ): string { return JSON.stringify( StreamSpeechResponse$outboundSchema.parse(streamSpeechResponse), ); } export function streamSpeechResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => StreamSpeechResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'StreamSpeechResponse' from JSON`, ); }