File size: 802 Bytes
65d68f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 });
}