Skip to content

Commit

Permalink
chore(format): run black on main
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Feb 15, 2025
1 parent 7a4793d commit ffa785a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
19 changes: 10 additions & 9 deletions rvc/lib/algorithm/generators/hifigan_mrf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import math
from typing import Optional

import numpy as np
Expand Down Expand Up @@ -274,7 +273,7 @@ def __init__(
self.noise_convs = torch.nn.ModuleList()

# f0 input gets upscaled to full segment size, then downscaled back to match each upscale step

# segment upscaling mel downscaling f0
# 36 = input z = 17280 / (2 x 2 x 10 x 12)
# 432 = 36 x 12 = 17280 / (2 x 2 x 10)
Expand All @@ -284,9 +283,9 @@ def __init__(

stride_f0s = [
upsample_rates[1] * upsample_rates[2] * upsample_rates[3],
upsample_rates[2] * upsample_rates[3],
upsample_rates[3],
1,
upsample_rates[2] * upsample_rates[3],
upsample_rates[3],
1,
]

for i, (u, k) in enumerate(zip(upsample_rates, upsample_kernel_sizes)):
Expand All @@ -307,7 +306,7 @@ def __init__(
torch.nn.Conv1d(
in_channels=1,
out_channels=upsample_initial_channel // (2 ** (i + 1)),
kernel_size = 1
kernel_size=1,
)
)
else:
Expand All @@ -323,7 +322,7 @@ def __init__(
)
)
)

self.noise_convs.append(
torch.nn.Conv1d(
1,
Expand Down Expand Up @@ -363,7 +362,9 @@ def forward(
# in-place call
x += self.cond(g)

for ups, upr, mrf, noise_conv in zip(self.upsamples, self.upsampler, self.mrfs, self.noise_convs):
for ups, upr, mrf, noise_conv in zip(
self.upsamples, self.upsampler, self.mrfs, self.noise_convs
):
# in-place call
x = torch.nn.functional.leaky_relu_(x, LRELU_SLOPE)

Expand All @@ -379,7 +380,7 @@ def forward(
h = noise_conv(har_source)
if self.upp == 441:
h = torch.nn.functional.interpolate(h, size=x.shape[-1], mode="linear")

x += h

def mrf_sum(x, layers):
Expand Down
21 changes: 10 additions & 11 deletions rvc/lib/algorithm/generators/refinegan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import math
import numpy as np
import torch
from torch import nn
Expand Down Expand Up @@ -321,7 +320,7 @@ def __init__(
self.checkpointing = checkpointing
self.upp = int(np.prod(upsample_rates))
assert self.upp == sample_rate // 100

self.m_source = SineGenerator(sample_rate)

# expanded f0 sinegen -> match mel_conv
Expand All @@ -335,9 +334,9 @@ def __init__(
bias=False,
)
)

# f0 input gets upscaled to full segment size, then downscaled back to match each upscale step

# segment upscaling mel downscaling f0
# 36 = input z = 17280 / (2 x 2 x 10 x 12)
# 432 = 36 x 12 = 17280 / (2 x 2 x 10)
Expand All @@ -347,23 +346,23 @@ def __init__(

stride_f0s = [
upsample_rates[1] * upsample_rates[2] * upsample_rates[3],
upsample_rates[2] * upsample_rates[3],
upsample_rates[3],
1,
upsample_rates[2] * upsample_rates[3],
upsample_rates[3],
1,
]

channels = upsample_initial_channel

self.downsample_blocks = nn.ModuleList([])
for i, u in enumerate(upsample_rates):
# 44k f0 downsampling is done using F.interpolate in the forward call due to 2.205 multiplier

# 44k f0 downsampling is done using F.interpolate in the forward call due to 2.205 multiplier
if self.upp == 441:
self.downsample_blocks.append(
nn.Conv1d(
in_channels=1,
out_channels=channels // 2 ** (i + 2),
kernel_size = 1
kernel_size=1,
)
)
else:
Expand Down Expand Up @@ -466,7 +465,7 @@ def forward(self, mel: torch.Tensor, f0: torch.Tensor, g: torch.Tensor = None):
h = down(har_source)
if self.upp == 441:
h = F.interpolate(h, size=x.shape[-1], mode="linear")
x = torch.cat([x, h], dim=1)
x = torch.cat([x, h], dim=1)
x = checkpoint(res, x, use_reentrant=False)
else:
x = ups(x)
Expand Down
8 changes: 2 additions & 6 deletions tabs/inference/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,10 @@ def get_presets_data(pitch, index_rate, rms_mix_rate, protect):
}


def export_presets_button(
preset_name, pitch, index_rate, rms_mix_rate, protect
):
def export_presets_button(preset_name, pitch, index_rate, rms_mix_rate, protect):
if preset_name:
file_path = os.path.join(PRESETS_DIR, f"{preset_name}.json")
presets_data = get_presets_data(
pitch, index_rate, rms_mix_rate, protect
)
presets_data = get_presets_data(pitch, index_rate, rms_mix_rate, protect)
with open(file_path, "w", encoding="utf-8") as json_file:
json.dump(presets_data, json_file, ensure_ascii=False, indent=4)
return "Export successful"
Expand Down

0 comments on commit ffa785a

Please sign in to comment.