File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -178,21 +178,22 @@ def encode_audio_to_file_like(
178178 if samples .dtype != torch .float32 :
179179 raise ValueError (f"samples must have dtype torch.float32, got { samples .dtype } " )
180180
181- samples_contiguous = samples .contiguous ()
182-
183- data_ptr = samples_contiguous .data_ptr ()
184- shape = list (samples_contiguous .shape )
181+ samples = samples .contiguous ()
185182
186183 _pybind_ops .encode_audio_to_file_like (
187- data_ptr ,
188- shape ,
184+ samples . data_ptr () ,
185+ list ( samples . shape ) ,
189186 sample_rate ,
190187 format ,
191188 file_like ,
192189 bit_rate ,
193190 num_channels ,
194191 )
195192
193+ # This check is useless but it's critical to keep it to ensures that samples
194+ # is still alive during the call to encode_audio_to_file_like.
195+ assert samples .is_contiguous ()
196+
196197
197198# ==============================
198199# Abstract impl for the operators. Needed by torch.compile.
You can’t perform that action at this time.
0 commit comments