question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

librosa.util.normalize doesn't preserve dtype

See original GitHub issue
In [1]: import librosa

In [2]: y, sr = librosa.load(librosa.util.example_audio_file())

In [3]: y.dtype
Out[3]: dtype('float32')

In [4]: y = librosa.util.normalize(y)

In [5]: y.dtype
Out[5]: dtype('float64')

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
bmcfeecommented, Oct 11, 2017

Fixed by merging #636

1reaction
carlthomecommented, Aug 11, 2017

IMO dtype should be preserved, but not forced to be float32. It should be enough to just get rid of .astype(np.float) as np.abs will preserve dtype as expected AFAIK.

E.g.

>>> import numpy as np
>>> a = np.zeros(1, dtype=np.complex64)
>>> np.abs(a).dtype
dtype('float32')
>>> a = np.zeros(1, dtype=np.float64)
>>> np.abs(a).dtype
dtype('float64')
>>> a = np.zeros(1, dtype=np.float32)
>>> np.abs(a).dtype
dtype('float32')
Read more comments on GitHub >

github_iconTop Results From Across the Web

librosa.util.normalize — librosa 0.10.0.dev0 documentation
Only the columns (or rows) with norm at least threshold are normalized. By default, the threshold is determined from the numerical precision of...
Read more >
librosa does not normalize wave file between [-1, 1]
The behaviour you are observing stems directly from resampling to 22050 Hz that librosa load does by default: librosa.core.load(path, ...
Read more >
Source code for librosa.util.utils
Or its second dimension >>> librosa.util.pad_center(data, 7, ... if fill is True: raise ParameterError('Cannot normalize with norm=0 and fill=True') length ...
Read more >
torchaudio.transforms - PyTorch
https://librosa.org/doc/latest/generated/librosa.amplitude_to_db.html ... functional form will retain higher precision, but run slower because it does not ...
Read more >
librosa Changelog - PyUp.io
PyUp actively tracks 474,986 Python packages for vulnerabilities to keep your Python ... `librosa.util.example_audio_file` is now deprecated in favor of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found