Skip to content

Commit

Permalink
chore: make Ruff happy
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Jul 5, 2023
1 parent bf543d2 commit f557072
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select = ["E", "F", "I"]

# Never enforce `E501` (line length violations).
ignore = ["E501"]
ignore = ["E501", "E741"]
4 changes: 2 additions & 2 deletions modules/DSConv.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import torch
import torch.nn as nn
from torch.nn.utils import weight_norm, remove_weight_norm
from torch.nn.utils import remove_weight_norm, weight_norm


class Depthwise_Separable_Conv1D(nn.Module):
def __init__(
Expand Down
4 changes: 3 additions & 1 deletion modules/mel_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def spectrogram_torch(y, n_fft, sampling_rate, hop_size, win_size, center=False)
y = y.squeeze(1)

y_dtype = y.dtype
if y.dtype == torch.bfloat16: y = y.to(torch.float32)
if y.dtype == torch.bfloat16:
y = y.to(torch.float32)

spec = torch.stft(y, n_fft, hop_length=hop_size, win_length=win_size, window=hann_window[wnsize_dtype_device],
center=center, pad_mode='reflect', normalized=False, onesided=True, return_complex=True)
spec = torch.view_as_real(spec).to(y_dtype)
Expand Down
10 changes: 6 additions & 4 deletions modules/modules.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import torch
from torch import nn
from torch.nn import Conv1d
from torch.nn import functional as F

from modules.DSConv import weight_norm_modules, remove_weight_norm_modules, Depthwise_Separable_Conv1D

import modules.commons as commons
from modules.commons import init_weights, get_padding
from modules.commons import get_padding, init_weights
from modules.DSConv import (
Depthwise_Separable_Conv1D,
remove_weight_norm_modules,
weight_norm_modules,
)

LRELU_SLOPE = 0.1

Expand Down
12 changes: 8 additions & 4 deletions webUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import time
import traceback
from itertools import chain
from pathlib import Path

# os.system("wget -P cvec/ https://huggingface.co/spaces/innnky/nanami/resolve/main/checkpoint_best_legacy_500.pt")
import gradio as gr
Expand All @@ -15,7 +16,6 @@
import soundfile
import torch
from scipy.io import wavfile
from pathlib import Path

from compress_model import removeOptimizer
from inference.infer_tool import Svc
Expand Down Expand Up @@ -172,14 +172,18 @@ def vc_fn(sid, input_audio, output_format, vc_transform, auto_f0,cluster_ratio,
model.clear_empty()
#os.remove(temp_path)
#构建保存文件的路径,并保存到results文件夹内
timestamp = str(int(time.time()))
str(int(time.time()))
if not os.path.exists("results"):
os.makedirs("results")
key = "auto" if auto_f0 else f"{int(vc_transform)}key"
cluster = "_" if cluster_ratio == 0 else f"_{cluster_ratio}_"
isdiffusion = "sovits"
if model.shallow_diffusion : isdiffusion = "sovdiff"
if model.only_diffusion : isdiffusion = "diff"
if model.shallow_diffusion:
isdiffusion = "sovdiff"

if model.only_diffusion:
isdiffusion = "diff"

output_file_name = 'result_'+truncated_basename+f'_{sid}_{key}{cluster}{isdiffusion}.{output_format}'
output_file = os.path.join("results", output_file_name)
soundfile.write(output_file, _audio, model.target_sample, format=output_format)
Expand Down

0 comments on commit f557072

Please sign in to comment.