File size: 637 Bytes
2cddd11 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# Copyright (c) ByteDance, Inc. and its affiliates.
# Copyright (c) Chutong Meng
#
# This source code is licensed under the CC BY-NC license found in the
# LICENSE file in the root directory of this source tree.
# Based on AudioDec (https://github.com/facebookresearch/AudioDec)
import numpy as np
import torch
class ReprCollater(object):
def __call__(self, batch):
xs = []
for b in batch:
if b is not None:
xs.append(b)
x_batch = np.stack(xs, axis=0)
x_batch = torch.tensor(x_batch, dtype=torch.float).transpose(1, 2) # (B, T, C) -> (B, C, T)
return x_batch
|