get_duration fails on .wav when not loaded into memory v0.8
See original GitHub issueDescribe the bug
get_duration
should be able to get the length of an audio file without loading it into memory, according this solved issue: https://github.com/librosa/librosa/issues/345
However, when I try it on a .wav from the CREMA-D dataset, it fails with: ParameterError: Audio data must be floating-point
To Reproduce
import librosa
librosa.get_duration("1001_IEO_NEU_XX.wav")
Audio file(s):
- git clone CREMA-D with only .wav files (not video/MP3):
git clone --config lfs.fetchexclude='AudioMP3,VideoFlash' https://github.com/CheyneyComputerScience/CREMA-D.git
- Download this sample file: 1001_IEO_NEU_XX.zip
Expected behavior
Output the length of the audio file in seconds: 1.2832199546485261
Error If applicable, add screenshots to help explain your problem.
Software versions*
Linux-4.15.0-112-generic-x86_64-with-debian-buster-sid
Python 3.7.6 | packaged by conda-forge | (default, Jan 7 2020, 20:28:53)
[GCC 7.3.0]
NumPy 1.18.5
SciPy 1.5.0
librosa 0.8.0
INSTALLED VERSIONS
------------------
python: 3.7.6 | packaged by conda-forge | (default, Jan 7 2020, 20:28:53)
[GCC 7.3.0]
librosa: 0.8.0
audioread: 2.1.8
numpy: 1.18.5
scipy: 1.5.0
sklearn: 0.23.1
joblib: 0.16.0
decorator: 4.4.2
soundfile: 0.10.2
resampy: 0.2.2
numba: 0.50.1
numpydoc: None
sphinx: 2.3.1
sphinx_rtd_theme: 0.4.3
sphinxcontrib.versioning: None
sphinx-gallery: None
pytest: 5.4.3
pytest-mpl: None
pytest-cov: None
matplotlib: 3.1.1
presets: None
Additional context The following code does work, showing it shouldn’t be an issue with the .wav itself:
signal, sr = librosa.load("1001_IEO_HAP_HI.wav", sr=None)
librosa.get_duration(signal)
Might it be related to the change in default audio parser since v0.7.0?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Get .wav file length or duration - python - Stack Overflow
The duration is equal to the number of frames divided by the framerate (frames per second): import wave import contextlib fname ...
Read more >librosa.get_duration — librosa 0.10.0.dev0 documentation
Compute the duration (in seconds) of an audio time series, feature matrix, or filename. ... If provided, all other parameters are ignored, and...
Read more >How to synthesize speech from text - Azure - Microsoft Learn
In this article · Select synthesis language and voice · Synthesize speech to a file · Synthesize to speaker output · Get a...
Read more >SoundPool.play() looping stopped working in 4.3 [36976097]
Same problem on a Nexus 7, both infinite and finite looping are not working. The same code works on a phone running 4.2.2....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I guess if I checked the documentation more carefully, I would have noticed the
filename
keyword. Therefore, the possible breaking of people’s code to reduce one argument might not be worth it. If you want to keep it like this, I’ll close the issue (or you can close it).@NumesSanguis the recommended prototypes are:
get_duration(y=signal, sr=sr)
get_duration(filename=filename)
It’s less about the type of the first argument that about the number of arguments.