File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
art/defences/preprocessor Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,10 @@ def wav_to_mp3(x, sample_rate):
115115 x_mp3 = x_mp3 * 2 ** - 15
116116 return x_mp3 .astype (x_dtype )
117117
118+ x_orig_type = x .dtype
119+ if x .dtype != object and x .ndim == 2 :
120+ x = x .astype (object )
121+
118122 if x .dtype != object and x .ndim != 3 :
119123 raise ValueError ("Mp3 compression can only be applied to temporal data across at least one channel." )
120124
@@ -146,6 +150,9 @@ def wav_to_mp3(x, sample_rate):
146150 if x .dtype != object and self .channels_first :
147151 x_mp3 = np .swapaxes (x_mp3 , 1 , 2 )
148152
153+ if x_orig_type != object and x .dtype == object and x .ndim == 2 :
154+ x_mp3 = x_mp3 .astype (x_orig_type )
155+
149156 return x_mp3 , y
150157
151158 def _check_params (self ) -> None :
You can’t perform that action at this time.
0 commit comments