import { UseGenerationOptions, UseGenerationReturn } from "./use-generation.js"; import { Accessor } from "solid-js"; import { AIDevtoolsDisplayOptions, ConnectConnectionAdapter, GenerationClientState, GenerationFetcher, GenerationPersistenceOptions, InferGenerationOutputFromReturn, TranscriptionGenerateInput } from "@tanstack/ai-client"; import { StreamChunk, TranscriptionResult } from "@tanstack/ai"; //#region src/use-transcription.d.ts /** * Options for the useTranscription hook. * * @template TOutput - The transformed output type (defaults to TranscriptionResult) */ interface UseTranscriptionOptions extends Pick, 'persistence' | 'threadId' | 'hydrateGeneration' | 'joinRun' | 'byok' | 'byokProvider'> { /** Connect-based adapter for streaming transport (SSE, HTTP stream, custom) */ connection?: ConnectConnectionAdapter; /** Direct async function for transcription */ fetcher?: GenerationFetcher; /** Additional body parameters to send with connect-based adapter requests */ body?: Record; /** Display options for TanStack AI Devtools. */ devtools?: AIDevtoolsDisplayOptions; /** * Callback when transcription is complete. Can optionally return a transformed value. * * - Return a non-null value to transform and store it as the result * - Return `null` to keep the previous result unchanged * - Return nothing (`void`) to store the raw result as-is */ onResult?: (result: TranscriptionResult) => TOutput | null | void; /** Callback when an error occurs */ onError?: (error: Error) => void; /** Callback when progress is reported (0-100) */ onProgress?: (progress: number, message?: string) => void; /** Callback for each stream chunk (connect-based adapter mode only) */ onChunk?: (chunk: StreamChunk) => void; } /** * Return type for the useTranscription hook. * * @template TOutput - The transformed output type (defaults to TranscriptionResult) */ interface UseTranscriptionReturn extends Omit, 'generate'> { /** Trigger transcription */ generate: (input: TranscriptionGenerateInput) => Promise; /** The transcription result, or null */ result: Accessor; /** Whether transcription is in progress */ isLoading: Accessor; /** Current error, if any */ error: Accessor; /** Current state of the generation */ status: Accessor; } /** * Solid hook for transcribing audio to text using AI models. * * @example * ```tsx * import { useTranscription } from '@tanstack/ai-solid' * import { fetchServerSentEvents } from '@tanstack/ai-client' * * function Transcriber() { * const { generate, result, isLoading } = useTranscription({ * connection: fetchServerSentEvents('/api/transcribe'), * }) * * const handleFile = (e: Event) => { * const input = e.target as HTMLInputElement * const file = input.files?.[0] * if (file) { * const reader = new FileReader() * reader.onload = () => { * generate({ audio: reader.result as string, language: 'en' }) * } * reader.readAsDataURL(file) * } * } * * return ( *
* * {isLoading() &&

Transcribing...

} * {result() &&

{result()!.text}

} *
* ) * } * ``` */ declare function useTranscription(options: Omit & { onResult?: (result: TranscriptionResult) => TTransformed; } & GenerationPersistenceOptions): UseTranscriptionReturn>; //#endregion export { UseTranscriptionOptions, UseTranscriptionReturn, useTranscription }; //# sourceMappingURL=use-transcription.d.ts.map