twix yon
twix yon

Reputation: 1

Problem using magenta to generate song: SyntaxError: (unicode error) 'unicodeescape'

I want to generate music with magenta and a neural network model for a project.

I found this simple example and wanted to try it first to understand how it works: https://www.twilio.com/blog/training-a-neural-network-on-midi-music-data-with-magenta-and-python

Apparently i have to modify the type of my inital data (which is midi file) "in note to sequences"

Here is what i have:

convert_dir_to_note_sequences \
  --input_dir == 'C:\Users\mista\Downloads\CLEANED_DATA\CLEANED_DATA' \
  --output_file = tmp/notesequences.tfrecord \
  --recursive

and here is the error i get:

File "C:\Users\mista\AppData\Local\Temp/ipykernel_28328/3757950315.py", line 3 --output_file = tmp/notesequences.tfrecord
^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

I saw some people saying that you could use an 'r' before your path to solve this but i've tried many ways, i'm still stuck

Upvotes: 0

Views: 111

Answers (1)

Ken Cox
Ken Cox

Reputation: 1

I am following the same tutorial and after a couple hours of bashing my head against the keyboard, I managed to run the neural net properly. It seems like the problem is a lot of conflicting dependencies and deprecations, so you may have to play around with what version of Python you're using once you set everything else up properly (I used Python 3.7 and did pip install magenta).

I used Powershell (right click on Windows home button --> run Powershell as admin). You'll want to set up a virtual environment in your current working directory, as the tutorial advises. And now we get to your problem in particular - make sure you're running the command all in one line, as such:

convert_dir_to_note_sequences --input_dir == 'C:\Users\mista\Downloads\CLEANED_DATA\CLEANED_DATA' --output_file = tmp/notesequences.tfrecord --recursive

That should start converting all the midi files to NoteSequences objects. If you have any more trouble, please follow up and I'll see what I can do to help.

Upvotes: 0

Related Questions