/* * 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 { ClosedEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { ConvertTextToSpeechParameters, ConvertTextToSpeechParameters$inboundSchema, ConvertTextToSpeechParameters$Outbound, ConvertTextToSpeechParameters$outboundSchema, } from "./converttexttospeechparameters.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; /** * Language code of the voice */ export const PredictTTSDurationRequestLanguage = { En: "en", Ko: "ko", Ja: "ja", Bg: "bg", Cs: "cs", Da: "da", El: "el", Es: "es", Et: "et", Fi: "fi", Hu: "hu", It: "it", Nl: "nl", Pl: "pl", Pt: "pt", Ro: "ro", Ar: "ar", De: "de", Fr: "fr", Hi: "hi", Id: "id", Ru: "ru", Vi: "vi", Hr: "hr", Lt: "lt", Lv: "lv", Sk: "sk", Sl: "sl", Sv: "sv", Tr: "tr", Uk: "uk", } as const; /** * Language code of the voice */ export type PredictTTSDurationRequestLanguage = ClosedEnum< typeof PredictTTSDurationRequestLanguage >; /** * The model type to use for the text-to-speech conversion */ export const PredictTTSDurationRequestModel = { SonaSpeech1: "sona_speech_1", SonaSpeech2: "sona_speech_2", SonaSpeech2t: "sona_speech_2t", SonaSpeech2Flash: "sona_speech_2_flash", SupertonicApi1: "supertonic_api_1", SonaSpeech3t: "sona_speech_3t", SupertonicApi3: "supertonic_api_3", } as const; /** * The model type to use for the text-to-speech conversion */ export type PredictTTSDurationRequestModel = ClosedEnum< typeof PredictTTSDurationRequestModel >; /** * The desired output format of the audio file (wav, mp3). Default is wav. */ export const PredictTTSDurationRequestOutputFormat = { Wav: "wav", Mp3: "mp3", } as const; /** * The desired output format of the audio file (wav, mp3). Default is wav. */ export type PredictTTSDurationRequestOutputFormat = ClosedEnum< typeof PredictTTSDurationRequestOutputFormat >; export type PredictTTSDurationRequest = { /** * The text to convert to speech. Max length is 300 characters. */ text: string; /** * Language code of the voice */ language: PredictTTSDurationRequestLanguage; /** * The style of character to use for the text-to-speech conversion */ style?: string | undefined; /** * The model type to use for the text-to-speech conversion */ model?: PredictTTSDurationRequestModel | undefined; /** * The desired output format of the audio file (wav, mp3). Default is wav. */ outputFormat?: PredictTTSDurationRequestOutputFormat | undefined; voiceSettings?: ConvertTextToSpeechParameters | undefined; }; /** @internal */ export const PredictTTSDurationRequestLanguage$inboundSchema: z.ZodNativeEnum< typeof PredictTTSDurationRequestLanguage > = z.nativeEnum(PredictTTSDurationRequestLanguage); /** @internal */ export const PredictTTSDurationRequestLanguage$outboundSchema: z.ZodNativeEnum< typeof PredictTTSDurationRequestLanguage > = PredictTTSDurationRequestLanguage$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PredictTTSDurationRequestLanguage$ { /** @deprecated use `PredictTTSDurationRequestLanguage$inboundSchema` instead. */ export const inboundSchema = PredictTTSDurationRequestLanguage$inboundSchema; /** @deprecated use `PredictTTSDurationRequestLanguage$outboundSchema` instead. */ export const outboundSchema = PredictTTSDurationRequestLanguage$outboundSchema; } /** @internal */ export const PredictTTSDurationRequestModel$inboundSchema: z.ZodNativeEnum< typeof PredictTTSDurationRequestModel > = z.nativeEnum(PredictTTSDurationRequestModel); /** @internal */ export const PredictTTSDurationRequestModel$outboundSchema: z.ZodNativeEnum< typeof PredictTTSDurationRequestModel > = PredictTTSDurationRequestModel$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PredictTTSDurationRequestModel$ { /** @deprecated use `PredictTTSDurationRequestModel$inboundSchema` instead. */ export const inboundSchema = PredictTTSDurationRequestModel$inboundSchema; /** @deprecated use `PredictTTSDurationRequestModel$outboundSchema` instead. */ export const outboundSchema = PredictTTSDurationRequestModel$outboundSchema; } /** @internal */ export const PredictTTSDurationRequestOutputFormat$inboundSchema: z.ZodNativeEnum = z.nativeEnum( PredictTTSDurationRequestOutputFormat, ); /** @internal */ export const PredictTTSDurationRequestOutputFormat$outboundSchema: z.ZodNativeEnum = PredictTTSDurationRequestOutputFormat$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PredictTTSDurationRequestOutputFormat$ { /** @deprecated use `PredictTTSDurationRequestOutputFormat$inboundSchema` instead. */ export const inboundSchema = PredictTTSDurationRequestOutputFormat$inboundSchema; /** @deprecated use `PredictTTSDurationRequestOutputFormat$outboundSchema` instead. */ export const outboundSchema = PredictTTSDurationRequestOutputFormat$outboundSchema; } /** @internal */ export const PredictTTSDurationRequest$inboundSchema: z.ZodType< PredictTTSDurationRequest, z.ZodTypeDef, unknown > = z.object({ text: z.string(), language: PredictTTSDurationRequestLanguage$inboundSchema, style: z.string().optional(), model: PredictTTSDurationRequestModel$inboundSchema.default("sona_speech_1"), output_format: PredictTTSDurationRequestOutputFormat$inboundSchema.default( "wav", ), voice_settings: ConvertTextToSpeechParameters$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "output_format": "outputFormat", "voice_settings": "voiceSettings", }); }); /** @internal */ export type PredictTTSDurationRequest$Outbound = { text: string; language: string; style?: string | undefined; model: string; output_format: string; voice_settings?: ConvertTextToSpeechParameters$Outbound | undefined; }; /** @internal */ export const PredictTTSDurationRequest$outboundSchema: z.ZodType< PredictTTSDurationRequest$Outbound, z.ZodTypeDef, PredictTTSDurationRequest > = z.object({ text: z.string(), language: PredictTTSDurationRequestLanguage$outboundSchema, style: z.string().optional(), model: PredictTTSDurationRequestModel$outboundSchema.default("sona_speech_1"), outputFormat: PredictTTSDurationRequestOutputFormat$outboundSchema.default( "wav", ), voiceSettings: ConvertTextToSpeechParameters$outboundSchema.optional(), }).transform((v) => { return remap$(v, { outputFormat: "output_format", voiceSettings: "voice_settings", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PredictTTSDurationRequest$ { /** @deprecated use `PredictTTSDurationRequest$inboundSchema` instead. */ export const inboundSchema = PredictTTSDurationRequest$inboundSchema; /** @deprecated use `PredictTTSDurationRequest$outboundSchema` instead. */ export const outboundSchema = PredictTTSDurationRequest$outboundSchema; /** @deprecated use `PredictTTSDurationRequest$Outbound` instead. */ export type Outbound = PredictTTSDurationRequest$Outbound; } export function predictTTSDurationRequestToJSON( predictTTSDurationRequest: PredictTTSDurationRequest, ): string { return JSON.stringify( PredictTTSDurationRequest$outboundSchema.parse(predictTTSDurationRequest), ); } export function predictTTSDurationRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PredictTTSDurationRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PredictTTSDurationRequest' from JSON`, ); }