/* * 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 { blobLikeSchema } from "../../types/blobs.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type Audio = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; export type BodyGenAudioToText = { /** * Uploaded audio file to be transcribed. */ audio: Audio | Blob; /** * Hugging Face model ID used for transcription. */ modelId?: string | undefined; /** * Return timestamps for the transcribed text. Supported values: 'sentence', 'word', or a string boolean ('true' or 'false'). Default is 'true' ('sentence'). 'false' means no timestamps. 'word' means word-based timestamps. */ returnTimestamps?: string | undefined; }; /** @internal */ export const Audio$inboundSchema: z.ZodType = z .object({ fileName: z.string(), content: z.union([ z.instanceof(ReadableStream), z.instanceof(Blob), z.instanceof(ArrayBuffer), z.instanceof(Uint8Array), ]), }); /** @internal */ export type Audio$Outbound = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; /** @internal */ export const Audio$outboundSchema: z.ZodType< Audio$Outbound, z.ZodTypeDef, Audio > = z.object({ fileName: z.string(), content: z.union([ z.instanceof(ReadableStream), z.instanceof(Blob), z.instanceof(ArrayBuffer), z.instanceof(Uint8Array), ]), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Audio$ { /** @deprecated use `Audio$inboundSchema` instead. */ export const inboundSchema = Audio$inboundSchema; /** @deprecated use `Audio$outboundSchema` instead. */ export const outboundSchema = Audio$outboundSchema; /** @deprecated use `Audio$Outbound` instead. */ export type Outbound = Audio$Outbound; } export function audioToJSON(audio: Audio): string { return JSON.stringify(Audio$outboundSchema.parse(audio)); } export function audioFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Audio$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Audio' from JSON`, ); } /** @internal */ export const BodyGenAudioToText$inboundSchema: z.ZodType< BodyGenAudioToText, z.ZodTypeDef, unknown > = z.object({ audio: z.lazy(() => Audio$inboundSchema), model_id: z.string().default("openai/whisper-large-v3"), return_timestamps: z.string().default("true"), }).transform((v) => { return remap$(v, { "model_id": "modelId", "return_timestamps": "returnTimestamps", }); }); /** @internal */ export type BodyGenAudioToText$Outbound = { audio: Audio$Outbound | Blob; model_id: string; return_timestamps: string; }; /** @internal */ export const BodyGenAudioToText$outboundSchema: z.ZodType< BodyGenAudioToText$Outbound, z.ZodTypeDef, BodyGenAudioToText > = z.object({ audio: z.lazy(() => Audio$outboundSchema).or(blobLikeSchema), modelId: z.string().default("openai/whisper-large-v3"), returnTimestamps: z.string().default("true"), }).transform((v) => { return remap$(v, { modelId: "model_id", returnTimestamps: "return_timestamps", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BodyGenAudioToText$ { /** @deprecated use `BodyGenAudioToText$inboundSchema` instead. */ export const inboundSchema = BodyGenAudioToText$inboundSchema; /** @deprecated use `BodyGenAudioToText$outboundSchema` instead. */ export const outboundSchema = BodyGenAudioToText$outboundSchema; /** @deprecated use `BodyGenAudioToText$Outbound` instead. */ export type Outbound = BodyGenAudioToText$Outbound; } export function bodyGenAudioToTextToJSON( bodyGenAudioToText: BodyGenAudioToText, ): string { return JSON.stringify( BodyGenAudioToText$outboundSchema.parse(bodyGenAudioToText), ); } export function bodyGenAudioToTextFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BodyGenAudioToText$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BodyGenAudioToText' from JSON`, ); }