get_duration can not work on generated audio <int16>
See original GitHub issueDescribe the bug
Traceback (most recent call last):
File "tts/tts.py", line 223, in <module>
timeDuration = librosa.get_duration(y=result, sr=sr)
File "python3.7/site-packages/librosa/core/audio.py", line 722, in get_duration
util.valid_audio(y, mono=False)
File "python3.7/site-packages/librosa/util/utils.py", line 290, in valid_audio
raise ParameterError("Audio data must be floating-point")
librosa.util.exceptions.ParameterError: Audio data must be floating-point
To Reproduce
Example:
import librosa
from tts import textToSpeech
import soundfile as sf
wav, sr = textToSpeech("hello world") # wav numpy int16 array
sf.write("result.wav", wav, sr) # it's ok.
timeDuration = librosa.get_duration(y=wav, sr=sr) # raise error
print("timeDuration",timeDuration)
Expected behavior
Get the duration from the int16 audio data.
Software versions* Please run the following Python code snippet and paste the output below.
Linux-5.4.0-80-generic-x86_64-with-debian-bullseye-sid
Python 3.7.10 (default, Jun 4 2021, 14:48:32)
[GCC 7.5.0]
NumPy 1.18.5
SciPy 1.7.0
librosa 0.8.1
INSTALLED VERSIONS
------------------
python: 3.7.10 (default, Jun 4 2021, 14:48:32)
[GCC 7.5.0]
librosa: 0.8.1
audioread: 2.1.9
numpy: 1.18.5
scipy: 1.7.0
sklearn: 0.24.2
joblib: 1.0.1
decorator: 4.4.2
soundfile: 0.10.3
resampy: 0.2.2
numba: 0.48.0
numpydoc: None
sphinx: None
sphinx_rtd_theme: None
sphinxcontrib.versioning: None
sphinx-gallery: None
pytest: None
pytest-mpl: None
pytest-cov: None
matplotlib: 3.3.4
presets: None
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Determine WAV Duration Time in Visual Studio 2019
I need to determine the duration (length of time) of a WAV audio file. I would like to get the results in milliseconds...
Read more >sf::InputSoundFile Class Reference (SFML / Learn / 2.5.1 ...
getDuration () Get the total duration of the sound file. This function is provided for convenience, the duration is deduced from the other...
Read more >How to fill buffers with data not from files · Issue #29 · kcat/alure
I'd like to generate sine waves (or audio synthesis via oscillators in general) with Alure/OpenAL but have no idea how to do that....
Read more >Non-Realtime Synthesis (NRT) | SuperCollider 3.12.2 Help
The server processes audio as fast as possible, or as slow as necessary, depending only on workload. There is no attempt to synchronize...
Read more >SoundBuffer - SFML - Simple and Fast Multimedia Library
bool, loadFromSamples (const Int16 *samples, std::size_t sampleCount, unsigned int ... Sound buffers alone are not very useful: they hold the audio data but ......
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
@tcelox Great! Let me know if you need any help 😃
@radioactive11 yes, I will raise the pull request by this week end.