Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resume for the SVC's vocalist pretrained ckpt #8

Merged
merged 8 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ egs/svc/custom
egs/svc/*/dev*
egs/svc/dev_exp_config.json
bins/svc/demo*
bins/svc/preprocess_custom.py
data
ckpts

Expand Down
146 changes: 0 additions & 146 deletions bins/svc/preprocess_custom.py

This file was deleted.

11 changes: 3 additions & 8 deletions models/svc/base/svc_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,9 @@ def __init__(self, args, cfg, infer_type):
self.trans_key = args.trans_key
assert type(target_singer) == str

# self.target_singer = target_singer.split("_")[-1]
# self.target_dataset = target_singer.replace(
# "_{}".format(self.target_singer), ""
# )

self.target_dataset = target_singer.split("_")[0]
self.target_singer = target_singer.replace(
"{}_".format(self.target_dataset), ""
self.target_singer = target_singer.split("_")[-1]
self.target_dataset = target_singer.replace(
"_{}".format(self.target_singer), ""
)

self.target_mel_extrema = load_mel_extrema(cfg.preprocess, self.target_dataset)
Expand Down
45 changes: 25 additions & 20 deletions modules/encoder/condition_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,34 @@


class ContentEncoder(nn.Module):
def __init__(self, input_dim, output_dim):
def __init__(self, cfg, input_dim, output_dim):
super().__init__()

# if input_dim != 0:
# self.nn = nn.Linear(input_dim, output_dim)
self.cfg = cfg

assert input_dim != 0

# TODO: introduce conformer
self.pos_encoder = PositionalEncoding(input_dim)
self.conformer = Conformer(
input_dim=input_dim,
num_heads=2,
ffn_dim=256,
num_layers=6,
depthwise_conv_kernel_size=3,
)
self.nn = nn.Linear(input_dim, output_dim)

# Introduce conformer or not
if (
"use_conformer_for_content_features" in cfg
and cfg.use_conformer_for_content_features
):
self.pos_encoder = PositionalEncoding(input_dim)
self.conformer = Conformer(
input_dim=input_dim,
num_heads=2,
ffn_dim=256,
num_layers=6,
depthwise_conv_kernel_size=3,
)
else:
self.conformer = None

def forward(self, x, length=None):
# x: (N, seq_len, input_dim) -> (N, seq_len, output_dim)
x = self.pos_encoder(x)
x, _ = self.conformer(x, length)
if self.conformer:
x = self.pos_encoder(x)
x, _ = self.conformer(x, length)
return self.nn(x)


Expand Down Expand Up @@ -160,22 +165,22 @@ def __init__(self, cfg):

if cfg.use_whisper:
self.whisper_encoder = ContentEncoder(
self.cfg.whisper_dim, self.cfg.content_encoder_dim
self.cfg, self.cfg.whisper_dim, self.cfg.content_encoder_dim
)

if cfg.use_contentvec:
self.contentvec_encoder = ContentEncoder(
self.cfg.contentvec_dim, self.cfg.content_encoder_dim
self.cfg, self.cfg.contentvec_dim, self.cfg.content_encoder_dim
)

if cfg.use_mert:
self.mert_encoder = ContentEncoder(
self.cfg.mert_dim, self.cfg.content_encoder_dim
self.cfg, self.cfg.mert_dim, self.cfg.content_encoder_dim
)

if cfg.use_wenet:
self.wenet_encoder = ContentEncoder(
self.cfg.wenet_dim, self.cfg.content_encoder_dim
self.cfg, self.cfg.wenet_dim, self.cfg.content_encoder_dim
)

self.melody_encoder = MelodyEncoder(self.cfg)
Expand Down
3 changes: 3 additions & 0 deletions modules/whisper_extractor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
import torch
from tqdm import tqdm

from .audio import load_audio, log_mel_spectrogram, pad_or_trim
from .decoding import DecodingOptions, DecodingResult, decode, detect_language
from .model import Whisper, ModelDimensions
from .transcribe import transcribe
from .version import __version__


Expand Down