/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 43871ae3ebde
 */

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  TranscriptionSegmentChunk,
  TranscriptionSegmentChunk$inboundSchema,
} from "./transcriptionsegmentchunk.js";
import { UsageInfo, UsageInfo$inboundSchema } from "./usageinfo.js";

export type TranscriptionResponse = {
  model: string;
  text: string;
  segments?: Array<TranscriptionSegmentChunk> | undefined;
  usage: UsageInfo;
  language: string | null;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const TranscriptionResponse$inboundSchema: z.ZodType<
  TranscriptionResponse,
  unknown
> = z.object({
  model: z.string(),
  text: z.string(),
  segments: z.array(TranscriptionSegmentChunk$inboundSchema).optional(),
  usage: UsageInfo$inboundSchema,
  language: z.nullable(z.string()),
}).catchall(z.any());

export function transcriptionResponseFromJSON(
  jsonString: string,
): SafeParseResult<TranscriptionResponse, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => TranscriptionResponse$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'TranscriptionResponse' from JSON`,
  );
}
