/* * 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 "./sdkvalidationerror.js"; export type BodyTranslationsV1AudioTranslationsPostFile = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; export type BodyTranslationsV1AudioTranslationsPost = { /** * The input audio file to transcribe. Common file formats such as mp3, flac, and wav are supported. Note that the audio will be resampled to 16kHz, downmixed to mono, and reformatted to 16-bit signed little-endian format before transcription. Pre-converting the file before sending it to the API can improve runtime performance. */ file: BodyTranslationsV1AudioTranslationsPostFile | Blob; /** * The model used for alignment. */ alignmentModel?: string | undefined; /** * String name of the ASR model to use. Currently "whisper-v3" is supported. */ model?: string | undefined; /** * The input prompt with which to prime transcription. This can be used, for example, to continue a prior transcription given new audio data. */ prompt?: string | null | undefined; /** * The format in which to return the response. Can be one of `json`, `text`, `srt`, `verbose_json`, or `vtt`. */ responseFormat?: string | undefined; /** * Sampling temperature to use when decoding text tokens during transcription. */ temperature?: number | undefined; /** * The Voice Activity Detection model to use. */ vadModel?: string | undefined; }; /** @internal */ export const BodyTranslationsV1AudioTranslationsPostFile$inboundSchema: z.ZodType< BodyTranslationsV1AudioTranslationsPostFile, z.ZodTypeDef, unknown > = z.object({ fileName: z.string(), content: z.union([ z.instanceof(ReadableStream), z.instanceof(Blob), z.instanceof(ArrayBuffer), z.instanceof(Uint8Array), ]), }); /** @internal */ export type BodyTranslationsV1AudioTranslationsPostFile$Outbound = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; /** @internal */ export const BodyTranslationsV1AudioTranslationsPostFile$outboundSchema: z.ZodType< BodyTranslationsV1AudioTranslationsPostFile$Outbound, z.ZodTypeDef, BodyTranslationsV1AudioTranslationsPostFile > = 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 BodyTranslationsV1AudioTranslationsPostFile$ { /** @deprecated use `BodyTranslationsV1AudioTranslationsPostFile$inboundSchema` instead. */ export const inboundSchema = BodyTranslationsV1AudioTranslationsPostFile$inboundSchema; /** @deprecated use `BodyTranslationsV1AudioTranslationsPostFile$outboundSchema` instead. */ export const outboundSchema = BodyTranslationsV1AudioTranslationsPostFile$outboundSchema; /** @deprecated use `BodyTranslationsV1AudioTranslationsPostFile$Outbound` instead. */ export type Outbound = BodyTranslationsV1AudioTranslationsPostFile$Outbound; } export function bodyTranslationsV1AudioTranslationsPostFileToJSON( bodyTranslationsV1AudioTranslationsPostFile: BodyTranslationsV1AudioTranslationsPostFile, ): string { return JSON.stringify( BodyTranslationsV1AudioTranslationsPostFile$outboundSchema.parse( bodyTranslationsV1AudioTranslationsPostFile, ), ); } export function bodyTranslationsV1AudioTranslationsPostFileFromJSON( jsonString: string, ): SafeParseResult< BodyTranslationsV1AudioTranslationsPostFile, SDKValidationError > { return safeParse( jsonString, (x) => BodyTranslationsV1AudioTranslationsPostFile$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'BodyTranslationsV1AudioTranslationsPostFile' from JSON`, ); } /** @internal */ export const BodyTranslationsV1AudioTranslationsPost$inboundSchema: z.ZodType< BodyTranslationsV1AudioTranslationsPost, z.ZodTypeDef, unknown > = z.object({ file: z.lazy(() => BodyTranslationsV1AudioTranslationsPostFile$inboundSchema), alignment_model: z.string().default("mms_fa"), model: z.string().default("whisper-v3"), prompt: z.nullable(z.string()).optional(), response_format: z.string().default("json"), temperature: z.number().default(0), vad_model: z.string().default("silero"), }).transform((v) => { return remap$(v, { "alignment_model": "alignmentModel", "response_format": "responseFormat", "vad_model": "vadModel", }); }); /** @internal */ export type BodyTranslationsV1AudioTranslationsPost$Outbound = { file: BodyTranslationsV1AudioTranslationsPostFile$Outbound | Blob; alignment_model: string; model: string; prompt?: string | null | undefined; response_format: string; temperature: number; vad_model: string; }; /** @internal */ export const BodyTranslationsV1AudioTranslationsPost$outboundSchema: z.ZodType< BodyTranslationsV1AudioTranslationsPost$Outbound, z.ZodTypeDef, BodyTranslationsV1AudioTranslationsPost > = z.object({ file: z.lazy(() => BodyTranslationsV1AudioTranslationsPostFile$outboundSchema) .or(blobLikeSchema), alignmentModel: z.string().default("mms_fa"), model: z.string().default("whisper-v3"), prompt: z.nullable(z.string()).optional(), responseFormat: z.string().default("json"), temperature: z.number().default(0), vadModel: z.string().default("silero"), }).transform((v) => { return remap$(v, { alignmentModel: "alignment_model", responseFormat: "response_format", vadModel: "vad_model", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BodyTranslationsV1AudioTranslationsPost$ { /** @deprecated use `BodyTranslationsV1AudioTranslationsPost$inboundSchema` instead. */ export const inboundSchema = BodyTranslationsV1AudioTranslationsPost$inboundSchema; /** @deprecated use `BodyTranslationsV1AudioTranslationsPost$outboundSchema` instead. */ export const outboundSchema = BodyTranslationsV1AudioTranslationsPost$outboundSchema; /** @deprecated use `BodyTranslationsV1AudioTranslationsPost$Outbound` instead. */ export type Outbound = BodyTranslationsV1AudioTranslationsPost$Outbound; } export function bodyTranslationsV1AudioTranslationsPostToJSON( bodyTranslationsV1AudioTranslationsPost: BodyTranslationsV1AudioTranslationsPost, ): string { return JSON.stringify( BodyTranslationsV1AudioTranslationsPost$outboundSchema.parse( bodyTranslationsV1AudioTranslationsPost, ), ); } export function bodyTranslationsV1AudioTranslationsPostFromJSON( jsonString: string, ): SafeParseResult< BodyTranslationsV1AudioTranslationsPost, SDKValidationError > { return safeParse( jsonString, (x) => BodyTranslationsV1AudioTranslationsPost$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'BodyTranslationsV1AudioTranslationsPost' from JSON`, ); }