fix place error

pull/3900/head
drryanhuang 9 months ago
parent 7de2513d83
commit 5e0f85a738

@ -269,7 +269,7 @@ class AudioSignal(
num_tries: int=8, num_tries: int=8,
state: typing.Union[np.random.RandomState, int]=None, state: typing.Union[np.random.RandomState, int]=None,
**kwargs, ): **kwargs, ):
"""Similar to AudioSignal.excerpt, except it extracts excerpts only """Similar to AudioSignal.excerpt, except it extracts excerpts only
if they are above a specified loudness threshold, which is computed via if they are above a specified loudness threshold, which is computed via
a fast LUFS routine. a fast LUFS routine.
@ -315,7 +315,7 @@ class AudioSignal(
num_try = 0 num_try = 0
while loudness <= loudness_cutoff: while loudness <= loudness_cutoff:
excerpt = cls.excerpt(audio_path, state=state, **kwargs) excerpt = cls.excerpt(audio_path, state=state, **kwargs)
loudness = excerpt.loudness() # <---- NOT IMPLEMENTED YET loudness = excerpt.loudness()
num_try += 1 num_try += 1
if num_tries is not None and num_try >= num_tries: if num_tries is not None and num_try >= num_tries:
break break
@ -784,7 +784,14 @@ class AudioSignal(
if self.stft_data is not None: if self.stft_data is not None:
self.stft_data = self.stft_data.to(device) self.stft_data = self.stft_data.to(device)
if self.audio_data is not None: if self.audio_data is not None:
device = "gpu" if "cuda" == device else device if 'cpu' == device:
device = paddle.to_tensor(
self.audio_data, place=paddle.CPUPlace())
if 'gpu' == device or 'cuda' == device:
device = paddle.to_tensor(
self.audio_data, place=paddle.CUDAPlace())
device = device.replace("cuda",
"gpu") if "cuda" in device else device
self.audio_data = self.audio_data.to(device) self.audio_data = self.audio_data.to(device)
return self return self

Loading…
Cancel
Save