/* * 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"; /** * The language code of the text */ export const APIConvertTextToSpeechUsingCharacterRequestLanguage = { 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; /** * The language code of the text */ export type APIConvertTextToSpeechUsingCharacterRequestLanguage = ClosedEnum< typeof APIConvertTextToSpeechUsingCharacterRequestLanguage >; /** * The model type to use for the text-to-speech conversion */ export const APIConvertTextToSpeechUsingCharacterRequestModel = { 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 APIConvertTextToSpeechUsingCharacterRequestModel = ClosedEnum< typeof APIConvertTextToSpeechUsingCharacterRequestModel >; /** * The desired output format of the audio file (wav, mp3). Default is wav. */ export const APIConvertTextToSpeechUsingCharacterRequestOutputFormat = { Wav: "wav", Mp3: "mp3", } as const; /** * The desired output format of the audio file (wav, mp3). Default is wav. */ export type APIConvertTextToSpeechUsingCharacterRequestOutputFormat = ClosedEnum; export type APIConvertTextToSpeechUsingCharacterRequest = { /** * The text to convert to speech */ text: string; /** * The language code of the text */ language: APIConvertTextToSpeechUsingCharacterRequestLanguage; /** * 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?: APIConvertTextToSpeechUsingCharacterRequestModel | undefined; /** * The desired output format of the audio file (wav, mp3). Default is wav. */ outputFormat?: | APIConvertTextToSpeechUsingCharacterRequestOutputFormat | undefined; voiceSettings?: ConvertTextToSpeechParameters | undefined; /** * Return phoneme timing data with the audio */ includePhonemes?: boolean | undefined; /** * Pre-normalized text for TTS. Only used with sona_speech_2 and sona_speech_2_flash models. */ normalizedText?: string | undefined; }; /** @internal */ export const APIConvertTextToSpeechUsingCharacterRequestLanguage$inboundSchema: z.ZodNativeEnum = z.nativeEnum(APIConvertTextToSpeechUsingCharacterRequestLanguage); /** @internal */ export const APIConvertTextToSpeechUsingCharacterRequestLanguage$outboundSchema: z.ZodNativeEnum = APIConvertTextToSpeechUsingCharacterRequestLanguage$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace APIConvertTextToSpeechUsingCharacterRequestLanguage$ { /** @deprecated use `APIConvertTextToSpeechUsingCharacterRequestLanguage$inboundSchema` instead. */ export const inboundSchema = APIConvertTextToSpeechUsingCharacterRequestLanguage$inboundSchema; /** @deprecated use `APIConvertTextToSpeechUsingCharacterRequestLanguage$outboundSchema` instead. */ export const outboundSchema = APIConvertTextToSpeechUsingCharacterRequestLanguage$outboundSchema; } /** @internal */ export const APIConvertTextToSpeechUsingCharacterRequestModel$inboundSchema: z.ZodNativeEnum = z .nativeEnum(APIConvertTextToSpeechUsingCharacterRequestModel); /** @internal */ export const APIConvertTextToSpeechUsingCharacterRequestModel$outboundSchema: z.ZodNativeEnum = APIConvertTextToSpeechUsingCharacterRequestModel$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace APIConvertTextToSpeechUsingCharacterRequestModel$ { /** @deprecated use `APIConvertTextToSpeechUsingCharacterRequestModel$inboundSchema` instead. */ export const inboundSchema = APIConvertTextToSpeechUsingCharacterRequestModel$inboundSchema; /** @deprecated use `APIConvertTextToSpeechUsingCharacterRequestModel$outboundSchema` instead. */ export const outboundSchema = APIConvertTextToSpeechUsingCharacterRequestModel$outboundSchema; } /** @internal */ export const APIConvertTextToSpeechUsingCharacterRequestOutputFormat$inboundSchema: z.ZodNativeEnum< typeof APIConvertTextToSpeechUsingCharacterRequestOutputFormat > = z.nativeEnum(APIConvertTextToSpeechUsingCharacterRequestOutputFormat); /** @internal */ export const APIConvertTextToSpeechUsingCharacterRequestOutputFormat$outboundSchema: z.ZodNativeEnum< typeof APIConvertTextToSpeechUsingCharacterRequestOutputFormat > = APIConvertTextToSpeechUsingCharacterRequestOutputFormat$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace APIConvertTextToSpeechUsingCharacterRequestOutputFormat$ { /** @deprecated use `APIConvertTextToSpeechUsingCharacterRequestOutputFormat$inboundSchema` instead. */ export const inboundSchema = APIConvertTextToSpeechUsingCharacterRequestOutputFormat$inboundSchema; /** @deprecated use `APIConvertTextToSpeechUsingCharacterRequestOutputFormat$outboundSchema` instead. */ export const outboundSchema = APIConvertTextToSpeechUsingCharacterRequestOutputFormat$outboundSchema; } /** @internal */ export const APIConvertTextToSpeechUsingCharacterRequest$inboundSchema: z.ZodType< APIConvertTextToSpeechUsingCharacterRequest, z.ZodTypeDef, unknown > = z.object({ text: z.string(), language: APIConvertTextToSpeechUsingCharacterRequestLanguage$inboundSchema, style: z.string().optional(), model: APIConvertTextToSpeechUsingCharacterRequestModel$inboundSchema .default("sona_speech_1"), output_format: APIConvertTextToSpeechUsingCharacterRequestOutputFormat$inboundSchema .default("wav"), voice_settings: ConvertTextToSpeechParameters$inboundSchema.optional(), include_phonemes: z.boolean().default(false), normalized_text: z.string().optional(), }).transform((v) => { return remap$(v, { "output_format": "outputFormat", "voice_settings": "voiceSettings", "include_phonemes": "includePhonemes", "normalized_text": "normalizedText", }); }); /** @internal */ export type APIConvertTextToSpeechUsingCharacterRequest$Outbound = { text: string; language: string; style?: string | undefined; model: string; output_format: string; voice_settings?: ConvertTextToSpeechParameters$Outbound | undefined; include_phonemes: boolean; normalized_text?: string | undefined; }; /** @internal */ export const APIConvertTextToSpeechUsingCharacterRequest$outboundSchema: z.ZodType< APIConvertTextToSpeechUsingCharacterRequest$Outbound, z.ZodTypeDef, APIConvertTextToSpeechUsingCharacterRequest > = z.object({ text: z.string(), language: APIConvertTextToSpeechUsingCharacterRequestLanguage$outboundSchema, style: z.string().optional(), model: APIConvertTextToSpeechUsingCharacterRequestModel$outboundSchema .default("sona_speech_1"), outputFormat: APIConvertTextToSpeechUsingCharacterRequestOutputFormat$outboundSchema .default("wav"), voiceSettings: ConvertTextToSpeechParameters$outboundSchema.optional(), includePhonemes: z.boolean().default(false), normalizedText: z.string().optional(), }).transform((v) => { return remap$(v, { outputFormat: "output_format", voiceSettings: "voice_settings", includePhonemes: "include_phonemes", normalizedText: "normalized_text", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace APIConvertTextToSpeechUsingCharacterRequest$ { /** @deprecated use `APIConvertTextToSpeechUsingCharacterRequest$inboundSchema` instead. */ export const inboundSchema = APIConvertTextToSpeechUsingCharacterRequest$inboundSchema; /** @deprecated use `APIConvertTextToSpeechUsingCharacterRequest$outboundSchema` instead. */ export const outboundSchema = APIConvertTextToSpeechUsingCharacterRequest$outboundSchema; /** @deprecated use `APIConvertTextToSpeechUsingCharacterRequest$Outbound` instead. */ export type Outbound = APIConvertTextToSpeechUsingCharacterRequest$Outbound; } export function apiConvertTextToSpeechUsingCharacterRequestToJSON( apiConvertTextToSpeechUsingCharacterRequest: APIConvertTextToSpeechUsingCharacterRequest, ): string { return JSON.stringify( APIConvertTextToSpeechUsingCharacterRequest$outboundSchema.parse( apiConvertTextToSpeechUsingCharacterRequest, ), ); } export function apiConvertTextToSpeechUsingCharacterRequestFromJSON( jsonString: string, ): SafeParseResult< APIConvertTextToSpeechUsingCharacterRequest, SDKValidationError > { return safeParse( jsonString, (x) => APIConvertTextToSpeechUsingCharacterRequest$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'APIConvertTextToSpeechUsingCharacterRequest' from JSON`, ); }