Giter Club home page Giter Club logo

hf-rvc's Introduction

HF RVC

HF RVC is a package for Retrieval-based-Voice-Conversion (RVC) implementation using HuggingFace's transformers, along with the capability to convert from original unsafe models. The library is easy to use and provides an efficient way to perform voice conversion tasks.

Original Implementation

The original implementation of the Retrieval-based-Voice-Conversion (RVC) can be found at the following GitHub repository: https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.

Installation

Supported Python versions: 3.8, 3.9, 3.10 (recommended)

To install the library, you can use the following command:

pip install git+https://github.com/esnya/hf-rvc.git#egg=hf-rvc

Basic Usage

Here's an example of how to use the package as a library:

from hf_rvc import RVCFeatureExtractor, RVCModel

feature_extractor = RVCFeatureExtractor.from_pretrained(model_name)
# feature_extractor.set_f0_method("harvest")

model = RVCModel.from_pretrained(model_name)

input_features = feature_extractor(
    audio["array"],
    sampling_rate=audio["sampling_rate"],
    f0_up_key=key,
    return_tensors="pt",
)
output = model(**input_features).numpy()

Command Line Tools

HF RVC also provides several command line tools. You can check the available commands with --help:

python -m hf_rvc --help

For more detailed usage of each tool, you can check the --help option of the specific command.

Model Conversion

Since the models are not yet available on HuggingFace, you may need to convert the original .pth model files or the original hubert_base.pt model to be compatible with HF RVC. This can be done using the convert-*** command line tools. The conversion not only adapts the models to the different frameworks but also, by default, ensures compatibility with the safetensor format for secure model sharing.

When using the command line tools to load the hubert_base.pt model, you must provide the --unsafe option to confirm that you have obtained the model from a trusted source. You also need to install the fairseq package to convert the original .pth model files. You can install it with this package by with suffix [convert].

Example:

python -m hf_rvc convert-rvc --hubert-path <path_to_hubert_base.pt> --unsafe <path_to_original_vits_model.pth>

Real-time Voice Conversion

A real-time voice conversion tool that allows you to perform voice conversion on-the-fly. To use this feature, simply run the following command:

python -m hf_rvc realtime-vc path/to/converted_or_hugging_face/model

This tool accepts various arguments, including the model, feature extractor, buffering settings, F0 method, input and output device indices, and more. It enables users to adjust the conversion parameters in, offering greater control and customization.

python -m hf_rvc realtime-vc --help

For a detailed explanation of each argument, please run the --help command as shown above.

Attribution

The code in hf_rvc/models/vits is based on the original implementation published under the MIT License Copyright (c) 2023 liujing04. The code has been slightly modified by esnya.

Contributing

We welcome contributions to the package! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the GitHub repository.

License

HF RVC is licensed under the MIT License.

hf-rvc's People

Contributors

esnya avatar scf4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

hf-rvc's Issues

Hubert compatibility and RVC v2 support

I tried a few different hubert checkpoints including this and this and some of these and an official fairseq base, and a few random RVC models from huggingface, I always get an error

Missing key(s) in state_dict: "hubert.encoder.pos_conv_embed.conv.parametrizations.weight.original0", "hubert.encoder.pos_conv_embed.conv.parametrizations.weight.original1". 
Unexpected key(s) in state_dict: "encoder.pos_conv.0.weight_g", "encoder.pos_conv.0.weight_v". 

Tried to fix it with edited mapping

r"encoder.pos_conv.0.weight_g": r"hubert.encoder.pos_conv_embed.conv.parametrizations.weight.original0",
r"encoder.pos_conv.0.weight_v": r"hubert.encoder.pos_conv_embed.conv.parametrizations.weight.original1",

I faced another issue:

RuntimeError: Error(s) in loading state_dict for SynthesizerTrnMs256NSFsid:
	size mismatch for enc_p.emb_phone.weight: copying a param with shape torch.Size([192, 768]) from checkpoint, the shape in current model is torch.Size([192, 256]).

turns out it was a v2 model, tried a v1 model and it worked.
changed emb_phone size to 768 and it converted v2 models, but v2 fails on inference:

RuntimeError: mat1 and mat2 shapes cannot be multiplied (112x256 and 768x192)

Documentation

Hello,

Maybe it's just me who can't figure out how to use this package, but would it be possible to get a little more detailed documentation?

I don't want to bother you with something that's surely not an "issue", but I can't use the models I trained with the web-ui version of rvc.

For example : in the basic usage, you need to specify the feature extractor that will be used. But I can't find any file named preprocess_config.json in the files of my models on the web-ui version, or in the files of the web-ui version at all.

Am I missing something?

usable as CLI for conversion?

hi! we just want to do plain old conversion for RVC - take an input wav and spit out a converted file - using the command line - like we can in so-vits. is there any easy way to do this? happy to help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.