Spaces:
Build error
Build error
Update src/vc_infer_pipeline.py
Browse files1123465891011678910111222 unmodified lines353637403839404142434344454645474849504751525354555657403 unmodified lines46146246345746446546646746846947047146146247247347447547628 unmodified lines505506507497498508509510511512from functools import lru_cacheimport numpy as np, parselmouth, torch, pdb, sys, osfrom time import time as ttimeimport torch.nn.functional as Fimport torchcrepefrom scipy import signalfrom torch import Tensorimport pyworld, os, faiss, librosa, torchcrepeimport randomimport gcimport reimport scipy.signal as signalimport pyworld, os, traceback, faiss, librosa, torchcrepefrom scipy import signalfrom functools import lru_cache
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))now_dir = os.path.join(BASE_DIR, 'src')22 unmodified lines
def change_rms(data1, sr1, data2, sr2, rate): rms1 = librosa.feature.rms(y=data1, frame_length=sr1 // 2 * 2, hop_length=sr1 // 2) rms1 = librosa.feature.rms( y=data1, frame_length=sr1 // 2 * 2, hop_length=sr1 // 2 ) rms2 = librosa.feature.rms(y=data2, frame_length=sr2 // 2 * 2, hop_length=sr2 // 2) rms1 = torch.from_numpy(rms1) rms1 = F.interpolate(rms1.unsqueeze(0), size=data2.shape[0], mode="linear").squeeze() rms1 = F.interpolate( rms1.unsqueeze(0), size=data2.shape[0], mode="linear" ).squeeze() rms2 = torch.from_numpy(rms2) rms2 = F.interpolate(rms2.unsqueeze(0), size=data2.shape[0], mode="linear").squeeze() rms2 = F.interpolate( rms2.unsqueeze(0), size=data2.shape[0], mode="linear" ).squeeze() rms2 = torch.max(rms2, torch.zeros_like(rms2) + 1e-6) data2 *= (torch.pow(rms1, torch.tensor(1 - rate))* torch.pow(rms2, torch.tensor(rate - 1))).numpy() data2 *= ( torch.pow(rms1, torch.tensor(1 - rate)) * torch.pow(rms2, torch.tensor(rate - 1)) ).numpy() return data2
403 unmodified lines crepe_hop_length, f0_file=None, ): if file_index != "" and os.path.exists(file_index) == True and index_rate != 0: if ( file_index != "" and os.path.exists(file_index) == True and index_rate != 0 ): try: index = faiss.read_index(file_index) big_npy = index.reconstruct_n(0, index.ntotal) except Exception as error: print(error) except: traceback.print_exc() index = big_npy = None else: index = big_npy = None28 unmodified lines for line in lines: inp_f0.append([float(i) for i in line.split(",")]) inp_f0 = np.array(inp_f0, dtype="float32") except Exception as error: print(error) except: traceback.print_exc() sid = torch.tensor(sid, device=self.device).unsqueeze(0).long() pitch, pitchf = None, None if if_f0 == 1:src/vc_infer_pipeline.py+26-15