Learn how to create AI voice models and generate voice covers using the Weights API. This guide covers both training custom RVC (Retrieval-based Voice Conversion) models and creating voice covers with existing models.
The Weights API provides powerful voice synthesis capabilities through RVC technology. You can train custom voice models on your own audio samples and create voice covers that sound like specific singers or speakers.
Start the training process by creating an RVC model:
Copy
Ask AI
const rvcModel = await client.rvcModels.training.create({ name: "My Custom Voice", description: "A voice model trained on my singing samples", audioFiles: trainingAudioFiles, runKaraoke: true, runDeEchoDeReverb: false,});console.log(`RVC model created with ID: ${rvcModel.id}`);console.log(`Training job ID: ${rvcModel.id}`);
RVC training is asynchronous and can take several hours. Poll the status to track progress:
Copy
Ask AI
async function checkTrainingStatus(modelId) { const status = await client.rvcModels.training.status(modelId); if (!status) { console.log("Model not found or access denied"); return null; } console.log(`Status: ${status.status}`); console.log(`Queue Position: ${status.queuePosition || "N/A"}`); console.log(`Status Text: ${status.shortStatusText || "N/A"}`); switch (status.status) { case "QUEUED": console.log("Your model is waiting in the training queue..."); break; case "PROCESSING": console.log("Your model is being trained..."); break; case "SUCCEEDED": console.log("Training completed successfully!"); break; case "ERRORED": console.log( "Training failed. Please check your audio files and try again." ); break; } return status;}// Check status every 10 minutesconst status = await checkTrainingStatus(rvcModel.id);
Once you have a trained model (or use a public one), you can create voice covers:
Copy
Ask AI
const cover = await client.covers.create({ rvcModelId: rvcModel.id, // or use a public model ID inputUrl: "https://example.com/song-to-cover.mp3", inputFileName: "Original Song", pitch: 0, // Pitch shift (0 = no change) preStemmed: false, // Whether input is already vocal-only stemOnly: false, // Whether to return only vocals deEcho: false, // Remove echo from output isolateMainVocals: true, // Focus on main vocals});console.log(`Cover created with ID: ${cover.id}`);
Cover generation is asynchronous. Poll the status to track progress:
Copy
Ask AI
async function checkCoverStatus(coverId) { const cover = await client.covers.retrieve(coverId); if (!cover) { console.log("Cover not found or access denied"); return null; } console.log(`Status: ${cover.status}`); console.log(`Queue Position: ${cover.queuePosition || "N/A"}`); switch (cover.status) { case "QUEUED": console.log("Your cover is waiting in the queue..."); break; case "PROCESSING": console.log("Your cover is being generated..."); break; case "SUCCEEDED": console.log("Cover generated successfully!"); console.log("Download URL:", cover.outputUrl); break; case "ERRORED": console.log("Cover generation failed. Please try again."); break; } return cover;}// Check status every 30 secondsconst coverResult = await checkCoverStatus(cover.id);
const uploadedModel = await client.rvcModels.upload({ url: "https://example.com/my-rvc-model.pth", title: "My Pre-trained Model", description: "A model I trained elsewhere",});console.log(`Model uploaded with ID: ${uploadedModel.id}`);
// Example: Training a singing voice modelconst singingModel = await client.rvcModels.training.create({ name: "My Singing Voice", description: "Trained on my singing samples", audioFiles: singingSamples, runKaraoke: true, // Extract vocals from music});// Example: Training a speaking voice modelconst speakingModel = await client.rvcModels.training.create({ name: "My Speaking Voice", description: "Trained on my speech samples", audioFiles: speechSamples, runKaraoke: false, // No need for vocal extraction});