diff --git a/rvc/f0/fcpe.py b/rvc/f0/fcpe.py index bf8897e..d60a1fc 100644 --- a/rvc/f0/fcpe.py +++ b/rvc/f0/fcpe.py @@ -1,8 +1,7 @@ -from typing import Any, Optional, Union +from typing import Optional, Union import numpy as np import torch -from torchfcpe import spawn_bundled_infer_model from .f0 import F0Predictor @@ -24,6 +23,8 @@ class FCPE(F0Predictor): device, ) + from torchfcpe import spawn_bundled_infer_model # must be imported at here, or it will cause fairseq crash on training + self.model = spawn_bundled_infer_model(self.device) def compute_f0( diff --git a/rvc/layers/encoders.py b/rvc/layers/encoders.py index 2c3f00a..1fc2478 100644 --- a/rvc/layers/encoders.py +++ b/rvc/layers/encoders.py @@ -192,7 +192,7 @@ class PosteriorEncoder(nn.Module): def __call__( self, x: torch.Tensor, x_lengths: torch.Tensor, g: Optional[torch.Tensor] = None ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]: - super().__call__(x, x_lengths, g=g) + return super().__call__(x, x_lengths, g=g) def forward( self, x: torch.Tensor, x_lengths: torch.Tensor, g: Optional[torch.Tensor] = None diff --git a/rvc/layers/utils.py b/rvc/layers/utils.py index d979087..418578b 100644 --- a/rvc/layers/utils.py +++ b/rvc/layers/utils.py @@ -20,9 +20,9 @@ def slice_on_last_dim( start_indices: List[int], segment_size=4, ) -> torch.Tensor: - new_shape = x.shape + new_shape = [*x.shape] new_shape[-1] = segment_size - ret = torch.empty(new_shape) + ret = torch.empty(new_shape, device=x.device) for i in range(x.size(0)): idx_str = start_indices[i] idx_end = idx_str + segment_size