mirror of
https://github.com/svc-develop-team/so-vits-svc.git
synced 2025-01-09 04:27:31 +08:00
Merge branch '4.1-Latest' of https://github.com/svc-develop-team/so-vits-svc into 4.1-Latest
This commit is contained in:
commit
de267002bf
18
.github/workflows/reviewdog.yml
vendored
Normal file
18
.github/workflows/reviewdog.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
name: Ruff Autofix
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
ruff:
|
||||
permissions:
|
||||
checks: write
|
||||
contents: read
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: chartboost/ruff-action@v1
|
||||
with:
|
||||
args: --fix -e
|
||||
- uses: reviewdog/action-suggester@v1
|
||||
with:
|
||||
tool_name: ruff
|
||||
|
23
utils.py
23
utils.py
@ -6,12 +6,15 @@ import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import traceback
|
||||
from multiprocessing import cpu_count
|
||||
|
||||
import faiss
|
||||
import librosa
|
||||
import numpy as np
|
||||
import torch
|
||||
from scipy.io.wavfile import read
|
||||
from sklearn.cluster import MiniBatchKMeans
|
||||
from torch.nn import functional as F
|
||||
|
||||
MATPLOTLIB_FLAG = False
|
||||
@ -449,6 +452,7 @@ def change_rms(data1, sr1, data2, sr2, rate): # 1是输入音频,2是输出
|
||||
return data2
|
||||
|
||||
def train_index(spk_name,root_dir = "dataset/44k/"): #from: RVC https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI
|
||||
n_cpu = cpu_count()
|
||||
print("The feature index is constructing.")
|
||||
exp_dir = os.path.join(root_dir,spk_name)
|
||||
listdir_res = []
|
||||
@ -465,6 +469,25 @@ def train_index(spk_name,root_dir = "dataset/44k/"): #from: RVC https://github.
|
||||
big_npy_idx = np.arange(big_npy.shape[0])
|
||||
np.random.shuffle(big_npy_idx)
|
||||
big_npy = big_npy[big_npy_idx]
|
||||
if big_npy.shape[0] > 2e5:
|
||||
# if(1):
|
||||
info = "Trying doing kmeans %s shape to 10k centers." % big_npy.shape[0]
|
||||
print(info)
|
||||
try:
|
||||
big_npy = (
|
||||
MiniBatchKMeans(
|
||||
n_clusters=10000,
|
||||
verbose=True,
|
||||
batch_size=256 * n_cpu,
|
||||
compute_labels=False,
|
||||
init="random",
|
||||
)
|
||||
.fit(big_npy)
|
||||
.cluster_centers_
|
||||
)
|
||||
except: # noqa: E722
|
||||
info = traceback.format_exc()
|
||||
print(info)
|
||||
n_ivf = min(int(16 * np.sqrt(big_npy.shape[0])), big_npy.shape[0] // 39)
|
||||
index = faiss.index_factory(big_npy.shape[1] , "IVF%s,Flat" % n_ivf)
|
||||
index_ivf = faiss.extract_index_ivf(index) #
|
||||
|
Loading…
Reference in New Issue
Block a user