Coder Social home page Coder Social logo

Comments (7)

feiyuehchen avatar feiyuehchen commented on June 12, 2024 2

I got remi files(0.txt and 1.txt) Then how to get midi file to remi files??

I have the same problem that it only generates remi files. The solution is to fix bugs in 2-attribute2music_model/midiprocessor/enc_remigen2_utils.py

change miditoolkit.containers to miditoolkit.midi.containers

after that, you can run the scripts below to generate midi files

import os
from midiprocessor import MidiDecoder, MidiEncoder


date = "0117"
midi_root = f"./generation/{date}/linear_mask-1billion-attribute2music/infer_test/topk15-t1.0-ngram0"
midi_decoder = MidiDecoder("REMIGEN2")

print(midi_decoder)


midi_list = []
error_midi_list = []

for folder_name in os.listdir(midi_root):
    folder_dir = os.path.join(midi_root, folder_name)
    # not folder, Using_pred_labels.txt etc
    if os.path.isfile(folder_dir):
        continue
        
    # remi_name: 0.txt, 1.txt...
    remi_dir = os.path.join(folder_dir, 'remi')
    midi_dir = os.path.join(folder_dir, 'midi')


    for remi_name in os.listdir(remi_dir):
        with open(os.path.join(remi_dir, remi_name), 'r') as f:
            hypo_str = f.read()
        
        # since the seq looks like this: prefix <seq> remi
        # we have to get the remi tokens by discard the prefix tokens and <seq>
        # orginal:
        # remi_token = hypo_str.split(" ")[sep_pos[id_] + 1:]
        remi_token = hypo_str.split(" <sep> ")[1].split(" ")
        os.makedirs(midi_dir, exist_ok=True)
        midi_save_path = os.path.join(midi_dir, remi_name.replace('.txt', '.mid'))
        midi_list.append(midi_save_path)
        try:
            midi_obj = midi_decoder.decode_from_token_str_list(remi_token)
            midi_obj.dump(midi_save_path)
        except:
            error_midi_list.append(midi_save_path)



print(len(midi_list))

print(len(error_midi_list))

I also got the assertion error as @cpadilha did. 39/560 midi files have that problem.

from muzic.

zoahmed-xyz avatar zoahmed-xyz commented on June 12, 2024

Same issue. Did you manage to find a solution?

from muzic.

Subin-Kim46 avatar Subin-Kim46 commented on June 12, 2024

I got remi files(0.txt and 1.txt) Then how to get midi file to remi files??

from muzic.

Subin-Kim46 avatar Subin-Kim46 commented on June 12, 2024

@feiyuehchen Thank you so much. This works well

from muzic.

Subin-Kim46 avatar Subin-Kim46 commented on June 12, 2024

@feiyuehchen Sir, I wonder one more thing.

What should I do to use the text I want as an input?

from muzic.

feiyuehchen avatar feiyuehchen commented on June 12, 2024

@Subin-Kim46 you could print hypo_str to know more

prefix_input  = hypo_str.split(" <sep> ")[0].split(" ")

from muzic.

Subin-Kim46 avatar Subin-Kim46 commented on June 12, 2024

@feiyuehchen Thank you so much

from muzic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.