infer_rvc_python 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.1
2
+ Name: infer_rvc_python
3
+ Version: 1.3.0
4
+ Summary: Python wrapper for fast inference with rvc
5
+ Home-page: https://github.com/R3gm/infer_rvc_python
6
+ License: MIT
7
+ Author: R3gm
8
+ Requires-Python: >=3.10,<4.0
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Provides-Extra: all
16
+ Requires-Dist: edge-tts ; extra == "all"
17
+ Requires-Dist: faiss-cpu (==1.10.0)
18
+ Requires-Dist: ffmpeg-python (>=0.2.0)
19
+ Requires-Dist: librosa
20
+ Requires-Dist: numba (==0.56.4) ; extra == "all"
21
+ Requires-Dist: numpy
22
+ Requires-Dist: praat-parselmouth (>=0.4.2)
23
+ Requires-Dist: pyworld (==0.3.4)
24
+ Requires-Dist: scipy ; extra == "all"
25
+ Requires-Dist: soundfile
26
+ Requires-Dist: soxr (==1.1.0)
27
+ Requires-Dist: torch
28
+ Requires-Dist: torchaudio
29
+ Requires-Dist: torchcrepe (==0.0.20)
30
+ Requires-Dist: torchvision
31
+ Requires-Dist: transformers
32
+ Requires-Dist: typeguard (==4.2.0)
33
+ Project-URL: Repository, https://github.com/R3gm/infer_rvc_python
34
+ Description-Content-Type: text/markdown
35
+
36
+ # RVC-Python-Fast Inference
37
+
38
+ A streamlined Python wrapper for fast inference with RVC.
39
+ Specifically designed for inference tasks.
40
+
41
+ ## Introduction
42
+
43
+ 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.
44
+
45
+ ## Key Features
46
+ - Preloaded Models: Accelerate inference by loading models into memory beforehand, minimizing latency during runtime.
47
+ - Batch Processing: Enhance efficiency by enabling batch processing, allowing for simultaneous conversion of multiple inputs, further optimizing throughput.
48
+ - 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.
49
+
50
+ ## Getting Started
51
+
52
+ ### Prerequisites
53
+
54
+ - You need to have ffmpeg and Python installed.
55
+
56
+ Pre-requirements:
57
+ ```
58
+ pip install pip>=24 setuptools<=80.6.0
59
+ ```
60
+
61
+ ### Installation
62
+
63
+ ```
64
+ pip install infer_rvc_python
65
+ ```
66
+
67
+ # Usage
68
+
69
+ ## Initialize the base class
70
+
71
+ ```
72
+ from infer_rvc_python import BaseLoader
73
+
74
+ converter = BaseLoader(only_cpu=False, hubert_path=None, rmvpe_path=None)
75
+ ```
76
+ `hubert_path` now accepts a pretrained model instead of a `.pt` file, with `r3gm/hubert_base` as the default value.
77
+
78
+
79
+ ## Define a tag and select the model along with other parameters.
80
+
81
+ ```
82
+ converter.apply_conf(
83
+ tag="yoimiya",
84
+ file_model="model.pth",
85
+ pitch_algo="rmvpe+",
86
+ pitch_lvl=0,
87
+ file_index="model.index",
88
+ index_influence=0.66,
89
+ respiration_median_filtering=3,
90
+ envelope_ratio=0.25,
91
+ consonant_breath_protection=0.33
92
+ )
93
+ ```
94
+
95
+ ## Select the audio or audios you want to convert.
96
+
97
+ ```
98
+ # audio_files = ["audio.wav", "haha.mp3"]
99
+ audio_files = "myaudio.mp3"
100
+
101
+ # speakers_list = ["sunshine", "yoimiya"]
102
+ speakers_list = "yoimiya"
103
+ ```
104
+
105
+ ## Perform inference
106
+
107
+ ```
108
+ result = converter(
109
+ audio_files,
110
+ speakers_list,
111
+ overwrite=False,
112
+ parallel_workers=4
113
+ )
114
+ ```
115
+ The `result` is a list with the paths of the converted files.
116
+
117
+ ## Unload models
118
+ ```
119
+ converter.unload_models()
120
+ ```
121
+
122
+ # Preloading model (Reduces inference time)
123
+
124
+ 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.
125
+ ```
126
+ result_array, sample_rate = converter.generate_from_cache(
127
+ audio_data="myaudiofile_path.wav",
128
+ tag="yoimiya",
129
+ )
130
+ ```
131
+
132
+ The param audio_data can be a path or a tuple with (array_data, sampling_rate)
133
+
134
+ ```
135
+ # array_data = np.array([-22, -22, -15, ..., 0, 0, 0], dtype=np.int16)
136
+ # source_sample_rate = 16000
137
+ data = (array_data, source_sample_rate)
138
+ result_array, sample_rate = converter.generate_from_cache(
139
+ audio_data=data,
140
+ tag="yoimiya",
141
+ )
142
+ ```
143
+ The result in both cases will be (array, sample_rate), which you can save or play in a notebook
144
+
145
+ ```
146
+ # Save
147
+ import soundfile as sf
148
+
149
+ sf.write(
150
+ file="output_file.wav",
151
+ samplerate=sample_rate,
152
+ data=result_array
153
+ )
154
+ ```
155
+
156
+ ```
157
+ # Play; need to install ipython
158
+ from IPython.display import Audio
159
+
160
+ Audio(result_array, rate=sample_rate)
161
+ ```
162
+ When settings or the tag are altered, the model requires reloading. To maintain multiple preloaded models, you can instantiate another BaseLoader object.
163
+ ```
164
+ second_converter = BaseLoader()
165
+ ```
166
+ # Credits
167
+ - RVC-Project
168
+ - FFMPEG
169
+
170
+ # License
171
+ This project is licensed under the MIT License.
172
+
173
+ # Disclaimer
174
+ 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.
175
+
@@ -0,0 +1,139 @@
1
+ # RVC-Python-Fast Inference
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 installed.
20
+
21
+ Pre-requirements:
22
+ ```
23
+ pip install pip>=24 setuptools<=80.6.0
24
+ ```
25
+
26
+ ### Installation
27
+
28
+ ```
29
+ pip install infer_rvc_python
30
+ ```
31
+
32
+ # Usage
33
+
34
+ ## Initialize the base class
35
+
36
+ ```
37
+ from infer_rvc_python import BaseLoader
38
+
39
+ converter = BaseLoader(only_cpu=False, hubert_path=None, rmvpe_path=None)
40
+ ```
41
+ `hubert_path` now accepts a pretrained model instead of a `.pt` file, with `r3gm/hubert_base` as the default value.
42
+
43
+
44
+ ## Define a tag and select the model along with other parameters.
45
+
46
+ ```
47
+ converter.apply_conf(
48
+ tag="yoimiya",
49
+ file_model="model.pth",
50
+ pitch_algo="rmvpe+",
51
+ pitch_lvl=0,
52
+ file_index="model.index",
53
+ index_influence=0.66,
54
+ respiration_median_filtering=3,
55
+ envelope_ratio=0.25,
56
+ consonant_breath_protection=0.33
57
+ )
58
+ ```
59
+
60
+ ## Select the audio or audios you want to convert.
61
+
62
+ ```
63
+ # audio_files = ["audio.wav", "haha.mp3"]
64
+ audio_files = "myaudio.mp3"
65
+
66
+ # speakers_list = ["sunshine", "yoimiya"]
67
+ speakers_list = "yoimiya"
68
+ ```
69
+
70
+ ## Perform inference
71
+
72
+ ```
73
+ result = converter(
74
+ audio_files,
75
+ speakers_list,
76
+ overwrite=False,
77
+ parallel_workers=4
78
+ )
79
+ ```
80
+ The `result` is a list with the paths of the converted files.
81
+
82
+ ## Unload models
83
+ ```
84
+ converter.unload_models()
85
+ ```
86
+
87
+ # Preloading model (Reduces inference time)
88
+
89
+ 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.
90
+ ```
91
+ result_array, sample_rate = converter.generate_from_cache(
92
+ audio_data="myaudiofile_path.wav",
93
+ tag="yoimiya",
94
+ )
95
+ ```
96
+
97
+ The param audio_data can be a path or a tuple with (array_data, sampling_rate)
98
+
99
+ ```
100
+ # array_data = np.array([-22, -22, -15, ..., 0, 0, 0], dtype=np.int16)
101
+ # source_sample_rate = 16000
102
+ data = (array_data, source_sample_rate)
103
+ result_array, sample_rate = converter.generate_from_cache(
104
+ audio_data=data,
105
+ tag="yoimiya",
106
+ )
107
+ ```
108
+ The result in both cases will be (array, sample_rate), which you can save or play in a notebook
109
+
110
+ ```
111
+ # Save
112
+ import soundfile as sf
113
+
114
+ sf.write(
115
+ file="output_file.wav",
116
+ samplerate=sample_rate,
117
+ data=result_array
118
+ )
119
+ ```
120
+
121
+ ```
122
+ # Play; need to install ipython
123
+ from IPython.display import Audio
124
+
125
+ Audio(result_array, rate=sample_rate)
126
+ ```
127
+ When settings or the tag are altered, the model requires reloading. To maintain multiple preloaded models, you can instantiate another BaseLoader object.
128
+ ```
129
+ second_converter = BaseLoader()
130
+ ```
131
+ # Credits
132
+ - RVC-Project
133
+ - FFMPEG
134
+
135
+ # License
136
+ This project is licensed under the MIT License.
137
+
138
+ # Disclaimer
139
+ 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.
@@ -0,0 +1 @@
1
+ from .main import BaseLoader
@@ -0,0 +1,21 @@
1
+ import ffmpeg
2
+ import numpy as np
3
+
4
+
5
+ def load_audio(file, sr):
6
+ try:
7
+ # https://github.com/openai/whisper/blob/main/whisper/audio.py#L26
8
+ # This launches a subprocess to decode audio while down-mixing and resampling as necessary.
9
+ # Requires the ffmpeg CLI and `ffmpeg-python` package to be installed.
10
+ file = (
11
+ file.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
12
+ ) # To prevent beginners from copying paths with leading or trailing spaces, quotation marks, and line breaks.
13
+ out, _ = (
14
+ ffmpeg.input(file, threads=0)
15
+ .output("-", format="f32le", acodec="pcm_f32le", ac=1, ar=sr)
16
+ .run(cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True)
17
+ )
18
+ except Exception as e:
19
+ raise RuntimeError(f"Failed to load audio: {e}")
20
+
21
+ return np.frombuffer(out, np.float32).flatten()