Update main.py
Browse files
main.py
CHANGED
@@ -13,7 +13,7 @@ from utils import (
|
|
13 |
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
|
14 |
|
15 |
DESCRIPTION = """
|
16 |
-
<h1>🎵
|
17 |
<h3>AI-driven Music Composer: Creating Music One Instrument at a Time!</h3>
|
18 |
<p>This interactive application uses an AI model to generate music sequences based on a chosen genre and various user inputs. The apps constructs the piece instrument by instrument</p>
|
19 |
|
@@ -47,9 +47,14 @@ DESCRIPTION = """
|
|
47 |
<p>Enjoy creating your own music!</p>
|
48 |
"""
|
49 |
|
50 |
-
|
51 |
genres = ["ROCK", "POP", "OTHER", "R&B/SOUL", "JAZZ", "ELECTRONIC", "RANDOM"]
|
52 |
|
|
|
|
|
|
|
|
|
|
|
53 |
demo = gr.Blocks()
|
54 |
|
55 |
|
@@ -65,13 +70,16 @@ def run():
|
|
65 |
genre = gr.Dropdown(
|
66 |
choices=genres, value="POP", label="Select the genre"
|
67 |
)
|
|
|
|
|
|
|
68 |
with gr.Row():
|
69 |
btn_from_scratch = gr.Button("🧹 Start from scratch")
|
70 |
btn_continue = gr.Button("➡️ Continue Generation")
|
71 |
btn_remove_last = gr.Button("↩️ Remove last instrument")
|
72 |
btn_regenerate_last = gr.Button("🔄 Regenerate last instrument")
|
73 |
with gr.Column():
|
74 |
-
with gr.
|
75 |
audio_output = gr.Video(show_share_button=True)
|
76 |
midi_file = gr.File()
|
77 |
with gr.Row():
|
@@ -91,7 +99,7 @@ def run():
|
|
91 |
num_tokens = gr.Text(visible=False)
|
92 |
btn_from_scratch.click(
|
93 |
fn=generate_song,
|
94 |
-
inputs=[genre, temp, empty_sequence, qpm],
|
95 |
outputs=[
|
96 |
audio_output,
|
97 |
midi_file,
|
@@ -103,7 +111,7 @@ def run():
|
|
103 |
)
|
104 |
btn_continue.click(
|
105 |
fn=generate_song,
|
106 |
-
inputs=[genre, temp, text_sequence, qpm],
|
107 |
outputs=[
|
108 |
audio_output,
|
109 |
midi_file,
|
|
|
13 |
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
|
14 |
|
15 |
DESCRIPTION = """
|
16 |
+
<h1>🎵 Multitrack Midi Generator 🎶</h1>
|
17 |
<h3>AI-driven Music Composer: Creating Music One Instrument at a Time!</h3>
|
18 |
<p>This interactive application uses an AI model to generate music sequences based on a chosen genre and various user inputs. The apps constructs the piece instrument by instrument</p>
|
19 |
|
|
|
47 |
<p>Enjoy creating your own music!</p>
|
48 |
"""
|
49 |
|
50 |
+
# Genrs
|
51 |
genres = ["ROCK", "POP", "OTHER", "R&B/SOUL", "JAZZ", "ELECTRONIC", "RANDOM"]
|
52 |
|
53 |
+
#Artists
|
54 |
+
with open('artist_names.json', 'r') as f:
|
55 |
+
artist_names = json.load(f)
|
56 |
+
#print("Loaded Artists names:", artist_names)
|
57 |
+
|
58 |
demo = gr.Blocks()
|
59 |
|
60 |
|
|
|
70 |
genre = gr.Dropdown(
|
71 |
choices=genres, value="POP", label="Select the genre"
|
72 |
)
|
73 |
+
artist = gr.Dropdown(
|
74 |
+
choices=artist_names, value=artist_names[0], label="Select the artist style"
|
75 |
+
)
|
76 |
with gr.Row():
|
77 |
btn_from_scratch = gr.Button("🧹 Start from scratch")
|
78 |
btn_continue = gr.Button("➡️ Continue Generation")
|
79 |
btn_remove_last = gr.Button("↩️ Remove last instrument")
|
80 |
btn_regenerate_last = gr.Button("🔄 Regenerate last instrument")
|
81 |
with gr.Column():
|
82 |
+
with gr.Box():
|
83 |
audio_output = gr.Video(show_share_button=True)
|
84 |
midi_file = gr.File()
|
85 |
with gr.Row():
|
|
|
99 |
num_tokens = gr.Text(visible=False)
|
100 |
btn_from_scratch.click(
|
101 |
fn=generate_song,
|
102 |
+
inputs=[genre, artist, temp, empty_sequence, qpm],
|
103 |
outputs=[
|
104 |
audio_output,
|
105 |
midi_file,
|
|
|
111 |
)
|
112 |
btn_continue.click(
|
113 |
fn=generate_song,
|
114 |
+
inputs=[genre, artist, temp, text_sequence, qpm],
|
115 |
outputs=[
|
116 |
audio_output,
|
117 |
midi_file,
|