/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { SpeakerSegment, SpeakerSegment$inboundSchema, SpeakerSegment$Outbound, SpeakerSegment$outboundSchema, } from "./speakersegment.js"; /** * Response from the transcription endpoint containing the transcribed text, detected language, confidence score, and optional speaker segments. */ export type TranscriptionResponse = { /** * The transcribed text from the audio file */ text: string; /** * The detected or specified language code in ISO-639-1 format (e.g., 'en', 'es', 'fr') */ language?: string | undefined; /** * Confidence score from 0 to 1 where 1 indicates highest confidence in transcription accuracy */ confidence?: number | undefined; /** * Speaker diarization segments, returned only when include_speaker_data is true. */ speakers?: Array | undefined; }; /** @internal */ export const TranscriptionResponse$inboundSchema: z.ZodType< TranscriptionResponse, z.ZodTypeDef, unknown > = z.object({ text: z.string(), language: z.string().optional(), confidence: z.number().optional(), speakers: z.array(SpeakerSegment$inboundSchema).optional(), }); /** @internal */ export type TranscriptionResponse$Outbound = { text: string; language?: string | undefined; confidence?: number | undefined; speakers?: Array | undefined; }; /** @internal */ export const TranscriptionResponse$outboundSchema: z.ZodType< TranscriptionResponse$Outbound, z.ZodTypeDef, TranscriptionResponse > = z.object({ text: z.string(), language: z.string().optional(), confidence: z.number().optional(), speakers: z.array(SpeakerSegment$outboundSchema).optional(), }); export function transcriptionResponseToJSON( transcriptionResponse: TranscriptionResponse, ): string { return JSON.stringify( TranscriptionResponse$outboundSchema.parse(transcriptionResponse), ); } export function transcriptionResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TranscriptionResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TranscriptionResponse' from JSON`, ); }