# @title HTML helper import re import base64 def to_data_url(midi_filename): """ This is crucial for Colab/WandB support. Thanks to Scott Hawley!! https://github.com/drscotthawley/midi-player/blob/main/midi_player/midi_player.py """ with open(midi_filename, "rb") as f: encoded_string = base64.b64encode(f.read()) return 'data:audio/midi;base64,'+encoded_string.decode('utf-8') def to_youtube_embed_url(video_url): regex = r"(?:https:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)" return re.sub(regex, r"https://www.youtube.com/embed/\1",video_url) def create_html_from_midi(midifile): html_template = """