andabi / deep-voice-conversion

Deep neural networks for voice conversion (voice style transfer) in Tensorflow
MIT License
3.92k stars 845 forks source link

wav = read_wav(wav_file, sr=hp.default.sr) KeyError: 'default' #55

Open BlcDec opened 6 years ago

BlcDec commented 6 years ago

Traceback (most recent call last): File "C:\Users\blcdec\ApplicationInstallPlace\Anaconda3\envs\tensorflow\lib\multiprocessing\process.py", line 258, in _bootstrap self.run() File "C:\Users\blcdec\ApplicationInstallPlace\Anaconda3\envs\tensorflow\lib\site-packages\tensorpack\dataflow\parallel.py", line 162, in run for dp in self.ds.get_data(): File "C:\Users\blcdec\ApplicationInstallPlace\Anaconda3\envs\tensorflow\lib\site-packages\tensorpack\dataflow\common.py", line 116, in get_data for data in self.ds.get_data(): File "C:\Users\blcdec\project\deep-voice-conversion-master\deep-voice-conversion-master\data_load.py", line 35, in get_data yield get_mfccs_and_phones(wav_file=wav_file) File "C:\Users\blcdec\project\deep-voice-conversion-master\deep-voice-conversion-master\data_load.py", line 72, in get_mfccs_and_phones wav = read_wav(wav_file, sr=hp.default.sr) KeyError: 'default'

win10 python36 because of what?

navinthenapster commented 6 years ago

some problem in your hparams/default.yaml . maybe your data_path is not configued

try the below code in new python script

from hparam import hparam as hp print hp print hp.default

you must get a dict variable but in case you get empty dict like output : {}

check the yaml files and set correctly

BlcDec commented 6 years ago

I can get the right value in train1.py by print, but not in data_load.py. The evaluation of hp in train1.py has no effect on hp in data_load.py. After I called the function named set_hparam_yaml in data_load.py again, training was started. My classmate ran successfully in Linux without any modification. So I think it may be caused by system version. Thank you for your reply!

mindmapper15 commented 6 years ago

On hparam.py line 70, you will see this code.

hparam = Hparam()

In short, this code is cause of all the problem. For every py file using hp.default.xxx, you will see "from hparam import hparam as hp" in the importing section.

Originally, this code imports hparam object as hp. The object was initialized with "hparam = Hparam()" code in hparam.py and variables you need are stored when hp.set_hparam_yaml(args.caseX) is executed on the main section in train1.py or train2.py and read yaml files on your disk. Other py file imports hparam object stored all the variables you need and the rest of the codes works perfectly with no errors.

But on Windows platform, things are different. For somehow in Windows, when Python read (or execute) "from hparam import hparam as hp" line in other py file, "hparam = Hparam()" code in hparam.py is executed "again" although hparam object has already been initialized. Because of this, all the variables are already stored in hparam object are completely wiped out. That's causing the error. I don't know whether this is bug or difference from Python's dependence system

So, you have to either modify hparam.py and rest of py file which import hparam, or just run your code on Linux :)

dawningo commented 6 years ago

Just to follow up, so in windows you should try: import hparam as hp and: sr=hp.load_hparam('hparams/default.yaml')['default']['sr'] works for me, hope that it helps