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.

get_duration can not work on generated audio <int16>

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
radioactive11commented, Aug 27, 2021

@tcelox Great! Let me know if you need any help 😃

1reaction
tceloxcommented, Aug 27, 2021

@radioactive11 yes, I will raise the pull request by this week end.

Read more comments on GitHub >

github_iconTop 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 >

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