Update app.py
Browse files
app.py
CHANGED
|
@@ -109,20 +109,21 @@ def empty_note_sequence(qpm=120.0, total_time=0.0):
|
|
| 109 |
return note_sequence
|
| 110 |
|
| 111 |
def process(text):
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
-
# Convert text of notes to audio
|
| 117 |
-
note_sequence = token_sequence_to_note_sequence(generated_sequence)
|
| 118 |
-
synth = note_seq.midi_synth.synthesize
|
| 119 |
-
array_of_floats = synth(note_sequence, sample_rate=SAMPLE_RATE)
|
| 120 |
-
note_plot = note_seq.plot_sequence(note_sequence, False)
|
| 121 |
-
array_of_floats /=1.414
|
| 122 |
-
array_of_floats *= 32767
|
| 123 |
-
int16_data = array_of_floats.astype(np.int16)
|
| 124 |
-
return SAMPLE_RATE, int16_data
|
| 125 |
-
|
| 126 |
title = "Music generation with GPT-2"
|
| 127 |
|
| 128 |
iface = gr.Interface(
|
|
@@ -131,7 +132,7 @@ iface = gr.Interface(
|
|
| 131 |
outputs=['audio'],
|
| 132 |
title=title,
|
| 133 |
#examples=[["PIECE_START"], ["PIECE_START STYLE=JSFAKES GENRE=JSFAKES TRACK_START INST=48 BAR_START NOTE_ON=61"]],
|
| 134 |
-
article="This demo is inspired in the notebook from https://huggingface.co/TristanBehrens/js-fakes-4bars"
|
| 135 |
)
|
| 136 |
|
| 137 |
iface.launch(debug=True)
|
|
|
|
| 109 |
return note_sequence
|
| 110 |
|
| 111 |
def process(text):
|
| 112 |
+
input_ids = tokenizer.encode(text, return_tensors="pt")
|
| 113 |
+
generated_ids = model.generate(input_ids, max_length=500)
|
| 114 |
+
generated_sequence = tokenizer.decode(generated_ids[0])
|
| 115 |
+
|
| 116 |
+
# Convert text of notes to audio
|
| 117 |
+
note_sequence = token_sequence_to_note_sequence(generated_sequence)
|
| 118 |
+
synth = note_seq.midi_synth.synthesize
|
| 119 |
+
array_of_floats = synth(note_sequence, sample_rate=SAMPLE_RATE)
|
| 120 |
+
note_plot = note_seq.plot_sequence(note_sequence, False)
|
| 121 |
+
array_of_floats /=1.414
|
| 122 |
+
array_of_floats *= 32767
|
| 123 |
+
int16_data = array_of_floats.astype(np.int16)
|
| 124 |
+
return SAMPLE_RATE, int16_data
|
| 125 |
+
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
title = "Music generation with GPT-2"
|
| 128 |
|
| 129 |
iface = gr.Interface(
|
|
|
|
| 132 |
outputs=['audio'],
|
| 133 |
title=title,
|
| 134 |
#examples=[["PIECE_START"], ["PIECE_START STYLE=JSFAKES GENRE=JSFAKES TRACK_START INST=48 BAR_START NOTE_ON=61"]],
|
| 135 |
+
article="This demo is inspired in the notebook from https://huggingface.co/TristanBehrens/js-fakes-4bars. Example: ["PIECE_START"], ["PIECE_START STYLE=JSFAKES GENRE=JSFAKES TRACK_START INST=48 BAR_START NOTE_ON=61"]"
|
| 136 |
)
|
| 137 |
|
| 138 |
iface.launch(debug=True)
|