/*
 * 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 { blobLikeSchema } from "../../types/blobs.js";
import { FileT, FileT$Outbound, FileT$outboundSchema } from "./file.js";
import {
  TimestampGranularity,
  TimestampGranularity$outboundSchema,
} from "./timestampgranularity.js";

export type AudioTranscriptionRequestStream = {
  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?: true | undefined;
  diarize?: boolean | undefined;
  contextBias?: Array<string> | undefined;
  /**
   * Granularities of timestamps to include in the response.
   */
  timestampGranularities?: Array<TimestampGranularity> | undefined;
};

/** @internal */
export type AudioTranscriptionRequestStream$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: true;
  diarize: boolean;
  context_bias?: Array<string> | undefined;
  timestamp_granularities?: Array<string> | undefined;
};

/** @internal */
export const AudioTranscriptionRequestStream$outboundSchema: z.ZodType<
  AudioTranscriptionRequestStream$Outbound,
  z.ZodTypeDef,
  AudioTranscriptionRequestStream
> = 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(true).default(true 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 audioTranscriptionRequestStreamToJSON(
  audioTranscriptionRequestStream: AudioTranscriptionRequestStream,
): string {
  return JSON.stringify(
    AudioTranscriptionRequestStream$outboundSchema.parse(
      audioTranscriptionRequestStream,
    ),
  );
}
