CSTR-Edinburgh / merlin

This is now the official location of the Merlin project.
http://www.cstr.ed.ac.uk/projects/merlin/
Apache License 2.0
1.31k stars 440 forks source link

World synthesis very sensitive to very slight changes #489

Open salah-zaiem opened 5 years ago

salah-zaiem commented 5 years ago

I am trying to synthesize wavs from numpy arrays regrouping the features needed in World Vocoder Synthesis ("mgc", "bap", "lf0"). For the moment, my numpy arrays are just concatenated features scaled. In the following code I just load these arrays, inverse scale them, and then dispatch them into the corresponding binary files.

However when I run the synthesis script on these new binary files, it fails, with this error: x2x : error: input data is over the range of type 'double'! The error is due to differences in the mgc files, because when I replace it with the initial one, it works. When I checked for the absolute differences between my mgc file and the initial one, it was lower than 10exp(-26) ( due to scaling /rescaling maybe ) I do not think that the synthesizer is sensitive to such differences, so what am I doing wrong here ? Here is the code to reform the binary files ? ( i am using the scripts in merlin/misc/scripts/vocoder/world/ )

 j = np.load(infile)
 sc = joblib.load(scaler)
 j = sc.inverse_transform(j)
 mgc = j[:, 0:60]
 bap = j[:, 60]
 lf0 = j[:, 61]
 for i in range(lf0.shape[0]) :
     if lf0[i] < -100000000 :
         lf0[i] = -6.08244970e+77
 mgc_pth = os.path.join(os.path.join(outdir, "mgc"), fname + ".mgc" )
 bap_pth = os.path.join(os.path.join(outdir, "bap"), fname + ".bap" )
 lf0_pth = os.path.join(os.path.join(outdir, "lf0"), fname + ".lf0" )
 write_binfile(mgc, mgc_pth)
 write_binfile(lf0, lf0_pth)
 write_binfile(bap, bap_pth)

with write_binfile being :

def write_binfile(m_data, filename, dtype=np.float64):
     '''
     Writes numpy array into binary file.
     '''

     m_data = np.array(m_data, dtype)

     m_data.tofile(filename)
     return