Format code (#89)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
github-actions[bot] 2023-04-17 14:09:03 +00:00 committed by GitHub
parent 35379217e8
commit 1e71efb265
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 8 deletions

12
gui.py
View File

@ -32,10 +32,10 @@ class RVC:
self.f0_max = 1100 self.f0_max = 1100
self.f0_mel_min = 1127 * np.log(1 + self.f0_min / 700) self.f0_mel_min = 1127 * np.log(1 + self.f0_min / 700)
self.f0_mel_max = 1127 * np.log(1 + self.f0_max / 700) self.f0_mel_max = 1127 * np.log(1 + self.f0_max / 700)
if index_rate !=0: if index_rate != 0:
self.index = faiss.read_index(index_path) self.index = faiss.read_index(index_path)
self.big_npy = np.load(npy_path) self.big_npy = np.load(npy_path)
print('index search enabled') print("index search enabled")
self.index_rate = index_rate self.index_rate = index_rate
model_path = hubert_path model_path = hubert_path
print("load model(s) from {}".format(model_path)) print("load model(s) from {}".format(model_path))
@ -111,11 +111,7 @@ class RVC:
feats = self.model.final_proj(logits[0]) feats = self.model.final_proj(logits[0])
####索引优化 ####索引优化
if ( if hasattr(self, "index") and hasattr(self, "big_npy") and self.index_rate != 0:
hasattr(self,'index')
and hasattr(self,'big_npy')
and self.index_rate != 0
):
npy = feats[0].cpu().numpy().astype("float32") npy = feats[0].cpu().numpy().astype("float32")
_, I = self.index.search(npy, 1) _, I = self.index.search(npy, 1)
npy = self.big_npy[I.squeeze()].astype("float16") npy = self.big_npy[I.squeeze()].astype("float16")
@ -124,7 +120,7 @@ class RVC:
+ (1 - self.index_rate) * feats + (1 - self.index_rate) * feats
) )
else: else:
print('index search FAIL or disabled') print("index search FAIL or disabled")
feats = F.interpolate(feats.permute(0, 2, 1), scale_factor=2).permute(0, 2, 1) feats = F.interpolate(feats.permute(0, 2, 1), scale_factor=2).permute(0, 2, 1)
torch.cuda.synchronize() torch.cuda.synchronize()