.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/musiclang_api/08_create_transition_between_parts.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_musiclang_api_08_create_transition_between_parts.py: Create a transition between two parts of a song ====================================================== In this example : - We load two parts of a same song (midi file with same tracks) - We ask musiclang to create a 4-bar transition for us between those two tracks - We get back the score with only the transition OR the full score .. GENERATED FROM PYTHON SOURCE LINES 11-31 .. code-block:: Python import os from maidi import MidiScore, instrument, midi_library from maidi.integrations.api import MusicLangAPI # Assuming API_URL and MUSICLANG_API_KEY are set in the environment MUSICLANG_API_KEY = os.getenv("MUSICLANG_API_KEY") nb_bars_transition = 4 # Should be less than 12 bars, the higher the value the less context is added to the model # Create a 4 bar template with the given instruments score1 = MidiScore.from_midi(midi_library.get_midi_file('drum_and_bass')) score2 = MidiScore.from_midi(midi_library.get_midi_file('drum_and_bass')) # Call the musiclang API to predict the score api = MusicLangAPI(api_key=MUSICLANG_API_KEY, verbose=True) predicted_score = api.create_transition(score1, score2, nb_bars_transition, async_mode=False, polling_interval=3 ) predicted_score.write("predicted_score.mid") .. _sphx_glr_download_auto_examples_musiclang_api_08_create_transition_between_parts.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 08_create_transition_between_parts.ipynb <08_create_transition_between_parts.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 08_create_transition_between_parts.py <08_create_transition_between_parts.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 08_create_transition_between_parts.zip <08_create_transition_between_parts.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_