File size: 1,006 Bytes
1c76dfa
347dddd
 
 
 
 
 
 
 
 
 
1c76dfa
347dddd
 
 
 
1c76dfa
 
 
 
 
 
347dddd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1c76dfa
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// frontend/src/api/client.js
const API = "http://localhost:3001/api";

export async function getModels() {
    const res = await fetch(`${API}/models`);
    return res.json();
}

export async function uploadAudio(file) {
    const fd = new FormData();
    fd.append("audio", file);

    const res = await fetch(`${API}/audio/upload`, {
        method: "POST",
        body: fd
    });

    if (!res.ok) {
        const txt = await res.text();
        throw new Error(txt || "Upload failed");
    }

    return res.json();
}

export async function createJob(payload) {
    const res = await fetch(`${API}/create`, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(payload)
    });
    return res.json();
}

export async function getJobStatus(jobId) {
    const res = await fetch(`${API}/create/${jobId}/status`);
    return res.json();
}

export async function listAudio() {
    const res = await fetch(`${API}/audio`);
    return res.json();
}