Transfer Bot commited on
Commit
8733ee3
·
0 Parent(s):

Moved to Hugging Face automatically

Browse files
Files changed (6) hide show
  1. .gitattributes +53 -0
  2. README.md +223 -0
  3. app.py +0 -0
  4. gitignore +19 -0
  5. requirements-training.txt +32 -0
  6. requirements.txt +14 -0
.gitattributes ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.whl filter=lfs diff=lfs merge=lfs -text
37
+ *.png filter=lfs diff=lfs merge=lfs -text
38
+ *.jpg filter=lfs diff=lfs merge=lfs -text
39
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
40
+ *.gif filter=lfs diff=lfs merge=lfs -text
41
+ *.webp filter=lfs diff=lfs merge=lfs -text
42
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
43
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
44
+ *.wav filter=lfs diff=lfs merge=lfs -text
45
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
46
+ *.pdf filter=lfs diff=lfs merge=lfs -text
47
+ *.woff filter=lfs diff=lfs merge=lfs -text
48
+ *.woff2 filter=lfs diff=lfs merge=lfs -text
49
+ *.ttf filter=lfs diff=lfs merge=lfs -text
50
+ *.eot filter=lfs diff=lfs merge=lfs -text
51
+ *.ico filter=lfs diff=lfs merge=lfs -text
52
+ *.sqlite3 filter=lfs diff=lfs merge=lfs -text
53
+ *.db filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: RVC-v2 + Beatrice-v2 Voice Conversion + training
3
+ emoji: 🎤
4
+ colorFrom: red
5
+ colorTo: yellow
6
+ sdk: gradio
7
+ python_version: "3.10"
8
+ sdk_version: 6.3.0
9
+ app_file: app.py
10
+ pinned: false
11
+ license: mit
12
+ tags:
13
+ - voice-conversion
14
+ - rvc
15
+ - beatrice
16
+ - beatrice-v2
17
+ - audio
18
+ - mcp-server
19
+ short_description: RVC-v2 Beatrice-v2 - CPU inference + training
20
+ ---
21
+
22
+ # RVC + Beatrice Voice Conversion
23
+
24
+ **CPU Inference + Training** - Single-file app for HuggingFace Spaces.
25
+
26
+ ## Features
27
+
28
+ - **Voice Conversion** - RVC v2 (.pth) + Beatrice v2 (.pt.gz)
29
+ - **Training** - Train both model types (GPU recommended, CPU works but slow)
30
+ - **Single File** - Everything in one `app.py`
31
+ - **CLI Support** - Command-line interface for batch processing
32
+
33
+ ## Voice Conversion
34
+
35
+ 1. Upload source audio (any format)
36
+ 2. Select **Model Type**: RVC v2 or Beatrice v2
37
+ 3. Get a model into the inputs one of three ways:
38
+ - **Upload manually** — .pth for RVC, .pt.gz for Beatrice.
39
+ - **Retrieve by tracking code** — under **"📥 بازیابی خودکار مدل"**, paste the tracking code from a finished Training job and click **"🔄 بازیابی مدل"**. The already-trained model (and index, for RVC) is pulled straight from the server — nothing to upload.
40
+ - **Load from a URL** — paste a direct link to a `.zip` (containing the `.pth`/`.pt.gz` and optionally `.index`) or to a raw model file, and click **"⬇️ دانلود از لینک"**. The server downloads and unpacks it and drops the files into the right slots automatically — this doesn't use your own upload bandwidth at all, only the server's.
41
+ 4. Adjust pitch shift if needed
42
+ 5. Click Convert
43
+
44
+ **Default model:** [audo/Benee-RVC](https://huggingface.co/audo/Benee-RVC) (RVC v2)
45
+
46
+ ## Training
47
+
48
+ 1. Select **Trainer**: RVC v2 or Beatrice v2
49
+ 2. Upload training audio, either way:
50
+ - **ZIP upload (recommended for many files):** zip up all your training audio files (any mix of .wav/.mp3/.flac/.ogg/.m4a/.aac/.wma/.opus/.aiff, subfolders ok) and upload the ZIP. It's auto-extracted, the file count is auto-detected, and every file is auto-added to the training slots — no manual per-file selection.
51
+ - **One-by-one:** start with one file; after each upload, an **"➕ افزودن فایل صوتی دیگر" (add another file)** button appears right below it, letting you add up to 100 files total.
52
+
53
+ All uploaded files (from either method) are combined (in order, with a short silence gap between them) into one training set.
54
+ 3. Enter model name
55
+ 4. Adjust epochs (up to 5000 for RVC v2) and batch size
56
+ 5. Click **Start Training**
57
+
58
+ Training runs as a **background job on the server**, not tied to your browser tab:
59
+
60
+ - As soon as you click Start Training, you instantly get a **tracking code** (e.g. `4F9A2C`) — you don't wait for training to finish.
61
+ - You can close the tab or refresh the page; training keeps going on the server.
62
+ - Go to the **📡 پیگیری آموزش / Track Training** tab any time, enter your tracking code, and click **Check Status** to see live progress/logs.
63
+ - Once training finishes, the same tab lets you download the trained model (and index file, for RVC).
64
+ - **You don't have to wait for training to finish.** A checkpoint is saved periodically during the run (e.g. the 600-epoch checkpoint of a 1000-epoch target) — download it from the tracking tab any time, or go to **🎵 Voice Conversion → "📥 بازیابی خودکار مدل"**, enter the same tracking code, and test-convert with that in-progress checkpoint right away while training keeps going in the background.
65
+ - You can also cancel a queued or running job from that tab using the same tracking code.
66
+
67
+ **Note:** CPU training works but is slow. For faster training, clone locally with CUDA GPU. Keep your tracking code — it stays valid as long as the Space itself hasn't restarted.
68
+
69
+ ## Compatibility
70
+
71
+ - **RVC v1** (256-dim HuBERT) - with f0 or no-f0
72
+ - **RVC v2** (768-dim HuBERT) - with f0 or no-f0
73
+ - **Beatrice v2** - 16kHz input, 24kHz output, per-speaker VQ
74
+ - **Index retrieval** (.index files) for RVC voice matching
75
+
76
+ Model version and f0 flag are auto-detected from the checkpoint.
77
+
78
+ Find models: [HuggingFace](https://huggingface.co/models?search=rvc) | [Weights.gg](https://weights.gg)
79
+
80
+ ---
81
+
82
+ ## API
83
+
84
+ ### Python Client - Voice Conversion
85
+
86
+ ```python
87
+ from gradio_client import Client, handle_file
88
+
89
+ client = Client("Luminia/rvc-voice-conversion")
90
+
91
+ # RVC v2 inference
92
+ result = client.predict(
93
+ source_audio=handle_file("voice.wav"),
94
+ model_type="RVC v2",
95
+ model_file=handle_file("model.pth"),
96
+ index_file=None, # Optional .index file
97
+ beatrice_model_file=None, # Not used for RVC
98
+ beatrice_target_speaker=0, # Not used for RVC
99
+ beatrice_formant_shift=0.0, # Not used for RVC
100
+ pitch_shift=0, # -12 to 12 semitones
101
+ f0_method="pm", # "pm" or "harvest"
102
+ index_rate=0.75, # 0-1, voice retrieval strength
103
+ protect=0.33, # 0-0.5, voiceless consonant protection
104
+ api_name="/convert"
105
+ )
106
+ print(result) # (output_path, status_message)
107
+
108
+ # Beatrice v2 inference
109
+ result = client.predict(
110
+ source_audio=handle_file("voice.wav"),
111
+ model_type="Beatrice v2",
112
+ model_file=None, # Not used for Beatrice
113
+ index_file=None, # Not used for Beatrice
114
+ beatrice_model_file=handle_file("beatrice_model.pt.gz"),
115
+ beatrice_target_speaker=0, # Speaker index
116
+ beatrice_formant_shift=0.0, # -2 to 2
117
+ pitch_shift=0, # -12 to 12 semitones
118
+ f0_method="pm", # Ignored for Beatrice
119
+ index_rate=0.75, # Ignored for Beatrice
120
+ protect=0.33, # Ignored for Beatrice
121
+ api_name="/convert"
122
+ )
123
+ print(result) # (output_path, status_message)
124
+ ```
125
+
126
+ ### Python Client - Training (background job + tracking code)
127
+
128
+ Training is asynchronous: `/train` registers the job and returns a **tracking code**
129
+ immediately (it does not wait for training to finish). Poll `/check_training_status`
130
+ with that code to get progress/logs, and to fetch the model once it's done.
131
+
132
+ ```python
133
+ from gradio_client import Client, handle_file
134
+ import time
135
+
136
+ client = Client("Luminia/rvc-voice-conversion")
137
+
138
+ # 1) Submit an RVC v2 training request — returns instantly
139
+ tracking_code, status_msg = client.predict(
140
+ trainer="RVC v2",
141
+ train_audio=handle_file("voice.wav"),
142
+ train_model_name="my_voice",
143
+ train_epochs=200, # 1-5000
144
+ train_batch=2, # Batch size
145
+ train_sr=40000, # 32000, 40000, or 48000
146
+ beatrice_epochs=30, # Ignored for RVC
147
+ beatrice_batch=8, # Ignored for RVC
148
+ beatrice_resume=False, # Ignored for RVC
149
+ api_name="/train"
150
+ )
151
+ print("Tracking code:", tracking_code)
152
+
153
+ # 2) Poll status any time later (even after restarting your script)
154
+ while True:
155
+ log, progress, model_path, index_path = client.predict(
156
+ tracking_code, api_name="/check_training_status"
157
+ )
158
+ print(log, progress)
159
+ if model_path or "خطا" in log or "لغو" in log:
160
+ break
161
+ time.sleep(15)
162
+
163
+ # 3) Cancel a queued/running job if needed
164
+ # client.predict(tracking_code, api_name="/cancel_training")
165
+ ```
166
+
167
+ Beatrice v2 training uses the same `/train` call, just with `trainer="Beatrice v2"`
168
+ and the `beatrice_*` parameters filled in instead.
169
+
170
+ ### MCP (Model Context Protocol)
171
+
172
+ This Space supports MCP for AI assistants (Claude Desktop, Cursor, VS Code).
173
+
174
+ 1. Click **MCP** badge → **Add to MCP tools**
175
+ 2. The `convert` and `train` tools become available
176
+
177
+ **MCP Config:**
178
+ ```json
179
+ {
180
+ "mcpServers": {
181
+ "rvc": {"url": "https://luminia-rvc-voice-conversion.hf.space/gradio_api/mcp/"}
182
+ }
183
+ }
184
+ ```
185
+
186
+ ---
187
+
188
+ ## CLI Usage
189
+
190
+ ### Inference
191
+ ```bash
192
+ # RVC v2
193
+ python app.py infer -i voice.wav -m model.pth -o output.wav
194
+
195
+ # Beatrice v2 (auto-detected from .pt.gz extension)
196
+ python app.py infer -i voice.wav -m beatrice_model.pt.gz -o output.wav
197
+
198
+ # With pitch shift
199
+ python app.py infer -i voice.wav -m model.pth -p 2 -o output.wav
200
+
201
+ # Beatrice with speaker/formant options
202
+ python app.py infer -i voice.wav -m beatrice.pt.gz --speaker 0 --formant-shift 1.0 -o output.wav
203
+ ```
204
+
205
+ ### Training
206
+ ```bash
207
+ # RVC v2 training
208
+ python app.py train -a voice.mp3 -o ./my_model --epochs 100
209
+
210
+ # Beatrice v2 training
211
+ python app.py train-beatrice -a voice.mp3 -o ./beatrice_model --epochs 30
212
+
213
+ # Beatrice resume training
214
+ python app.py train-beatrice -a voice.mp3 -o ./beatrice_model --epochs 30 --resume
215
+ ```
216
+
217
+ ---
218
+
219
+ - Local real-time model usage: https://huggingface.co/wok000/vcclient000/tree/main
220
+
221
+ ## Credits
222
+
223
+ Based on [RVC-Project](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI)-[Mangio-UI-Fork](https://github.com/Mangio621/Mangio-RVC-Fork), [Applio](https://github.com/IAHispano/Applio) data processing, and [Beatrice v2](https://huggingface.co/fierce-cats/beatrice-trainer)
app.py ADDED
The diff for this file is too large to render. See raw diff
 
gitignore ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__/
2
+ *.pyc
3
+ *.wav
4
+ *.flac
5
+ *.mp3
6
+ *.index
7
+ *.pth
8
+ nul
9
+
10
+ # Test/training artifacts
11
+ test_*/
12
+ train_*/
13
+ F_p340_*/
14
+ beatrice_test/
15
+
16
+ # Dev scripts
17
+ detect_noise.py
18
+ test_applio_ab.py
19
+ app_beatrice.py
requirements-training.txt ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RVC Training Requirements (CUDA GPU required)
2
+ # Run: pip install -r requirements-training.txt
3
+
4
+ # PyTorch with CUDA (install separately based on your CUDA version)
5
+ # pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
6
+
7
+ # Core
8
+ numpy
9
+ scipy
10
+ librosa
11
+ soundfile
12
+ praat-parselmouth
13
+
14
+ # Training
15
+ fairseq
16
+ pyworld
17
+ faiss-gpu # Use faiss-cpu if no GPU
18
+ torchcrepe
19
+
20
+ # F0 extraction
21
+ onnxruntime-gpu # Use onnxruntime for CPU
22
+
23
+ # Web UI
24
+ gradio>=4.0.0
25
+
26
+ # Utils
27
+ tqdm
28
+ tensorboard
29
+ ffmpeg-python
30
+
31
+ # For model export
32
+ onnx
requirements.txt ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ --extra-index-url https://download.pytorch.org/whl/cpu
2
+ torch
3
+ torchaudio
4
+ gradio>=6.0.0
5
+ numpy
6
+ librosa
7
+ soundfile
8
+ huggingface_hub
9
+ requests
10
+ transformers
11
+ praat-parselmouth
12
+ pyworld
13
+ faiss-cpu
14
+ scipy