You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
1021 B
TypeScript
23 lines
1021 B
TypeScript
// frontend/lib/inbox/multimodal.ts — 멀티모달 캡처 (음성 STT / 이미지 Vision)
|
|
import type { TranscribeResult, CaptionResult } from "@/lib/types";
|
|
|
|
const BASE = process.env.NEXT_PUBLIC_API_BASE ?? (typeof window === "undefined" ? "http://localhost:31800" : "");
|
|
|
|
export async function transcribeAudio(blob: Blob, hint = ""): Promise<TranscribeResult> {
|
|
const fd = new FormData();
|
|
fd.append("audio", blob, "capture.webm");
|
|
if (hint) fd.append("hint", hint);
|
|
const res = await fetch(`${BASE}/api/inbox/transcribe`, { method: "POST", body: fd });
|
|
if (!res.ok) throw new Error(`transcribe ${res.status}`);
|
|
return res.json();
|
|
}
|
|
|
|
export async function captionImage(file: File, hint = ""): Promise<CaptionResult> {
|
|
const fd = new FormData();
|
|
fd.append("image", file, file.name || "capture.jpg");
|
|
if (hint) fd.append("hint", hint);
|
|
const res = await fetch(`${BASE}/api/inbox/caption`, { method: "POST", body: fd });
|
|
if (!res.ok) throw new Error(`caption ${res.status}`);
|
|
return res.json();
|
|
}
|