Hmmm it’s a long story.
When data is different length you can pad the data.
Nowadays, there are architectures which deals with different-length samples (transformers).
The way to go is measuring or estimating the maximum length possible and then padding your samples according to that.
Another way is doing chunks of a representative length and working with a reduced duration.