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

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type TranscriptionStreamSegmentDelta = {
  type: "transcription.segment";
  text: string;
  start: number;
  end: number;
  speakerId?: string | null | undefined;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const TranscriptionStreamSegmentDelta$inboundSchema: z.ZodType<
  TranscriptionStreamSegmentDelta,
  unknown
> = z.object({
  type: z.literal("transcription.segment"),
  text: z.string(),
  start: z.number(),
  end: z.number(),
  speaker_id: z.nullable(z.string()).optional(),
}).catchall(z.any()).transform((v) => {
  return remap$(v, {
    "speaker_id": "speakerId",
  });
});

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