In this tutorial, we will introduce you how to fix this error: TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘int’. You can learn our solution to fix your question.
For example:
n_fft =1024, hop_size = 256 win_size = 1024 y = torch.nn.functional.pad(y.unsqueeze(1), (int((n_fft-hop_size)/2), int((n_fft-hop_size)/2)), mode='reflect')
Run this code, we will see:
How to fix this TypeError?
In order to fix this error, we should notice the type of n_fft.
print(n_fft, type(n_fft))
We will find n_fft is a tuple, not an integer.
(1024,) <class 'tuple'>
In order to fix this error, we can fix as follows:
Modify
n_fft =1024,
to
n_fft =1024
Then, we will find this error is fixed.