Closed bradydowling closed 4 months ago
I dug into the SDK code a little bit and when I add a console.log(request.name)
into the add function in the client then it's giving me what I'd expect (BradyDowling
). So Perhaps this issue is coming from a mismatch between what the client and the server are expecting here.
Hmmm, I tried using Axios instead and it worked great so it looks like this is an issue with the client. Here's my code in case that helps:
import axios from "axios";
import { createRequire } from "module";
import arg from "arg";
import fs from "fs";
import FormData from "form-data";
const customRequire = createRequire(import.meta.url);
const dotenv = customRequire("dotenv");
dotenv.config();
// Define the expected command-line arguments
const args = arg({
// Types
"--name": String,
"--file": String,
// Aliases
"-n": "--name",
"-f": "--file",
});
const name = args["--name"];
const filePath = args["--file"];
const run = async () => {
if (!name || !filePath) {
console.error("Please provide a voice name and file path");
return;
}
const fullFilePath = `./input/audio-samples/${filePath}`;
try {
const form = new FormData();
form.append("name", name);
form.append("files", fs.createReadStream(fullFilePath));
form.append("description", "Meditation voice created by Brady");
const response = await axios.post(
"https://api.elevenlabs.io/v1/voices/add",
form,
{
headers: {
"Content-Type": `multipart/form-data; boundary=${form._boundary}`,
"xi-api-key": process.env.ELEVENLABS_API_KEY,
},
}
);
console.log(response.data);
} catch (error) {
console.error(
"Error: ",
error.response ? error.response.data : error.message
);
}
};
run();
+1, experiencing the same thing.
@plungepool @bradydowling this should be fixed in the latest SDK 0.8.2
, let us know if you have any futher issues!
Seems like the SDK call isn't properly providing the field to the API? See the error message a little further down. Here is the full code for my file:
And here is the full run output and error message:
Here's my package.json in case that helps:
I looked at the call signature of add and I'm matching it. I'm not sure what else I could be doing wrong.
node: v22.2.0 yarn: 1.22.22