Skip to main content

RVC-Python-Fast Inference

A streamlined Python wrapper for fast inference with RVC. Specifically designed for inference tasks.

Introduction

This streamlined wrapper offers an efficient solution for integrating RVC into your Python projects, focusing primarily on rapid inference. Whether you're working on voice conversion applications or related projects, this tool simplifies the process while maintaining performance.

Key Features

  • Preloaded Models: Accelerate inference by loading models into memory beforehand, minimizing latency during runtime.
  • Batch Processing: Enhance efficiency by enabling batch processing, allowing for simultaneous conversion of multiple inputs, further optimizing throughput.
  • Support for Array Input and Output: Facilitate seamless integration with existing data pipelines by accepting and returning arrays, enhancing compatibility across various platforms and frameworks.

Getting Started

Prerequisites

  • You need to have ffmpeg and Python installed.

Pre-requirements:

pip install pip>=24 setuptools<=80.6.0

Installation

pip install infer_rvc_python

Usage

Initialize the base class

from infer_rvc_python import BaseLoader

converter = BaseLoader(only_cpu=False, hubert_path=None, rmvpe_path=None)

hubert_path now accepts a pretrained model instead of a .pt file, with r3gm/hubert_base as the default value.

Define a tag and select the model along with other parameters.

converter.apply_conf(
        tag="yoimiya",
        file_model="model.pth",
        pitch_algo="rmvpe+",
        pitch_lvl=0,
        file_index="model.index",
        index_influence=0.66,
        respiration_median_filtering=3,
        envelope_ratio=0.25,
        consonant_breath_protection=0.33
    )

Select the audio or audios you want to convert.

# audio_files = ["audio.wav", "haha.mp3"]
audio_files = "myaudio.mp3"

# speakers_list = ["sunshine", "yoimiya"]
speakers_list = "yoimiya"

Perform inference

result = converter(
    audio_files,
    speakers_list,
    overwrite=False,
    parallel_workers=4
)

The result is a list with the paths of the converted files.

Unload models

converter.unload_models()

Preloading model (Reduces inference time)

The initial execution will preload the model for the tag. Subsequent calls to inference with the same tag will benefit from preloaded components, thereby reducing inference time.

result_array, sample_rate = converter.generate_from_cache(
    audio_data="myaudiofile_path.wav",
    tag="yoimiya",
)

The param audio_data can be a path or a tuple with (array_data, sampling_rate)

# array_data = np.array([-22, -22, -15, ..., 0, 0, 0], dtype=np.int16)
# source_sample_rate = 16000
data = (array_data, source_sample_rate)
result_array, sample_rate = converter.generate_from_cache(
    audio_data=data,
    tag="yoimiya",
)

The result in both cases will be (array, sample_rate), which you can save or play in a notebook

# Save
import soundfile as sf

sf.write(
    file="output_file.wav",
    samplerate=sample_rate,
    data=result_array
)
# Play; need to install ipython
from IPython.display import Audio

Audio(result_array, rate=sample_rate)

When settings or the tag are altered, the model requires reloading. To maintain multiple preloaded models, you can instantiate another BaseLoader object.

second_converter = BaseLoader()

Credits

  • RVC-Project
  • FFMPEG

License

This project is licensed under the MIT License.

Disclaimer

This software is provided for educational and research purposes only. The authors and contributors of this project do not endorse or encourage any misuse or unethical use of this software. Any use of this software for purposes other than those intended is solely at the user's own risk. The authors and contributors shall not be held responsible for any damages or liabilities arising from the use of this software inappropriately.

Metadata

Release files for infer_rvc_python 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for infer_rvc_python 1.3.1
File Size Uploaded
infer_rvc_python-1.3.1.tar.gz 32.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for infer_rvc_python 1.3.1
File Interpreter ABI Platform
infer_rvc_python-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 69.1 kB

Release files / infer_rvc_python-1.3.1.tar.gz

Download URL infer_rvc_python-1.3.1.tar.gz
Size 32.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f4830c83f2b43cd972a7b43604c474424e6d765aaa3ddb54bba446f8cba1fd76
BLAKE2b-256 checksum
How to use checksums
4f8523dca7d02074520357a9a7530d313c2aa96a37222d307d780fd79fb86405
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.12.1 Linux/6.8.0-1052-azure

Release files / infer_rvc_python-1.3.1-py3-none-any.whl

Download URL infer_rvc_python-1.3.1-py3-none-any.whl
Size 36.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
945da670c9f0a7841abf2507908424cd53221219d0b2c35e9605a4ea0e25cacc
BLAKE2b-256 checksum
How to use checksums
69348496560d8ca99b1c068af179fdb6490e2f1c5221a43fa0b3cc9a42c94e20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.12.1 Linux/6.8.0-1052-azure

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 release files

1.3.0

2 release files

1.2.0

1 release file

1.1.0

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page