From 6cc2279fb9539e1a75f58a33a305d18451442988 Mon Sep 17 00:00:00 2001 From: Ftps <63702646+Tps-F@users.noreply.github.com> Date: Wed, 10 May 2023 22:17:13 +0900 Subject: [PATCH] Support mps generate (#263) --- config.py | 1 + vc_infer_pipeline.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/config.py b/config.py index 496b3cb..ca4c67b 100644 --- a/config.py +++ b/config.py @@ -86,6 +86,7 @@ class Config: elif torch.backends.mps.is_available(): print("没有发现支持的N卡, 使用MPS进行推理") self.device = "mps" + self.is_half = False else: print("没有发现支持的N卡, 使用CPU进行推理") self.device = "cpu" diff --git a/vc_infer_pipeline.py b/vc_infer_pipeline.py index 2b8e099..1d9313b 100644 --- a/vc_infer_pipeline.py +++ b/vc_infer_pipeline.py @@ -246,6 +246,8 @@ class VC(object): pitch, pitchf = self.get_f0(audio_pad, p_len, f0_up_key, f0_method, inp_f0) pitch = pitch[:p_len] pitchf = pitchf[:p_len] + if self.device == "mps": + pitchf = pitchf.astype(np.float32) pitch = torch.tensor(pitch, device=self.device).unsqueeze(0).long() pitchf = torch.tensor(pitchf, device=self.device).unsqueeze(0).float() t2 = ttime()