Skip to content

Commit 01504e2

Browse files
committed
change resampling method to librosa in real-time-gui
1 parent 800af65 commit 01504e2

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

real-time-gui.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -979,21 +979,15 @@ def audio_callback(
979979
self.input_wav[-indata.shape[0] :] = torch.from_numpy(indata).to(
980980
self.config.device
981981
)
982-
# self.input_wav_res[: -self.block_frame_16k] = self.input_wav_res[
983-
# self.block_frame_16k :
984-
# ].clone()
985-
# self.input_wav_res[-320 * (indata.shape[0] // self.zc + 1) :] = (
986-
# self.resampler(self.input_wav[-indata.shape[0] - 2 * self.zc :])[
987-
# 320:
988-
# ]
989-
# )
990-
self.input_wav_res = torch.from_numpy(
991-
librosa.resample(
992-
self.input_wav.cpu().numpy(),
993-
orig_sr=self.gui_config.samplerate,
994-
target_sr=16000
995-
)
996-
).to(self.config.device)
982+
self.input_wav_res[: -self.block_frame_16k] = self.input_wav_res[
983+
self.block_frame_16k :
984+
].clone()
985+
self.input_wav_res[-320 * (indata.shape[0] // self.zc + 1) :] = (
986+
# self.resampler(self.input_wav[-indata.shape[0] - 2 * self.zc :])[
987+
# 320:
988+
# ]
989+
torch.from_numpy(librosa.resample(self.input_wav[-indata.shape[0] - 2 * self.zc :].cpu().numpy(), orig_sr=self.gui_config.samplerate, target_sr=16000)[320:])
990+
)
997991
print(f"preprocess time: {time.perf_counter() - start_time:.2f}")
998992
# infer
999993
if self.function == "vc":

0 commit comments

Comments
 (0)