DocDoeAI / src /lib /api /record-lecture.ts
asnannp's picture
deploy: sync backend to Space root (learn-lesson HF cache fix)
65d68f5
Raw History Blame Contribute Delete
802 Bytes
import { apiUpload } from "@/lib/api/client";
export type TranscriptionResult = {
ok: boolean;
configured: boolean;
transcript: string;
reason: string | null;
duration_seconds: number | null;
};
/**
* Send a recorded audio clip to the backend for transcription. The backend is
* honest: `configured` is false when the server has no Deepgram key, `ok` is
* true only when real speech was transcribed. Never throws for a "no speech"
* clip — that comes back as ok:false with a reason.
*/
export async function transcribeLecture(audio: Blob, filename = "lecture.webm"): Promise<TranscriptionResult> {
const formData = new FormData();
formData.append("file", audio, filename);
return apiUpload<TranscriptionResult>("/record-lecture/transcribe", formData, { timeoutMs: 90_000 });
}