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

import * as z from "zod/v3";
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";
import {
  AudioFormat,
  AudioFormat$inboundSchema,
  AudioFormat$Outbound,
  AudioFormat$outboundSchema,
} from "./audioformat.js";

export type RealtimeTranscriptionSession = {
  requestId: string;
  model: string;
  audioFormat: AudioFormat;
  targetStreamingDelayMs?: number | null | undefined;
};

/** @internal */
export const RealtimeTranscriptionSession$inboundSchema: z.ZodType<
  RealtimeTranscriptionSession,
  z.ZodTypeDef,
  unknown
> = z.object({
  request_id: z.string(),
  model: z.string(),
  audio_format: AudioFormat$inboundSchema,
  target_streaming_delay_ms: z.nullable(z.number().int()).optional(),
}).transform((v) => {
  return remap$(v, {
    "request_id": "requestId",
    "audio_format": "audioFormat",
    "target_streaming_delay_ms": "targetStreamingDelayMs",
  });
});
/** @internal */
export type RealtimeTranscriptionSession$Outbound = {
  request_id: string;
  model: string;
  audio_format: AudioFormat$Outbound;
  target_streaming_delay_ms?: number | null | undefined;
};

/** @internal */
export const RealtimeTranscriptionSession$outboundSchema: z.ZodType<
  RealtimeTranscriptionSession$Outbound,
  z.ZodTypeDef,
  RealtimeTranscriptionSession
> = z.object({
  requestId: z.string(),
  model: z.string(),
  audioFormat: AudioFormat$outboundSchema,
  targetStreamingDelayMs: z.nullable(z.number().int()).optional(),
}).transform((v) => {
  return remap$(v, {
    requestId: "request_id",
    audioFormat: "audio_format",
    targetStreamingDelayMs: "target_streaming_delay_ms",
  });
});

export function realtimeTranscriptionSessionToJSON(
  realtimeTranscriptionSession: RealtimeTranscriptionSession,
): string {
  return JSON.stringify(
    RealtimeTranscriptionSession$outboundSchema.parse(
      realtimeTranscriptionSession,
    ),
  );
}
export function realtimeTranscriptionSessionFromJSON(
  jsonString: string,
): SafeParseResult<RealtimeTranscriptionSession, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => RealtimeTranscriptionSession$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'RealtimeTranscriptionSession' from JSON`,
  );
}
