/* * 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 FileT = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; export type BodyTranscriptionsV1AudioTranscriptionsPost = { /** * 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: FileT | Blob; /** * The target language for transcription. The set of supported target languages can be found [here](https://github.com/openai/whisper/blob/ba3f3cd54b0e5b8ce1ab3de13e32122d0d5f98ab/whisper/tokenizer.py#L10-L128). */ language: string; /** * 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 FileT$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 FileT$Outbound = { fileName: string; content: ReadableStream | Blob | ArrayBuffer | Uint8Array; }; /** @internal */ export const FileT$outboundSchema: z.ZodType< FileT$Outbound, z.ZodTypeDef, FileT > = 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 FileT$ { /** @deprecated use `FileT$inboundSchema` instead. */ export const inboundSchema = FileT$inboundSchema; /** @deprecated use `FileT$outboundSchema` instead. */ export const outboundSchema = FileT$outboundSchema; /** @deprecated use `FileT$Outbound` instead. */ export type Outbound = FileT$Outbound; } export function fileToJSON(fileT: FileT): string { return JSON.stringify(FileT$outboundSchema.parse(fileT)); } export function fileFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FileT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FileT' from JSON`, ); } /** @internal */ export const BodyTranscriptionsV1AudioTranscriptionsPost$inboundSchema: z.ZodType< BodyTranscriptionsV1AudioTranscriptionsPost, z.ZodTypeDef, unknown > = z.object({ file: z.lazy(() => FileT$inboundSchema), language: z.string(), 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 BodyTranscriptionsV1AudioTranscriptionsPost$Outbound = { file: FileT$Outbound | Blob; language: string; alignment_model: string; model: string; prompt?: string | null | undefined; response_format: string; temperature: number; vad_model: string; }; /** @internal */ export const BodyTranscriptionsV1AudioTranscriptionsPost$outboundSchema: z.ZodType< BodyTranscriptionsV1AudioTranscriptionsPost$Outbound, z.ZodTypeDef, BodyTranscriptionsV1AudioTranscriptionsPost > = z.object({ file: z.lazy(() => FileT$outboundSchema).or(blobLikeSchema), language: z.string(), 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 BodyTranscriptionsV1AudioTranscriptionsPost$ { /** @deprecated use `BodyTranscriptionsV1AudioTranscriptionsPost$inboundSchema` instead. */ export const inboundSchema = BodyTranscriptionsV1AudioTranscriptionsPost$inboundSchema; /** @deprecated use `BodyTranscriptionsV1AudioTranscriptionsPost$outboundSchema` instead. */ export const outboundSchema = BodyTranscriptionsV1AudioTranscriptionsPost$outboundSchema; /** @deprecated use `BodyTranscriptionsV1AudioTranscriptionsPost$Outbound` instead. */ export type Outbound = BodyTranscriptionsV1AudioTranscriptionsPost$Outbound; } export function bodyTranscriptionsV1AudioTranscriptionsPostToJSON( bodyTranscriptionsV1AudioTranscriptionsPost: BodyTranscriptionsV1AudioTranscriptionsPost, ): string { return JSON.stringify( BodyTranscriptionsV1AudioTranscriptionsPost$outboundSchema.parse( bodyTranscriptionsV1AudioTranscriptionsPost, ), ); } export function bodyTranscriptionsV1AudioTranscriptionsPostFromJSON( jsonString: string, ): SafeParseResult< BodyTranscriptionsV1AudioTranscriptionsPost, SDKValidationError > { return safeParse( jsonString, (x) => BodyTranscriptionsV1AudioTranscriptionsPost$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'BodyTranscriptionsV1AudioTranscriptionsPost' from JSON`, ); }