keithito / tacotron

A TensorFlow implementation of Google's Tacotron speech synthesis with pre-trained model (unofficial)
MIT License
2.96k stars 957 forks source link

librosa.util.exceptions.ParameterError: data must be floating-point #187

Closed cogmeta closed 6 years ago

cogmeta commented 6 years ago

Traceback (most recent call last): File "/usr/lib/python3.5/wsgiref/handlers.py", line 137, in run self.result = application(self.environ, self.start_response) File "/usr/local/lib/python3.5/dist-packages/falcon/api.py", line 227, in call responder(req, resp, **params) File "demo_server.py", line 70, in on_get res.data = synthesizer.synthesize(req.params.get('text')) File "/home/ubuntu/speech/tts/tacotron/synthesizer.py", line 39, in synthesize audio.save_wav(wav, out) File "/home/ubuntu/speech/tts/tacotron/util/audio.py", line 16, in save_wav librosa.output.write_wav(path, wav.astype(np.int16), hparams.sample_rate) File "/usr/local/lib/python3.5/dist-packages/librosa/output.py", line 223, in write_wav util.valid_audio(y, mono=False) File "/usr/local/lib/python3.5/dist-packages/librosa/util/utils.py", line 159, in valid_audio raise ParameterError('data must be floating-point') librosa.util.exceptions.ParameterError: data must be floating-point 49.32.65.177 - - [10/Jul/2018 01:26:29] "GET /synthesize?text=tell%20the%20time HTTP/1.1" 500 59

librosa versions is 0.5.1

pip3 list | grep librosa librosa (0.5.1)

JuniverseCoder commented 6 years ago

I change librosa.output.write_wav(path, wav.astype(np.int16), hparams.sample_rate) in audio.py to librosa.output.write_wav(path, wav, hparams.sample_rate) , and it work to me.

cogmeta commented 6 years ago

That fixed it, Thanks @745245208

sunnnnnnnny commented 6 years ago

@745245208 I experimented according to your practice. There is really no bug, but the synthesized wav file is not empty, but there is no sound. Have you ever encountered a similar situation?

JuniverseCoder commented 6 years ago

i finally solved the problem by this code

from scipy.io import wavfile
def save_wav(wav, path):
    wav *= 32767 / max(0.01, np.max(np.abs(wav)))
    wavfile.write(path, hparams.sample_rate, wav.astype(np.int16))
npujcong commented 6 years ago

I change librosa.output.write_wav(path, wav.astype(np.int16), hparams.sample_rate) in audio.py to librosa.output.write_wav(path, wav, hparams.sample_rate) , and it work to me.

can't get the right waveform, the SNR is not correct. scipy.io.wavfile.write(path, hparams.sample_rate, wav.astype(np.int16)) cant figure out!

alokprasad commented 5 years ago

i finally solved the problem by this code

from scipy.io import wavfile
def save_wav(wav, path):
    wav *= 32767 / max(0.01, np.max(np.abs(wav)))
    wavfile.write(path, hparams.sample_rate, wav.astype(np.int16))

This worked like charm, This solution do not worked for me as librosa.output.write_wav(path, wav, hparams.sample_rate) it produced invalid wav file.