Add an assert for the upsampling trick (#1538)

This commit is contained in:
Eren Gölge 2022-05-12 19:55:24 +02:00 committed by GitHub
parent 6048959e24
commit 6e460b7e42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -1629,10 +1629,17 @@ class Vits(BaseTTS):
from TTS.utils.audio import AudioProcessor from TTS.utils.audio import AudioProcessor
upsample_rate = torch.prod(torch.as_tensor(config.model_args.upsample_rates_decoder)).item() upsample_rate = torch.prod(torch.as_tensor(config.model_args.upsample_rates_decoder)).item()
if not config.model_args.encoder_sample_rate: if not config.model_args.encoder_sample_rate:
assert ( assert (
upsample_rate == config.audio.hop_length upsample_rate == config.audio.hop_length
), f" [!] Product of upsample rates must be equal to the hop length - {upsample_rate} vs {config.audio.hop_length}" ), f" [!] Product of upsample rates must be equal to the hop length - {upsample_rate} vs {config.audio.hop_length}"
else:
encoder_to_vocoder_upsampling_factor = config.audio.sample_rate / config.model_args.encoder_sample_rate
effective_hop_length = config.audio.hop_length * encoder_to_vocoder_upsampling_factor
assert (
upsample_rate == effective_hop_length
), f" [!] Product of upsample rates must be equal to the hop length - {upsample_rate} vs {effective_hop_length}"
ap = AudioProcessor.init_from_config(config, verbose=verbose) ap = AudioProcessor.init_from_config(config, verbose=verbose)
tokenizer, new_config = TTSTokenizer.init_from_config(config) tokenizer, new_config = TTSTokenizer.init_from_config(config)