-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: stereo transform, convert always to 2 channels
- Loading branch information
1 parent
fbe0932
commit cdb7e1a
Showing
6 changed files
with
22 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
from .all import AllTransform | ||
from .crop import Crop | ||
from .duplicate_channels import DuplicateChannels | ||
from .loudness import Loudness | ||
from .overlap_channels import OverlapChannels | ||
from .randomcrop import RandomCrop | ||
from .resample import Resample | ||
from .scale import Scale | ||
from .stereo import Stereo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from torch import Tensor, nn | ||
|
||
|
||
class Stereo(nn.Module): | ||
def forward(self, x: Tensor) -> Tensor: | ||
shape = x.shape | ||
channels = shape[0] | ||
if len(shape) == 1: # s -> 2, s | ||
x = x.unsqueeze(0).repeat(2, 1) | ||
elif len(shape) == 2: | ||
if channels == 1: # 1, s -> 2, s | ||
x = x.repeat(2, 1) | ||
elif channels > 2: # ?, s -> 2,s | ||
x = x[:2, :] | ||
return x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters