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

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { blobLikeSchema } from "../../types/blobs.js";
import { FileT, FileT$Outbound, FileT$outboundSchema } from "./file.js";
import {
  TimestampGranularity,
  TimestampGranularity$outboundSchema,
} from "./timestampgranularity.js";

export type AudioTranscriptionRequest = {
  /**
   * ID of the model to be used.
   */
  model: string;
  file?: FileT | Blob | undefined;
  /**
   * Url of a file to be transcribed
   */
  fileUrl?: string | null | undefined;
  /**
   * ID of a file uploaded to /v1/files
   */
  fileId?: string | null | undefined;
  /**
   * Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
   */
  language?: string | null | undefined;
  temperature?: number | null | undefined;
  stream?: false | undefined;
  diarize?: boolean | undefined;
  contextBias?: Array<string> | undefined;
  /**
   * Granularities of timestamps to include in the response.
   */
  timestampGranularities?: Array<TimestampGranularity> | undefined;
};

/** @internal */
export type AudioTranscriptionRequest$Outbound = {
  model: string;
  file?: FileT$Outbound | Blob | undefined;
  file_url?: string | null | undefined;
  file_id?: string | null | undefined;
  language?: string | null | undefined;
  temperature?: number | null | undefined;
  stream: false;
  diarize: boolean;
  context_bias?: Array<string> | undefined;
  timestamp_granularities?: Array<string> | undefined;
};

/** @internal */
export const AudioTranscriptionRequest$outboundSchema: z.ZodType<
  AudioTranscriptionRequest$Outbound,
  AudioTranscriptionRequest
> = z.object({
  model: z.string(),
  file: FileT$outboundSchema.or(blobLikeSchema).optional(),
  fileUrl: z.nullable(z.string()).optional(),
  fileId: z.nullable(z.string()).optional(),
  language: z.nullable(z.string()).optional(),
  temperature: z.nullable(z.number()).optional(),
  stream: z.literal(false).default(false as const),
  diarize: z.boolean().default(false),
  contextBias: z.array(z.string()).optional(),
  timestampGranularities: z.array(TimestampGranularity$outboundSchema)
    .optional(),
}).transform((v) => {
  return remap$(v, {
    fileUrl: "file_url",
    fileId: "file_id",
    contextBias: "context_bias",
    timestampGranularities: "timestamp_granularities",
  });
});

export function audioTranscriptionRequestToJSON(
  audioTranscriptionRequest: AudioTranscriptionRequest,
): string {
  return JSON.stringify(
    AudioTranscriptionRequest$outboundSchema.parse(audioTranscriptionRequest),
  );
}
