0

I'm going to use pretty_midi to make a midi file with lyrics(Chinese). But it hints:

UnicodeEncodeError: 'latin-1' codec can't encode character '\u6211' in position 0: ordinal not in range(256)

How can I solve this problem? Can I change the encoding to utf-8?

initch
  • 1
  • you can search which encoding method chinese characters us, that will solve your problem – Ankit Kumar Namdeo Apr 16 '20 at 09:59
  • Does pretty_midi support any encoding with Chinese ? I'm afraid the answer is not. – initch Apr 16 '20 at 10:21
  • 1
    Can you provide a [minimal code example](https://stackoverflow.com/help/minimal-reproducible-example)? Please also post a link to the pretty_midi documentation. Edit the post with the "edit" button below your post. – lenz Apr 16 '20 at 12:14
  • A code example:```import pretty_midi midi = pretty_midi.PrettyMIDI() l = pretty_midi.Lyric(text='我',time=0) midi.lyrics.append(l) midi.write('test.mid')``` [link](https://craffel.github.io/pretty-midi/#pretty-midi-lyric) is the pretty_midi documentation. Thank you! – initch Apr 17 '20 at 05:22

0 Answers0