Spaces:
Build error
Build error
juancopi81
commited on
Commit
•
d0d8765
1
Parent(s):
b2e5b51
Add better description
Browse files
main.py
CHANGED
@@ -17,19 +17,20 @@ DESCRIPTION = """
|
|
17 |
# 🎵 Multitrack Midi Generator 🎶
|
18 |
This interactive application uses an AI model to generate music sequences based on a chosen genre and various user inputs.
|
19 |
|
20 |
-
Features:
|
21 |
-
🎼 Select the genre for the music.
|
22 |
-
🌡️ Use the "Temperature" slider to adjust the randomness of the music generated (higher values will produce more random outputs).
|
23 |
-
⏱️ Adjust the "Tempo" slider to change the speed of the music.
|
24 |
-
🎹 Use the buttons to generate a new song from scratch, continue generation with the current settings, remove the last added instrument, regenerate the last added instrument with a new one, or change the tempo of the current song.
|
25 |
-
|
|
|
26 |
The app outputs the following:
|
27 |
|
28 |
-
🎧 The audio of the generated song.
|
29 |
-
📁 A MIDI file of the song.
|
30 |
-
📊 A plot of the song's sequence.
|
31 |
-
🎸 A list of the generated instruments.
|
32 |
-
📝 The text sequence of the song.
|
33 |
Enjoy creating your own AI-generated music! 🎵
|
34 |
"""
|
35 |
|
|
|
17 |
# 🎵 Multitrack Midi Generator 🎶
|
18 |
This interactive application uses an AI model to generate music sequences based on a chosen genre and various user inputs.
|
19 |
|
20 |
+
## Features:
|
21 |
+
- 🎼 Select the genre for the music.
|
22 |
+
- 🌡️ Use the "Temperature" slider to adjust the randomness of the music generated (higher values will produce more random outputs).
|
23 |
+
- ⏱️ Adjust the "Tempo" slider to change the speed of the music.
|
24 |
+
- 🎹 Use the buttons to generate a new song from scratch, continue generation with the current settings, remove the last added instrument, regenerate the last added instrument with a new one, or change the tempo of the current song.
|
25 |
+
|
26 |
+
## Outputs:
|
27 |
The app outputs the following:
|
28 |
|
29 |
+
- 🎧 The audio of the generated song.
|
30 |
+
- 📁 A MIDI file of the song.
|
31 |
+
- 📊 A plot of the song's sequence.
|
32 |
+
- 🎸 A list of the generated instruments.
|
33 |
+
- 📝 The text sequence of the song.
|
34 |
Enjoy creating your own AI-generated music! 🎵
|
35 |
"""
|
36 |
|
utils.py
CHANGED
@@ -51,15 +51,13 @@ def get_instruments(text_sequence: str) -> List[str]:
|
|
51 |
|
52 |
|
53 |
def generate_new_instrument(
|
54 |
-
seed: str,
|
55 |
) -> str:
|
56 |
"""
|
57 |
Generates a new instrument sequence from a given seed and temperature.
|
58 |
|
59 |
Args:
|
60 |
seed (str): The seed string for the generation.
|
61 |
-
tokenizer (PreTrainedTokenizer): The tokenizer used to encode and decode the sequences.
|
62 |
-
model (PreTrainedModel): The pretrained model used for generating the sequences.
|
63 |
temp (float, optional): The temperature for the generation, which controls the randomness. Defaults to 0.75.
|
64 |
|
65 |
Returns:
|
@@ -209,8 +207,6 @@ def change_tempo(
|
|
209 |
|
210 |
|
211 |
def generate_song(
|
212 |
-
model: AutoModelForCausalLM = model,
|
213 |
-
tokenizer: AutoTokenizer = tokenizer,
|
214 |
genre: str = "OTHER",
|
215 |
temp: float = 0.75,
|
216 |
text_sequence: str = "",
|
@@ -237,7 +233,7 @@ def generate_song(
|
|
237 |
seed_string = text_sequence
|
238 |
|
239 |
generated_sequence = generate_new_instrument(
|
240 |
-
seed=seed_string,
|
241 |
)
|
242 |
audio, midi_file, fig, instruments_str, num_tokens = get_outputs_from_string(
|
243 |
generated_sequence, qpm
|
|
|
51 |
|
52 |
|
53 |
def generate_new_instrument(
|
54 |
+
seed: str, temp: float = 0.75
|
55 |
) -> str:
|
56 |
"""
|
57 |
Generates a new instrument sequence from a given seed and temperature.
|
58 |
|
59 |
Args:
|
60 |
seed (str): The seed string for the generation.
|
|
|
|
|
61 |
temp (float, optional): The temperature for the generation, which controls the randomness. Defaults to 0.75.
|
62 |
|
63 |
Returns:
|
|
|
207 |
|
208 |
|
209 |
def generate_song(
|
|
|
|
|
210 |
genre: str = "OTHER",
|
211 |
temp: float = 0.75,
|
212 |
text_sequence: str = "",
|
|
|
233 |
seed_string = text_sequence
|
234 |
|
235 |
generated_sequence = generate_new_instrument(
|
236 |
+
seed=seed_string, temp=temp
|
237 |
)
|
238 |
audio, midi_file, fig, instruments_str, num_tokens = get_outputs_from_string(
|
239 |
generated_sequence, qpm
|