Python error when using user .wav file
Closed this issue · 9 comments
I am using Reaper DAW (on Ubuntu Linux) to export a wav file from a project, mono channel, 16 bit, 44.1kHz. After preparing the data and running predict.py, I get the following:
python predict.py guitar_sample.wav my_output.wav
predict.py:23: WavFileWarning: Chunk (non-data) not understood, skipping it.
in_rate, in_data = wavfile.read(args.input)
Traceback (most recent call last):
File "/home/keith/anaconda3/lib/python3.7/site-packages/numpy/lib/shape_base.py", line 770, in array_split
Nsections = len(indices_or_sections) + 1
TypeError: object of type 'int' has no len()
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "predict.py", line 58, in <module>
predict(args)
File "/home/keith/anaconda3/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 15, in decorate_context
return func(*args, **kwargs)
File "predict.py", line 40, in predict
for x in tqdm(np.array_split(pad_in_data, batches)):
File "<__array_function__ internals>", line 6, in array_split
File "/home/keith/anaconda3/lib/python3.7/site-packages/numpy/lib/shape_base.py", line 776, in array_split
raise ValueError('number sections must be larger than 0.')
ValueError: number sections must be larger than 0.
I'm guessing this has something to do with formatting or metadata in the wav file, but it's not clear what that might be.
Interesting. I sometimes see the "Chunk (non-data) not understood" warning, which usually just means it is skipping over some metadata. However in this case it seems like batches
has a value of 0, which is causing the array_split
to fail. batches
is computed as the length of the input data divided by args.batch_size
(in this case 256), so it seems your input data must have a length of less than 256 samples.
I would add a print statement after line 37, and print in_data.shape
as well as pad_in_data.shape
. I suspect that even though the data is mono, it might still have 2 channels (where one channel is empty). If this is the case you will see that there are in fact 3 dimensions to the data, not 2. To solve this you'll have to add in_data = in_data[:, 0]
or in_data = in_data[:, 1]
after line 23, depending on which channel the data is actually in.
Hope this helps!
Thanks for the help! Something about how Reaper is exporting the wav is not translating, but I tried it with another wav file and it worked fine. I'll figure out what's happening there eventually, and I'll go ahead close this issue since it's not something that should be changed in the code. This is a really interesting project, are there any plans on integrating the generated model data into a realtime plugin?
I figured; glad you sorted it out! I have been quite busy recently, but I have created a small C++ application that uses the models in real time, even with decent latency. If anyone has experience creating effects plugins, I would love to collaborate!
Hi Teddy,
That's great news! You want to do a VST or a stand-alone application?
I think a VST. I'm envisioning a plugin where users can select from a wide variety of pretrained effects, and adding more would be as simple as training more models.
I'd love to give it a try. I'm using wdl-ol and should be good to make a first attempt. It supports multiple formats(VST / VST3 / Audiounit / RTAS / AAX (Native)) and win/mac platforms.
Nice! Send me an email (see profile) and I can show you what I have so far.
I'd be happy to test what you guys come up with. I have some guitar effects/amps I'd like to record and train to see how close the model sounds.
You may have thought about this already, but the WaveNetVA repo from the research paper you reference uses JUCE to build plugins cross platform. If you can convert the pytorch model to a equivalent tensorflow model like in the WaveNetVA project then all the plugin building work is done. I'm not sure if the model conversion would be easy or even possible, but just an idea. Looks like the weights are stored differently between pytorch and tensorflow.