/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; 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"; /** * A stored text-to-speech generation. */ export type TextToSpeechHistoryObject = { /** * Unique identifier for the history item. */ id: string; /** * The object type, always 'speech.tts'. */ object: "speech.tts"; /** * The input text that was synthesized. */ text: string; /** * The requested language ('auto' or an ISO 639-1 code). */ language: string; /** * The language actually used for synthesis. */ detectedLanguage: string | null; /** * The TTS model used. */ model: string; /** * The provider that produced the audio. */ providerId: string | null; /** * Audio format of the stored output (wav, mp3, or pcm). */ format: string; /** * Size of the generated audio in bytes. */ audioBytes: number; /** * Number of characters in the input text. */ characters: number; /** * Whether the audio was produced via the streaming endpoint. */ streaming: boolean; /** * Arbitrary metadata stored with the item. */ metadata: { [k: string]: any }; /** * Unix timestamp (seconds) when the item was created. */ createdAt: number; }; /** @internal */ export const TextToSpeechHistoryObject$inboundSchema: z.ZodType< TextToSpeechHistoryObject, z.ZodTypeDef, unknown > = z.object({ id: z.string(), object: z.literal("speech.tts"), text: z.string(), language: z.string(), detected_language: z.nullable(z.string()), model: z.string(), provider_id: z.nullable(z.string()), format: z.string(), audio_bytes: z.number().int(), characters: z.number().int(), streaming: z.boolean(), metadata: z.record(z.any()), created_at: z.number().int(), }).transform((v) => { return remap$(v, { "detected_language": "detectedLanguage", "provider_id": "providerId", "audio_bytes": "audioBytes", "created_at": "createdAt", }); }); /** @internal */ export type TextToSpeechHistoryObject$Outbound = { id: string; object: "speech.tts"; text: string; language: string; detected_language: string | null; model: string; provider_id: string | null; format: string; audio_bytes: number; characters: number; streaming: boolean; metadata: { [k: string]: any }; created_at: number; }; /** @internal */ export const TextToSpeechHistoryObject$outboundSchema: z.ZodType< TextToSpeechHistoryObject$Outbound, z.ZodTypeDef, TextToSpeechHistoryObject > = z.object({ id: z.string(), object: z.literal("speech.tts"), text: z.string(), language: z.string(), detectedLanguage: z.nullable(z.string()), model: z.string(), providerId: z.nullable(z.string()), format: z.string(), audioBytes: z.number().int(), characters: z.number().int(), streaming: z.boolean(), metadata: z.record(z.any()), createdAt: z.number().int(), }).transform((v) => { return remap$(v, { detectedLanguage: "detected_language", providerId: "provider_id", audioBytes: "audio_bytes", createdAt: "created_at", }); }); export function textToSpeechHistoryObjectToJSON( textToSpeechHistoryObject: TextToSpeechHistoryObject, ): string { return JSON.stringify( TextToSpeechHistoryObject$outboundSchema.parse(textToSpeechHistoryObject), ); } export function textToSpeechHistoryObjectFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TextToSpeechHistoryObject$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TextToSpeechHistoryObject' from JSON`, ); }