/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { SDKCore } from "../core.js"; import { llmSpeechTranscribe } from "../funcs/llmSpeechTranscribe.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import * as components from "../models/components/index.js"; import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; import { unwrapAsync } from "../types/fp.js"; import { useSDKContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type LlmSpeechTranscribeMutationVariables = { request: operations.TranscribeRequest; options?: RequestOptions; }; export type LlmSpeechTranscribeMutationData = components.TranscriptionResponse; export type LlmSpeechTranscribeMutationError = | SDKError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Speech to text transcription * * @remarks * Convert audio to text using advanced speech recognition. * * **Complete File Upload (Standard)** * Use `Content-Type: multipart/form-data` to upload the complete audio file in one request. Maximum file size: 25MB. * * Example: * ```bash * curl -X POST "http://localhost:3000/api/v1/llm/speech/transcriptions?language=en" \ * -F "file=@audio.flac" * ``` * * **Chunked Upload (Streaming)** * Use `Transfer-Encoding: chunked` header to stream audio data in chunks as it's being recorded. No need to know total file size upfront. Server buffers chunks until complete before processing. Maximum total size: 25MB. * * Example: * ```bash * curl -X POST "http://localhost:3000/api/v1/llm/speech/transcriptions?language=en" \ * -H "Transfer-Encoding: chunked" \ * -H "Content-Type: multipart/form-data" \ * --data-binary @audio.flac * ``` * * **Supported Formats:** FLAC, MP3, MP4, MPEG, MPGA, M4A, OGG, WAV, WebM * * **Query Parameters:** * - `model` (optional): Transcription model identifier. Defaults to 'auto'. * - `language` (optional): ISO-639-1 or BCP-47 language code (e.g., "en", "en-US"). Auto-detects if not specified. * - `prompt` (optional): Legacy prompt parameter retained for backward compatibility. * - `temperature` (optional): Legacy temperature parameter retained for backward compatibility. * - `include_speaker_data` (optional): When `true`, include speaker diarization data and require WAV/PCM input. Otherwise transcription uses the standard compatibility path. * * **Response:** Returns transcribed text in JSON format. */ export function useLlmSpeechTranscribeMutation( options?: MutationHookOptions< LlmSpeechTranscribeMutationData, LlmSpeechTranscribeMutationError, LlmSpeechTranscribeMutationVariables >, ): UseMutationResult< LlmSpeechTranscribeMutationData, LlmSpeechTranscribeMutationError, LlmSpeechTranscribeMutationVariables > { const client = useSDKContext(); return useMutation({ ...buildLlmSpeechTranscribeMutation(client, options), ...options, }); } export function mutationKeyLlmSpeechTranscribe(): MutationKey { return ["@meetkai/mka1", "speech", "transcribe"]; } export function buildLlmSpeechTranscribeMutation( client$: SDKCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: LlmSpeechTranscribeMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyLlmSpeechTranscribe(), mutationFn: function llmSpeechTranscribeMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(llmSpeechTranscribe( client$, request, mergedOptions, )); }, }; }