/* * 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 { SpeakerSegment, SpeakerSegment$inboundSchema, SpeakerSegment$Outbound, SpeakerSegment$outboundSchema, } from "./speakersegment.js"; /** * A stored speech-to-text transcription. */ export type SpeechToTextHistoryObject = { /** * Unique identifier for the history item. */ id: string; /** * The object type, always 'speech.transcription'. */ object: "speech.transcription"; /** * The transcribed text. */ text: string; /** * The detected or specified language code. */ language: string | null; /** * Confidence score from 0 to 1, when available. */ confidence: number | null; /** * The transcription model used. */ model: string; /** * The provider that produced the transcription. */ providerId: string | null; /** * Original filename of the input audio, when available. */ filename: string | null; /** * Size of the input audio in bytes. */ audioBytes: number; /** * MIME type of the stored input audio. */ audioMimeType: string | null; /** * Speaker diarization segments, when present. */ speakers: Array | null; /** * Whether the transcription came from the streaming WebSocket. */ streaming: boolean; /** * Arbitrary metadata stored with the item. */ metadata: { [k: string]: any }; /** * Unix timestamp (seconds) when the item was created. */ createdAt: number; }; /** @internal */ export const SpeechToTextHistoryObject$inboundSchema: z.ZodType< SpeechToTextHistoryObject, z.ZodTypeDef, unknown > = z.object({ id: z.string(), object: z.literal("speech.transcription"), text: z.string(), language: z.nullable(z.string()), confidence: z.nullable(z.number()), model: z.string(), provider_id: z.nullable(z.string()), filename: z.nullable(z.string()), audio_bytes: z.number().int(), audio_mime_type: z.nullable(z.string()), speakers: z.nullable(z.array(SpeakerSegment$inboundSchema)), streaming: z.boolean(), metadata: z.record(z.any()), created_at: z.number().int(), }).transform((v) => { return remap$(v, { "provider_id": "providerId", "audio_bytes": "audioBytes", "audio_mime_type": "audioMimeType", "created_at": "createdAt", }); }); /** @internal */ export type SpeechToTextHistoryObject$Outbound = { id: string; object: "speech.transcription"; text: string; language: string | null; confidence: number | null; model: string; provider_id: string | null; filename: string | null; audio_bytes: number; audio_mime_type: string | null; speakers: Array | null; streaming: boolean; metadata: { [k: string]: any }; created_at: number; }; /** @internal */ export const SpeechToTextHistoryObject$outboundSchema: z.ZodType< SpeechToTextHistoryObject$Outbound, z.ZodTypeDef, SpeechToTextHistoryObject > = z.object({ id: z.string(), object: z.literal("speech.transcription"), text: z.string(), language: z.nullable(z.string()), confidence: z.nullable(z.number()), model: z.string(), providerId: z.nullable(z.string()), filename: z.nullable(z.string()), audioBytes: z.number().int(), audioMimeType: z.nullable(z.string()), speakers: z.nullable(z.array(SpeakerSegment$outboundSchema)), streaming: z.boolean(), metadata: z.record(z.any()), createdAt: z.number().int(), }).transform((v) => { return remap$(v, { providerId: "provider_id", audioBytes: "audio_bytes", audioMimeType: "audio_mime_type", createdAt: "created_at", }); }); export function speechToTextHistoryObjectToJSON( speechToTextHistoryObject: SpeechToTextHistoryObject, ): string { return JSON.stringify( SpeechToTextHistoryObject$outboundSchema.parse(speechToTextHistoryObject), ); } export function speechToTextHistoryObjectFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SpeechToTextHistoryObject$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SpeechToTextHistoryObject' from JSON`, ); }