Add the period for VITS multi-period discriminator in model_args

This commit is contained in:
Edresson Casanova 2022-04-21 10:03:37 -03:00
parent 9252b3c5bd
commit adcc2f8299
4 changed files with 10 additions and 7 deletions

View File

@ -114,7 +114,7 @@ synthesizer = Synthesizer(
use_multi_speaker = hasattr(synthesizer.tts_model, "num_speakers") and ( use_multi_speaker = hasattr(synthesizer.tts_model, "num_speakers") and (
synthesizer.tts_model.num_speakers > 1 or synthesizer.tts_speakers_file is not None synthesizer.tts_model.num_speakers > 1 or synthesizer.tts_speakers_file is not None
) )
print("Multispeaker?", use_multi_speaker, synthesizer.tts_model.num_speakers)
speaker_manager = getattr(synthesizer.tts_model, "speaker_manager", None) speaker_manager = getattr(synthesizer.tts_model, "speaker_manager", None)
# TODO: set this from SpeakerManager # TODO: set this from SpeakerManager
use_gst = synthesizer.tts_config.get("use_gst", False) use_gst = synthesizer.tts_config.get("use_gst", False)

View File

@ -58,10 +58,8 @@ class VitsDiscriminator(nn.Module):
use_spectral_norm (bool): if `True` swith to spectral norm instead of weight norm. use_spectral_norm (bool): if `True` swith to spectral norm instead of weight norm.
""" """
def __init__(self, use_spectral_norm=False): def __init__(self, periods=(2, 3, 5, 7, 11), use_spectral_norm=False):
super().__init__() super().__init__()
periods = [2, 3, 5, 7, 11]
self.nets = nn.ModuleList() self.nets = nn.ModuleList()
self.nets.append(DiscriminatorS(use_spectral_norm=use_spectral_norm)) self.nets.append(DiscriminatorS(use_spectral_norm=use_spectral_norm))
self.nets.extend([DiscriminatorP(i, use_spectral_norm=use_spectral_norm) for i in periods]) self.nets.extend([DiscriminatorP(i, use_spectral_norm=use_spectral_norm) for i in periods])

View File

@ -362,6 +362,9 @@ class VitsArgs(Coqpit):
upsample_kernel_sizes_decoder (List[int]): upsample_kernel_sizes_decoder (List[int]):
Kernel sizes for each upsampling layer of the decoder network. Defaults to `[16, 16, 4, 4]`. Kernel sizes for each upsampling layer of the decoder network. Defaults to `[16, 16, 4, 4]`.
periods_multi_period_discriminator (List[int]):
Periods values for Vits Multi-Period Discriminator. Defaults to `[2, 3, 5, 7, 11]`.
use_sdp (bool): use_sdp (bool):
Use Stochastic Duration Predictor. Defaults to True. Use Stochastic Duration Predictor. Defaults to True.
@ -475,6 +478,7 @@ class VitsArgs(Coqpit):
upsample_rates_decoder: List[int] = field(default_factory=lambda: [8, 8, 2, 2]) upsample_rates_decoder: List[int] = field(default_factory=lambda: [8, 8, 2, 2])
upsample_initial_channel_decoder: int = 512 upsample_initial_channel_decoder: int = 512
upsample_kernel_sizes_decoder: List[int] = field(default_factory=lambda: [16, 16, 4, 4]) upsample_kernel_sizes_decoder: List[int] = field(default_factory=lambda: [16, 16, 4, 4])
periods_multi_period_discriminator: List[int] = field(default_factory=lambda: [2, 3, 5, 7, 11])
use_sdp: bool = True use_sdp: bool = True
noise_scale: float = 1.0 noise_scale: float = 1.0
inference_noise_scale: float = 0.667 inference_noise_scale: float = 0.667
@ -628,7 +632,7 @@ class Vits(BaseTTS):
) )
if self.args.init_discriminator: if self.args.init_discriminator:
self.disc = VitsDiscriminator(use_spectral_norm=self.args.use_spectral_norm_disriminator) self.disc = VitsDiscriminator(periods=self.args.periods_multi_period_discriminator, use_spectral_norm=self.args.use_spectral_norm_disriminator)
if self.args.TTS_part_sample_rate: if self.args.TTS_part_sample_rate:
self.interpolate_factor = self.config.audio["sample_rate"] / self.args.TTS_part_sample_rate self.interpolate_factor = self.config.audio["sample_rate"] / self.args.TTS_part_sample_rate

View File

@ -73,10 +73,11 @@ config.use_language_weighted_sampler = True
# test upsample # test upsample
config.model_args.TTS_part_sample_rate = 11025 config.model_args.TTS_part_sample_rate = 11025
config.model_args.interpolate_z = True config.model_args.interpolate_z = False
config.model_args.detach_z_vocoder = True config.model_args.detach_z_vocoder = True
config.model_args.upsample_rates_decoder = [8, 8, 2, 2] config.model_args.upsample_rates_decoder = [8, 8, 4, 2]
config.model_args.periods_multi_period_discriminator = [2, 3, 5, 7, 11, 13, 17, 19, 23]
config.save_json(config_path) config.save_json(config_path)