audiotools icon indicating copy to clipboard operation
audiotools copied to clipboard

Audio device movement for cpu only augmentation

Open DanTremonti opened this issue 1 year ago • 2 comments

Given that torchaudio.functional.apply_codec currently only supports "cpu" device ref, apply_codec effect may need moving the waveform to "cpu"

The below line of time_stretch effect

        waveform = self._to_2d().cpu()

moves the signal to "cpu", but the following line is from apply_codec effect

        waveform = self._to_2d()

If I'm not missing anything here, apply_codec effect is missing device handling.

Another small suggestion would be to have a flag that specifies if an effect does device movement. This will help users who are concerned about latency to effortlessly decide which effects to use, without having to look into every effect's implementation.

DanTremonti avatar Jun 20 '23 06:06 DanTremonti

Oh, that's fair. I can look into that and roll it into the next release!

Re: device movement, I think it should be possible to add something that moves back to the original device after the effect. The only reason for an effect to have device movement is because the underlying code doesn't support the original device. So I think we should just move stuff back to the original device, and allow users to just select latency by doing .cuda or .cpu calls between effects on the signal.

pseeth avatar Jun 22 '23 18:06 pseeth

So I think we should just move stuff back to the original device

Yes, you are right. I was implying the same as well. But, like you also mentioned,

only reason for an effect to have device movement is because the underlying code doesn't support the original device

I was merely suggesting to let user know, at least through docstring, that an effect is applied on cpu (despite moving back to input device).

DanTremonti avatar Jun 23 '23 06:06 DanTremonti