/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Language code: 'auto' for automatic detection, or ISO 639-1 language codes */ export const TextToSpeechStreamingRequestLanguage = { Auto: "auto", En: "en", Zh: "zh", Hi: "hi", Es: "es", Ar: "ar", Bn: "bn", Pt: "pt", Ru: "ru", Ja: "ja", Pa: "pa", De: "de", Ko: "ko", Fr: "fr", Tr: "tr", It: "it", Th: "th", Pl: "pl", Nl: "nl", Id: "id", Vi: "vi", Ur: "ur", } as const; /** * Language code: 'auto' for automatic detection, or ISO 639-1 language codes */ export type TextToSpeechStreamingRequestLanguage = ClosedEnum< typeof TextToSpeechStreamingRequestLanguage >; /** * Audio output format: 'mp3' for MPEG audio (default), or 'pcm' for uncompressed PCM/WAV (24kHz, 16-bit, mono) */ export const Format = { Mp3: "mp3", Pcm: "pcm", } as const; /** * Audio output format: 'mp3' for MPEG audio (default), or 'pcm' for uncompressed PCM/WAV (24kHz, 16-bit, mono) */ export type Format = ClosedEnum; /** * Request parameters for streaming text-to-speech conversion with language selection and format options. */ export type TextToSpeechStreamingRequest = { /** * Input text to convert to speech */ text: string; /** * Language code: 'auto' for automatic detection, or ISO 639-1 language codes */ language?: TextToSpeechStreamingRequestLanguage | undefined; /** * TTS model identifier. Defaults to 'auto', which selects the default provider. Registry-resolvable ids dispatch to the matching provider. */ model?: string | undefined; /** * When true, persist this generation (input text, parameters, and the generated audio) to text-to-speech history. Defaults to false. */ store?: boolean | undefined; /** * Audio output format: 'mp3' for MPEG audio (default), or 'pcm' for uncompressed PCM/WAV (24kHz, 16-bit, mono) */ format?: Format | undefined; }; /** @internal */ export const TextToSpeechStreamingRequestLanguage$inboundSchema: z.ZodNativeEnum = z.nativeEnum( TextToSpeechStreamingRequestLanguage, ); /** @internal */ export const TextToSpeechStreamingRequestLanguage$outboundSchema: z.ZodNativeEnum = TextToSpeechStreamingRequestLanguage$inboundSchema; /** @internal */ export const Format$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Format); /** @internal */ export const Format$outboundSchema: z.ZodNativeEnum = Format$inboundSchema; /** @internal */ export const TextToSpeechStreamingRequest$inboundSchema: z.ZodType< TextToSpeechStreamingRequest, z.ZodTypeDef, unknown > = z.object({ text: z.string(), language: TextToSpeechStreamingRequestLanguage$inboundSchema.default("auto"), model: z.string().default("auto"), store: z.boolean().default(false), format: Format$inboundSchema.default("mp3"), }); /** @internal */ export type TextToSpeechStreamingRequest$Outbound = { text: string; language: string; model: string; store: boolean; format: string; }; /** @internal */ export const TextToSpeechStreamingRequest$outboundSchema: z.ZodType< TextToSpeechStreamingRequest$Outbound, z.ZodTypeDef, TextToSpeechStreamingRequest > = z.object({ text: z.string(), language: TextToSpeechStreamingRequestLanguage$outboundSchema.default("auto"), model: z.string().default("auto"), store: z.boolean().default(false), format: Format$outboundSchema.default("mp3"), }); export function textToSpeechStreamingRequestToJSON( textToSpeechStreamingRequest: TextToSpeechStreamingRequest, ): string { return JSON.stringify( TextToSpeechStreamingRequest$outboundSchema.parse( textToSpeechStreamingRequest, ), ); } export function textToSpeechStreamingRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TextToSpeechStreamingRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TextToSpeechStreamingRequest' from JSON`, ); }