1
0
mirror of https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI.git synced 2026-06-07 02:00:25 +08:00

optimize(rvc): gather residuals

This commit is contained in:
源文雨
2024-06-08 00:44:46 +09:00
parent eb24434260
commit b91dcf2261
9 changed files with 210 additions and 200 deletions

View File

@@ -1,6 +1,7 @@
from typing import Any, Optional
import numpy as np
import pyworld
import typing
from .f0 import F0Predictor
@@ -10,7 +11,7 @@ class DioF0Predictor(F0Predictor):
super().__init__(hop_length, f0_min, f0_max, sampling_rate)
def compute_f0(
self, wav: np.ndarray[typing.Any, np.dtype], p_len: int | None = None
self, wav: np.ndarray[Any, np.dtype], p_len: Optional[int] = None
):
if p_len is None:
p_len = wav.shape[0] // self.hop_length
@@ -27,7 +28,7 @@ class DioF0Predictor(F0Predictor):
return self.__interpolate_f0(self.__resize_f0(f0, p_len))[0]
def compute_f0_uv(
self, wav: np.ndarray[typing.Any, np.dtype], p_len: int | None = None
self, wav: np.ndarray[Any, np.dtype], p_len: Optional[int] = None
):
if p_len is None:
p_len = wav.shape[0] // self.hop_length

View File

@@ -1,5 +1,6 @@
from typing import Any, Optional
import numpy as np
import typing
class F0Predictor(object):
@@ -10,14 +11,14 @@ class F0Predictor(object):
self.sampling_rate = sampling_rate
def compute_f0(
self, wav: np.ndarray[typing.Any, np.dtype], p_len: int | None = None
self, wav: np.ndarray[Any, np.dtype], p_len: Optional[int] = None
): ...
def compute_f0_uv(
self, wav: np.ndarray[typing.Any, np.dtype], p_len: int | None = None
self, wav: np.ndarray[Any, np.dtype], p_len: Optional[int] = None
): ...
def __interpolate_f0(self, f0: np.ndarray[typing.Any, np.dtype]):
def __interpolate_f0(self, f0: np.ndarray[Any, np.dtype]):
"""
对F0进行插值处理
"""
@@ -55,7 +56,7 @@ class F0Predictor(object):
return ip_data[:, 0], vuv_vector[:, 0]
def __resize_f0(self, x: np.ndarray[typing.Any, np.dtype], target_len: int):
def __resize_f0(self, x: np.ndarray[Any, np.dtype], target_len: int):
source = np.array(x)
source[source < 0.001] = np.nan
target = np.interp(

View File

@@ -1,6 +1,7 @@
from typing import Any, Optional
import numpy as np
import pyworld
import typing
from .f0 import F0Predictor
@@ -10,7 +11,7 @@ class HarvestF0Predictor(F0Predictor):
super().__init__(hop_length, f0_min, f0_max, sampling_rate)
def compute_f0(
self, wav: np.ndarray[typing.Any, np.dtype], p_len: int | None = None
self, wav: np.ndarray[Any, np.dtype], p_len: Optional[int] = None
):
if p_len is None:
p_len = wav.shape[0] // self.hop_length
@@ -25,7 +26,7 @@ class HarvestF0Predictor(F0Predictor):
return self.__interpolate_f0(self.__resize_f0(f0, p_len))[0]
def compute_f0_uv(
self, wav: np.ndarray[typing.Any, np.dtype], p_len: int | None = None
self, wav: np.ndarray[Any, np.dtype], p_len: Optional[int] = None
):
if p_len is None:
p_len = wav.shape[0] // self.hop_length

View File

@@ -1,6 +1,7 @@
from typing import Any, Optional
import numpy as np
import parselmouth
import typing
from .f0 import F0Predictor
@@ -10,7 +11,7 @@ class PMF0Predictor(F0Predictor):
super().__init__(hop_length, f0_min, f0_max, sampling_rate)
def compute_f0(
self, wav: np.ndarray[typing.Any, np.dtype], p_len: int | None = None
self, wav: np.ndarray[Any, np.dtype], p_len: Optional[int] = None
):
x = wav
if p_len is None:
@@ -36,7 +37,7 @@ class PMF0Predictor(F0Predictor):
return f0
def compute_f0_uv(
self, wav: np.ndarray[typing.Any, np.dtype], p_len: int | None = None
self, wav: np.ndarray[Any, np.dtype], p_len: Optional[int] = None
):
x = wav
if p_len is None: