def test_select_streams(): static_stream_sizes = [60, 1, 1, 1] x = torch.zeros(32, 100, 63) assert select_streams(x, static_stream_sizes, streams=[ True, True, True, True]).size() == (32, 100, 63) assert select_streams(x, static_stream_sizes, streams=[ True, False, False, False]).size() == (32, 100, 60) assert select_streams(x, static_stream_sizes, streams=[ True, False, False, True]).size() == (32, 100, 61) x = torch.arange(0, 63).expand(32, 100, 63) assert (select_streams(x, static_stream_sizes, streams=[ False, False, False, True]).squeeze(-1) == x[:, :, -1]).all() assert (select_streams(x, static_stream_sizes, streams=[ False, False, True, False]).squeeze(-1) == x[:, :, -2]).all() assert (select_streams(x, static_stream_sizes, streams=[ False, True, False, False]).squeeze(-1) == x[:, :, -3]).all() # Multiple selects y = select_streams(x, static_stream_sizes, streams=[ True, False, False, True]) assert (y[:, :, :60] == x[:, :, :60]).all() assert (y[:, :, -1] == x[:, :, -1]).all() y = select_streams(x, static_stream_sizes, streams=[ True, True, False, False]) assert (y[:, :, :60] == x[:, :, :60]).all() assert (y[:, :, 60] == x[:, :, 60]).all()
def get_selected_static_stream(y_hat_static): static_stream_sizes = get_static_stream_sizes(hp.stream_sizes, hp.has_dynamic_features, len(hp.windows)) y_hat_selected = select_streams(y_hat_static, static_stream_sizes, streams=hp.adversarial_streams) # 0-th mgc with adversarial trainging affects speech quality # ref: saito17asja_gan.pdf if hp.mask_0th_mgc_for_adv_loss: assert hp == hparams.tts_acoustic y_hat_selected = y_hat_selected[:, :, 1:] return y_hat_selected
def test_select_streams(): static_stream_sizes = [60, 1, 1, 1] x = torch.zeros(32, 100, 63) assert select_streams(x, static_stream_sizes, streams=[True, True, True, True]).size() == (32, 100, 63) assert select_streams(x, static_stream_sizes, streams=[True, False, False, False]).size() == (32, 100, 60) assert select_streams(x, static_stream_sizes, streams=[True, False, False, True]).size() == (32, 100, 61) x = torch.arange(0, 63).expand(32, 100, 63) assert (select_streams(x, static_stream_sizes, streams=[False, False, False, True]).squeeze(-1) == x[:, :, -1]).all() assert (select_streams(x, static_stream_sizes, streams=[False, False, True, False]).squeeze(-1) == x[:, :, -2]).all() assert (select_streams(x, static_stream_sizes, streams=[False, True, False, False]).squeeze(-1) == x[:, :, -3]).all() # Multiple selects y = select_streams(x, static_stream_sizes, streams=[True, False, False, True]) assert (y[:, :, :60] == x[:, :, :60]).all() assert (y[:, :, -1] == x[:, :, -1]).all() y = select_streams(x, static_stream_sizes, streams=[True, True, False, False]) assert (y[:, :, :60] == x[:, :, :60]).all() assert (y[:, :, 60] == x[:, :, 60]).all()