This commit is contained in:
w-okada 2023-07-15 05:47:06 +09:00
parent 8a2df2dbb4
commit 8339e72ef5
4 changed files with 5 additions and 6 deletions

View File

@ -137,7 +137,6 @@ class Pipeline(object):
audio16k.squeeze(),
pitchf,
f0_up_key,
16000, # 音声のサンプリングレート(既に16000)
int(self.hop_size), # 処理のwindowサイズ (44100における512)
silence_front=silence_front,
)

View File

@ -16,7 +16,7 @@ class DioPitchExtractor(PitchExtractor):
self.sapmle_rate = 16000
self.uv_interp = True
def extract(self, audio: torch.Tensor, pitch, f0_up_key, sr, window, silence_front=0):
def extract(self, audio: torch.Tensor, pitch, f0_up_key, window, silence_front=0):
audio = audio.detach().cpu().numpy()
start_frame = int(silence_front * self.sapmle_rate / window)
real_silence_front = start_frame * window / self.sapmle_rate

View File

@ -16,7 +16,7 @@ class HarvestPitchExtractor(PitchExtractor):
self.sapmle_rate = 16000
self.uv_interp = True
def extract(self, audio: torch.Tensor, pitch, f0_up_key, sr, window, silence_front=0):
def extract(self, audio: torch.Tensor, pitch, f0_up_key, window, silence_front=0):
audio = audio.detach().cpu().numpy()
start_frame = int(silence_front * self.sapmle_rate / window)
real_silence_front = start_frame * window / self.sapmle_rate

View File

@ -45,13 +45,13 @@ class VolumeExtractor:
mask = upsample(mask, block_size).squeeze(-1)
return mask
def get_mask_from_volume_t(self, volume: torch.Tensor, block_size: int, threshold=-60.0, device='cpu') -> torch.Tensor:
def get_mask_from_volume_t(self, volume: torch.Tensor, block_size: int, threshold=-60.0) -> torch.Tensor:
volume = volume.squeeze()
mask = (volume > 10.0 ** (float(threshold) / 20)).float()
mask = (volume > 10.0 ** (float(threshold) / 20)).to(volume.device).float()
mask = nn.functional.pad(mask, (4, 0), 'constant', mask[0])
mask = nn.functional.pad(mask, (0, 4), 'constant', mask[-1])
mask = torch.max(mask.unfold(-1, 9, 1), -1)[0]
mask = mask.to(device).unsqueeze(-1).unsqueeze(0)
mask = mask.unsqueeze(-1).unsqueeze(0)
mask = upsample(mask, block_size).squeeze(-1)
return mask