Upload 3 files
Browse files
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2024 Roger Condori
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
README.md
CHANGED
@@ -1,3 +1,138 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# RVC-Python-FastInference
|
2 |
+
|
3 |
+
A streamlined Python wrapper for fast inference with RVC.
|
4 |
+
Specifically designed for inference tasks.
|
5 |
+
|
6 |
+
## Introduction
|
7 |
+
|
8 |
+
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.
|
9 |
+
|
10 |
+
## Key Features
|
11 |
+
- Preloaded Models: Accelerate inference by loading models into memory beforehand, minimizing latency during runtime.
|
12 |
+
- Batch Processing: Enhance efficiency by enabling batch processing, allowing for simultaneous conversion of multiple inputs, further optimizing throughput.
|
13 |
+
- 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.
|
14 |
+
|
15 |
+
## Getting Started
|
16 |
+
|
17 |
+
### Prerequisites
|
18 |
+
|
19 |
+
- You need to have ffmpeg and Python 3.10 installed.
|
20 |
+
- In windows is needed to install Microsoft Visual C++ Build Tools, MSVC and Windows 10 SDK:
|
21 |
+
|
22 |
+
* Go to the [Visual Studio downloads page](https://visualstudio.microsoft.com/visual-cpp-build-tools/); Or maybe you already have **Visual Studio Installer**? Open it. If you have it already click modify.
|
23 |
+
* Download and install the "Build Tools for Visual Studio" if you don't have it.
|
24 |
+
* 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.
|
25 |
+
* Complete the installation.
|
26 |
+
|
27 |
+
### Installation
|
28 |
+
|
29 |
+
```
|
30 |
+
pip install infer_rvc_python
|
31 |
+
```
|
32 |
+
|
33 |
+
# Usage
|
34 |
+
|
35 |
+
## Initialize the base class
|
36 |
+
|
37 |
+
```
|
38 |
+
from infer_rvc_python import BaseLoader
|
39 |
+
|
40 |
+
converter = BaseLoader(only_cpu=False, hubert_path=None, rmvpe_path=None)
|
41 |
+
```
|
42 |
+
|
43 |
+
## Define a tag and select the model along with other parameters.
|
44 |
+
|
45 |
+
```
|
46 |
+
converter.apply_conf(
|
47 |
+
tag="yoimiya",
|
48 |
+
file_model="model.pth",
|
49 |
+
pitch_algo="rmvpe+",
|
50 |
+
pitch_lvl=0,
|
51 |
+
file_index="model.index",
|
52 |
+
index_influence=0.66,
|
53 |
+
respiration_median_filtering=3,
|
54 |
+
envelope_ratio=0.25,
|
55 |
+
consonant_breath_protection=0.33
|
56 |
+
)
|
57 |
+
```
|
58 |
+
|
59 |
+
## Select the audio or audios you want to convert.
|
60 |
+
|
61 |
+
```
|
62 |
+
# audio_files = ["audio.wav", "haha.mp3"]
|
63 |
+
audio_files = "myaudio.mp3"
|
64 |
+
|
65 |
+
# speakers_list = ["sunshine", "yoimiya"]
|
66 |
+
speakers_list = "yoimiya"
|
67 |
+
```
|
68 |
+
|
69 |
+
## Perform inference
|
70 |
+
|
71 |
+
```
|
72 |
+
result = converter(
|
73 |
+
audio_files,
|
74 |
+
speakers_list,
|
75 |
+
overwrite=False,
|
76 |
+
parallel_workers=4
|
77 |
+
)
|
78 |
+
```
|
79 |
+
The `result` is a list with the paths of the converted files.
|
80 |
+
|
81 |
+
## Unload models
|
82 |
+
```
|
83 |
+
converter.unload_models()
|
84 |
+
```
|
85 |
+
|
86 |
+
# Preloading model (Reduces inference time)
|
87 |
+
|
88 |
+
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.
|
89 |
+
```
|
90 |
+
result_array, sample_rate = converter.generate_from_cache(
|
91 |
+
audio_data="myaudiofile_path.wav",
|
92 |
+
tag="yoimiya",
|
93 |
+
)
|
94 |
+
```
|
95 |
+
|
96 |
+
The param audio_data can be a path or a tuple with (array_data, sampling_rate)
|
97 |
+
|
98 |
+
```
|
99 |
+
# array_data = np.array([-22, -22, -15, ..., 0, 0, 0], dtype=np.int16)
|
100 |
+
# source_sample_rate = 16000
|
101 |
+
data = (array_data, source_sample_rate)
|
102 |
+
result_array, sample_rate = converter.generate_from_cache(
|
103 |
+
audio_data=data,
|
104 |
+
tag="yoimiya",
|
105 |
+
)
|
106 |
+
```
|
107 |
+
The result in both cases will be (array, sample_rate), which you can save or play in a notebook
|
108 |
+
|
109 |
+
```
|
110 |
+
# Save
|
111 |
+
import soundfile as sf
|
112 |
+
|
113 |
+
sf.write(
|
114 |
+
file="output_file.wav",
|
115 |
+
samplerate=sample_rate,
|
116 |
+
data=result_array
|
117 |
+
)
|
118 |
+
```
|
119 |
+
|
120 |
+
```
|
121 |
+
# Play; need to install ipython
|
122 |
+
from IPython.display import Audio
|
123 |
+
|
124 |
+
Audio(result_array, rate=sample_rate)
|
125 |
+
```
|
126 |
+
When settings or the tag are altered, the model requires reloading. To maintain multiple preloaded models, you can instantiate another BaseLoader object.
|
127 |
+
```
|
128 |
+
second_converter = BaseLoader()
|
129 |
+
```
|
130 |
+
# Credits
|
131 |
+
- RVC-Project
|
132 |
+
- FFMPEG
|
133 |
+
|
134 |
+
# License
|
135 |
+
This project is licensed under the MIT License.
|
136 |
+
|
137 |
+
# Disclaimer
|
138 |
+
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.
|
setup.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import platform
|
3 |
+
import pkg_resources
|
4 |
+
from setuptools import find_packages, setup
|
5 |
+
|
6 |
+
setup(
|
7 |
+
name="rvcinfpy",
|
8 |
+
version="1.1.0",
|
9 |
+
description="Python wrapper for fast inference with rvc",
|
10 |
+
long_description=open('README.md').read(),
|
11 |
+
long_description_content_type='text/markdown',
|
12 |
+
readme="README.md",
|
13 |
+
python_requires=">=3.10",
|
14 |
+
author="Thatneos",
|
15 |
+
url="https://huggingface.co/Thatneos/rvcinfpy",
|
16 |
+
license="MIT",
|
17 |
+
packages=find_packages(),
|
18 |
+
package_data={'': ['*.txt', '*.rep', '*.pickle']},
|
19 |
+
install_requires=[
|
20 |
+
"torch",
|
21 |
+
"torchaudio",
|
22 |
+
"praat-parselmouth>=0.4.3",
|
23 |
+
"pyworld==0.3.2",
|
24 |
+
"faiss-cpu==1.7.3",
|
25 |
+
"torchcrepe==0.0.23",
|
26 |
+
"ffmpeg-python>=0.2.0",
|
27 |
+
"fairseq2",
|
28 |
+
"typeguard==4.2.0",
|
29 |
+
"soundfile",
|
30 |
+
"librosa",
|
31 |
+
"numpy",
|
32 |
+
],
|
33 |
+
include_package_data=True,
|
34 |
+
extras_require={"all": [
|
35 |
+
"scipy",
|
36 |
+
"numba==0.56.4",
|
37 |
+
"edge-tts"
|
38 |
+
]},
|
39 |
+
)
|