Install RVC using pip
developYou can install the RVC framework directly from the GitHub repository using pip.
pip install git+https://github.com/RVC-Project/Retrieval-based-Voice-Conversionrepository·develop·Indexed 17 days ago
https://github.com/rvc-project/retrieval-based-voice-conversionA voice conversion framework based on VITS (version 0.3.5) that transforms input audio into a target voice using pre-trained models and feature indexing. It provides a Python library via the VC class, a REST API server, and a comprehensive CLI for inference, training, environment configuration, and UVR5 vocal/instrumental separation.
You can install the RVC framework directly from the GitHub repository using pip.
pip install git+https://github.com/RVC-Project/Retrieval-based-Voice-ConversionTo set up a standard working directory, use the rvc init command. This creates an assets folder (for models used in inference and training) and a .env file in your current directory.
Warning: Ensure the directory is empty or does not already contain an assets folder before running this command.
rvc initYou can build and run the container using the provided script:
./docker-run.shIf running manually, ensure your weights, indices, and input audios are stored in the ${PWD}/assets directory.
docker build -t "rvc" .docker run -it \
-p 8000:8000 \
-v "${PWD}/assets/weights:/weights:ro" \
-v "${PWD}/assets/indices:/indices:ro" \
-v "${PWD}/assets/audios:/audios:ro" \
"rvc"docker build -t "rvc" .
docker run -it \
-p 8000:8000 \
-v "${PWD}/assets/weights:/weights:ro" \
-v "${PWD}/assets/indices:/indices:ro" \
-v "${PWD}/assets/audios:/audios:ro" \
"rvc"If you need to change model locations or configurations, edit the .env file. If you don't have one, generate it using:
rvc env createYou can download models directly via the CLI:
rvc dlmodelrvc dlmodel {download_dir}After downloading, ensure the model location is correctly specified in your .env file.
rvc env create
rvc dlmodel {download_dir}You can use the VC class from rvc.modules.vc.modules to perform voice conversion programmatically.
VC object.get_vc(model_path).vc_inference(sid, input_audio_path) which returns the target sample rate, audio data, and timing information.from pathlib import Path
from dotenv import load_dotenv
from scipy.io import wavfile
from rvc.modules.vc.modules import VC
def main():
vc = VC()
vc.get_vc("{model.pth}")
tgt_sr, audio_opt, times, _ = vc.vc_inference(
1, Path("{InputAudio}")
)
wavfile.write("{OutputAudio}", tgt_sr, audio_opt)
if __name__ == "__main__":
load_dotenv("{envPath}")
main()Run the server using:
rvc-apiAll inference requests are POST requests to /inference using multipart/form-data. You can specify the response type via the res_type query parameter.
Use res_type=blob to receive the raw audio data.
Use res_type=json to receive a JSON object containing the audio and timing information.
# Get as blob
curl -X 'POST' \
'http://127.0.0.1:8000/inference?res_type=blob' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'modelpath={model.pth}' \
-F 'input={input audio path}'
# Get as json(include time)
curl -X 'POST' \
'http://127.0.0.1:8000/inference?res_type=json' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'modelpath={model.pth}' \
-F 'input={input audio path}'The following options are available for the rvc infer command:
| option | flag | type | default value | description |
|---------------|------------|--------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| modelPath | -m | Path | *required | Model path or filename (reads in the directory set in env) |
| inputPath | -i | Path | *required | Input audio path or folder |
| outputPath | -o | Path | *required | Output audio path or folder |
| sid | -s | int | 0 | Speaker/Singer ID |
| f0_up_key | -fu | int | 0 | Transpose (integer, number of semitones, raise by an octave: 12, lower by an octave: -12) |
| f0_method | -fm | str | rmvpe | pitch extraction algorithm (pm, harvest, crepe, rmvpe) |
| f0_file | -ff | Path \| None | None | F0 curve file (optional). One pitch per line. Replaces the default F0 and pitch modulation |
| index_file | -if | Path \| None | None | Path to the feature index file |
| index_rate | -if | float | 0.75 | Search feature ratio (controls accent strength, too high has artifacting) |
| filter_radius | -fr | int | 3 | If >=3: apply median filtering to the harvested pitch results. The value represents the filter radius and can reduce breathiness |
| resample_sr | -rsr | int | 0 | Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling |
| rms_mix_rate | -rmr | float | 0.25 | Adjust the volume envelope scaling. Closer to 0, the more it mimicks the volume of the original vocals. Closer to 1 will be a more of a consistently loud volume |
| protect | -p | float | 0.33 | Protect voiceless consonants and breath sounds to prevent artifacts such as tearing in electronic music. Set to 0.5 to disable. Decrease the value to increase protection, but it may reduce indexing accuracy |Use the rvc infer command to convert audio files via the command line. You must provide the model path, input path, and output path.
rvc infer -m {model.pth} -i {input.wav} -o {output.wav}The following commands are registered under the rvc CLI group:
infer: Handles voice conversion/inference tasks.train: Manages the training process for voice models.uvr: Provides UVR5 (Ultimate Vocal Remover) functionality for vocal/instrumental separation.dlmodel: Utilities for handling deep learning models.env: Manages environment-specific configurations or settings.init: Performs initialization tasks for the RVC environment.Full list of command-line options available for the infer command.
--modelPath, -m (str, required): Model path or filename (reads in the directory set in env)
--inputPath, -i (Path, required): input audio path or folder
--outputPath, -o (Path, required): output audio path or folder
--sid, -s (int): Speaker/Singer id (default: 0)
--f0upkey, -fu (int): Transpose (default: 0)
--f0method, -fm (str): Pitch extraction algorith (default: "rmvpe")
--f0file, -ff (Path): F0 curve file (optional)
--indexFile, -if (Path): Feature index file
--indexRate, -ir (float): Search feature ratio (default: 0.75)
--filterRadius, -fr (int): Apply median filtering (default: 3)
--resamplesr, -rsr (int): Resample the output audio (default: 0)
--rmsmixrate, -rmr (float): Adjust the volume envelope scaling (default: 0.25)
--protect, -p (float): Protect voiceless consonants and breath sounds (default: 0.33)The following options are available for the uvr command:
| Option | Long Flag | Type | Description |
|---|---|---|---|
-m | --modelName | str | Model path or filename (reads in the directory set in env) |
-i | --inputPath | Path | Input audio path or folder |
-o | --outputPath | Path | Required. Output audio path or folder |
-f | --format | str | Output Format |
-m, --modelName STR
Model path or filename (reads in the directory set in env)
-i, --inputPath PATH
input audio path or folder
-o, --outputPath PATH
output audio path or folder (REQUIRED)
-f, --format STR
output FormatThe uvr command is used to perform audio separation using UVR5 models. It accepts an input audio file or folder, a model name/path, and an output destination. The command uses the UVR module to process the files and can specify an output format.
Note: The --modelName option reads from the directory specified in your environment variables if a full path is not provided.
# Example usage (placeholders for actual paths)
python -m rvc.wrapper.cli.handler.uvr5 --modelName "model_name" --inputPath "/path/to/input" --outputPath "/path/to/output" --format "wav"