Skip to main content

python-rvc-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 3.10 installed.

  • In windows is needed to install Microsoft Visual C++ Build Tools, MSVC and Windows 10 SDK:

    • Go to the Visual Studio downloads page; Or maybe you already have Visual Studio Installer? Open it. If you have it already click modify.
    • Download and install the "Build Tools for Visual Studio" if you don't have it.
    • During installation, under "Workloads", select "C++ build tools" and ensure the latest versions of "MSVCv142 - VS 2019 C++ x64/x86 build tools" and "Windows 10 SDK" are selected ("Windows 11 SDK" if you are using Windows 11); OR go to individual components and find those two listed.
    • Complete the installation.

Installation

pip install infervcpy

Usage

Initialize the base class

from infervcpy import BaseLoader

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

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 BSD 2-Clause 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 infervcpy 1.6

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

Source distribution (sdist)

Source distribution for infervcpy 1.6
File Size Uploaded Provenance Actions
infervcpy-1.6.tar.gz 35.1 kB Without provenance Details for infervcpy-1.6.tar.gz

Built distribution (wheel)

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

Total release size: 71.6 kB

Release files / infervcpy-1.6.tar.gz

Download URL infervcpy-1.6.tar.gz
Size 35.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3ed9580d9893f7652b794b80edd29da2b1d60e537f1227e27d3e18eb47af8fdf
BLAKE2b-256 checksum
How to use checksums
acd73d714af9682fcad6f1ec73bad78671ea760ead4af7da0934dccf3bf158be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / infervcpy-1.6-py3-none-any.whl

Download URL infervcpy-1.6-py3-none-any.whl
Size 36.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77c1544482a02a7c477520aa4a9a31f97fc127b1996d67d568a0b6341902f56c
BLAKE2b-256 checksum
How to use checksums
d8467fd26a538476b93438cf888bad7dde712d11ec8cc32be3db0c26e464780f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Security for infervcpy 1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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