Spaces:
Sleeping
Sleeping
| # ================================================================================================= | |
| # https://huggingface.co/spaces/projectlosangeles/MuseCraft-AlgoPOP | |
| # ================================================================================================= | |
| import os | |
| import time as reqtime | |
| import datetime | |
| from pytz import timezone | |
| import gradio as gr | |
| from musicpy import algorithms, scale, write | |
| # ================================================================================================= | |
| def Generate_POP(): | |
| print('=' * 70) | |
| print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT))) | |
| start_time = reqtime.time() | |
| print('=' * 70) | |
| #================================================================== | |
| print('=' * 70) | |
| print('MuseCraft AlgoPOP Generator') | |
| print('=' * 70) | |
| print('Generating...') | |
| pop_piece = algorithms.write_pop(scale('C', 'Major')) | |
| output_midi = 'MuseCraft-AlgoPOP-Composition.mid' | |
| write(pop_piece, name=output_midi) | |
| #======================================================== | |
| print('Done!') | |
| print('=' * 70) | |
| #======================================================== | |
| print('-' * 70) | |
| print('Req end time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT))) | |
| print('-' * 70) | |
| print('Req execution time:', (reqtime.time() - start_time), 'sec') | |
| return output_midi | |
| # ================================================================================================= | |
| if __name__ == "__main__": | |
| PDT = timezone('US/Pacific') | |
| print('=' * 70) | |
| print('App start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT))) | |
| print('=' * 70) | |
| #=============================================================================== | |
| app = gr.Blocks() | |
| with app: | |
| gr.Markdown("<h1 style='text-align: left; margin-bottom: 1rem'>MuseCraft AlgoPOP</h1>") | |
| gr.Markdown("<h1 style='text-align: left; margin-bottom: 1rem'>Simple algorithmic POP music generator</h1>") | |
| gr.HTML(""" | |
| Check out <a href="https://github.com/MIDIAI/MuseCraft">MuseCraft project</a> on GitHub | |
| <p> | |
| <a href="https://huggingface.co/spaces/projectlosangeles/MuseCraft-AlgoPOP?duplicate=true"> | |
| <img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-md.svg" alt="Duplicate in Hugging Face"> | |
| </a> | |
| </p> | |
| """) | |
| gr.Markdown("## Generate") | |
| run_btn = gr.Button("generate", variant="primary") | |
| gr.Markdown("## Generation results") | |
| output_midi = gr.File(label="Output MIDI file", file_types=[".mid"]) | |
| run_event = run_btn.click(Generate_POP, [], [output_midi]) | |
| app.queue().launch() |