Closed tmageebtr closed 1 month ago
I am also facing this issue. Any updates on this?
Same issue. I am using the latest version now.
I found one alternative is to create a Blob of the uploaded file buffer. Node: v20.9.0 elevenlabs: ^0.15.0
const express = require("express");
const multer = require("multer");
const { ElevenLabsClient } = require("elevenlabs");
const app = express();
const port = 3000;
const client = new ElevenLabsClient({
apiKey: "API_KEY",
});
const upload = multer();
app.post("/add-voice", upload.array("files"), async (req, res) => {
try {
const { name } = req.body;
const files = req.files;
if (!files?.length) {
return res.status(400).send({ message: "No file uploaded" });
}
if (!name) {
return res.status(400).send({ message: "Name is required" });
}
const filesArr = files.map(
(file) =>
new Blob([file.buffer], {
type: file?.mimetype,
})
);
const response = await client.voices.add({
files: filesArr,
name: name,
});
res.send({
response,
});
} catch (error) {
res.send({
error: error?.message,
});
}
});
Same issue.
@tmageebtr we've also merged a fix into the SDK on the latest version
Trying code similar to example. Getting error. Node 18.19.1 "elevenlabs": "^0.13.0"
`/home/ubuntu/web/node_modules/elevenlabs/api/resources/voices/client/Client.js:496 throw new ElevenLabs.UnprocessableEntityError(_response.error.body); ^
UnprocessableEntityError: UnprocessableEntityError Status code: 422 Body: { "detail": [ { "loc": [ "body", "files", 0 ], "msg": "Expected UploadFile, received: <class 'str'>", "type": "value_error" } ] } at Voices. (/home/ubuntu/web/node_modules/elevenlabs/api/resources/voices/client/Client.js:496:31)
at Generator.next ()
at fulfilled (/home/ubuntu/web/node_modules/elevenlabs/api/resources/voices/client/Client.js:31:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
statusCode: 422,
body: {
detail: [
{
loc: [ 'body', 'files', 0 ],
msg: "Expected UploadFile, received: <class 'str'>",
type: 'value_error'
}
]
}
}
`