ryu-js / lib /@randydev /openai.js
randydev's picture
Create openai.js
8e6f2c8 verified
raw
history blame
946 Bytes
/*
app.post("/run/:model", async (req, res) => {
const { model } = req.params;
const url = req.query.url;
const path = await audioContent(
"https://pub-dbcf9f0bd3af47ca9d40971179ee62de.r2.dev/02f6edc0-1f7b-4272-bd17-f05335104725/audio.mp3"
);
if (!path) {
return res.status(500).json({ error: "Failed to download audio file" });
}
try {
const audioBytes = fs.readFileSync(path);
const audioBase64 = Buffer.from(audioBytes).toString("base64");
const inputData = { audio: audioBase64 };
const response = await axios.post(`${API_BASE_URL}${model}`, inputData, { headers });
return res.json(response.data);
} catch (error) {
console.error("Error making API request:", error.message);
return res.status(500).json({ error: error.message });
} finally {
if (fs.existsSync(path)) {
fs.unlinkSync(path);
}
}
});
*/