[numpy] Fix users of NumPy APIs that are removed in NumPy 2.0.
This change migrates users of APIs removed in NumPy 2.0 to their recommended replacements (https://numpy.org/devdocs/numpy_2_0_migration_guide.html). Bug: None Change-Id: I5c275ed3f39863d42b5c34df0723933f7a8b94a0 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/358020 Reviewed-by: Lionel Koenig <lionelk@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42684}
This commit is contained in:
parent
2a8cca6a5d
commit
e02a200f5e
@ -316,11 +316,11 @@ class SignalProcessingUtils(object):
|
||||
An AudioSegment instance.
|
||||
"""
|
||||
# Handle infinite target SNR.
|
||||
if target_snr == -np.Inf:
|
||||
if target_snr == -np.inf:
|
||||
# Return a copy of noise.
|
||||
logging.warning('SNR = -Inf, returning noise')
|
||||
return cls.Copy(noise)
|
||||
elif target_snr == np.Inf:
|
||||
elif target_snr == np.inf:
|
||||
# Return a copy of signal.
|
||||
logging.warning('SNR = +Inf, returning signal')
|
||||
return cls.Copy(signal)
|
||||
@ -328,11 +328,11 @@ class SignalProcessingUtils(object):
|
||||
# Check signal and noise power.
|
||||
signal_power = float(signal.dBFS)
|
||||
noise_power = float(noise.dBFS)
|
||||
if signal_power == -np.Inf:
|
||||
if signal_power == -np.inf:
|
||||
logging.error('signal has -Inf power, cannot mix')
|
||||
raise exceptions.SignalProcessingException(
|
||||
'cannot mix a signal with -Inf power')
|
||||
if noise_power == -np.Inf:
|
||||
if noise_power == -np.inf:
|
||||
logging.error('noise has -Inf power, cannot mix')
|
||||
raise exceptions.SignalProcessingException(
|
||||
'cannot mix a signal with -Inf power')
|
||||
|
||||
@ -35,9 +35,9 @@ class TestSignalProcessing(unittest.TestCase):
|
||||
signal_samples = signal.get_array_of_samples()
|
||||
noise_samples = noise.get_array_of_samples()
|
||||
|
||||
# Test target SNR -Inf (noise expected).
|
||||
# Test target SNR -inf (noise expected).
|
||||
mix_neg_inf = signal_processing.SignalProcessingUtils.MixSignals(
|
||||
signal, noise, -np.Inf)
|
||||
signal, noise, -np.inf)
|
||||
self.assertTrue(len(noise), len(mix_neg_inf)) # Check duration.
|
||||
mix_neg_inf_samples = mix_neg_inf.get_array_of_samples()
|
||||
self.assertTrue( # Check samples.
|
||||
@ -54,9 +54,9 @@ class TestSignalProcessing(unittest.TestCase):
|
||||
self.assertTrue(
|
||||
any([x != y for x, y in zip(noise_samples, mix_0_samples)]))
|
||||
|
||||
# Test target SNR +Inf (signal expected).
|
||||
# Test target SNR +inf (signal expected).
|
||||
mix_pos_inf = signal_processing.SignalProcessingUtils.MixSignals(
|
||||
signal, noise, np.Inf)
|
||||
signal, noise, np.inf)
|
||||
self.assertTrue(len(signal), len(mix_pos_inf)) # Check duration.
|
||||
mix_pos_inf_samples = mix_pos_inf.get_array_of_samples()
|
||||
self.assertTrue( # Check samples.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user