High-Pass Filter Pytorch

While trying to preprocess the signal, it shows this error TypeError: torch.Size() takes an iterable of 'int' (item 0 is 'tuple') . However, I’m using PyTorch for audio preprocessing, and want to apply the High-Pass Filter over the entire load signals. The below code is my current try with PyTorch. Hence, how can I use the High-Pass filter with PyTorch? my signals shape is torch.Size([30, 100, 100]) , each signal shape is torch.Size([1, 100, 100]) . Here is my code:

import torch
from load_data import AudioRead
from scipy import signal


SAMPLE_RATE = 48000
CARRIER_FREQUENCY = 18000
BOTTOM_FREQUENCY = 19000
TOP_FREQUENCY = 17000
CUT_OFF = 5
BANDWITH = BOTTOM_FREQUENCY - TOP_FREQUENCY


def high_pass_filter(signal_data, cut_off, sample_rate, carrier_frequency, bandwith):
    """
    Based DSP for audio signal processing
    :return:
    :rtype:
    """

    [b, a] = torch.FloatTensor(signal.butter(cut_off, (carrier_frequency - bandwith/2) / (sample_rate/2), 'high'))
    signal_size = torch.Size(signal_data)
    for ii in range(1, len(signal_size)):
        if signal_data != 0:
            signal_data[ii] = filter([b, a, signal_data[ii, :]])
        else:
            raise ValueError("Signals are not iterable. Null !!!!")
    return b, a


if __name__ == '__main__':
    path_dir = r"D:\ACG-Data\acg"
    ANNOTATION_FILE = r"D:\ACG-Data\acg\training_rate.csv"
    TRANSFORMATION = None
    SAMPLE_RATE = 48000
    REAL_SAMPLE_RATE = 48000

    if torch.cuda.is_available():
        DEVICE = 'cuda'
    else:
        DEVICE = 'cpu'

    data_load = AudioRead(ANNOTATION_FILE, path_dir, 
    TRANSFORMATION, SAMPLE_RATE, 
     REAL_SAMPLE_RATE, DEVICE)

    high_pass_filter(data_load, CUT_OFF, SAMPLE_RATE, CARRIER_FREQUENCY, BANDWITH)

Error:

The usage of torch.Size() is wrong.
If you want to get the shape of a tensor, use tensor.size() or tensor.shape.

Thanks Sr for your attention. I have change to:

[b, a] = torch.FloatTensor(signal.butter(cut_off, (carrier_frequency - bandwith/2) / (sample_rate/2), 'high'))
    signal_size = signal_data.size()
    for ii in range(1, len(signal_size)):
        if signal_data != 0:
            signal_data[ii] = filter([b, a, signal_data[ii, :]])
        else:
            raise ValueError("Signals are not iterable. Null !!!!")
    return b, a

but shows this error: AttributeError: 'AudioRead' object has no attribute 'size'. AudioRead is the Dataset converted in tensor after some examination. How can I make the HP match with my dataset. Or, should I first consider the the data in numpy shape before convert to tensor? delete the torch.FloatTensor()?

Error:

As I understand, AudioRead is a class or function from the load_data module.
You have to call .size() on tensor data.

AudioRead is a class

While my AudioREad dataset is a tensor, I’m getting an array shape with a tensor. I want to maintain the shape of my data into tensor format to interact with the neural network. How to transform into tensor only, already the tensor.from_numpy() doesn’t work in this case.

Here my code

def high_pass_filter(signal_data, cut_off, sample_rate, order=5):

 
    nyquist = 0.5 * sample_rate
    normal_cutoff = cut_off / nyquist
    [b, a] = (signal.butter(order, normal_cutoff, btype='high', analog=False))
    signal_data = (signal.freqs(b, a, signal_data))
    print("les donnes de w+", signal_data)
    return signal_data

Why this error : ary = asanyarray(ary)