def pad_frames(signal, n_frames, how='replicate'):
    """
    Pad a signal to n_frames.

    :param signal: input to pad. Shape is frames X n_features where frames < n_frames
    :param n_frames: number of frames to pad to
    :param how: replicate the beginning of the signal or 0 padding
    :return: padded signal
    """
    n_features = len(signal[0])
    if how == '0':
        return signal + (n_frames - len(signal)) * [n_features*[0]]
    if how == 'replicate':
        while len(signal) != n_frames:
            signal += signal[:(n_frames - len(signal))]
        return signal