Spaces:
Runtime error
Runtime error
Omar Sanseviero
commited on
Commit
·
e12c7d6
1
Parent(s):
9edb478
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
|
|
| 1 |
import note_seq
|
|
|
|
|
|
|
| 2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
|
| 4 |
tokenizer = AutoTokenizer.from_pretrained("TristanBehrens/js-fakes-4bars")
|
|
@@ -116,14 +119,16 @@ def process(text):
|
|
| 116 |
note_sequence = token_sequence_to_note_sequence(generated_sequence)
|
| 117 |
synth = note_seq.midi_synth.synthesize
|
| 118 |
array_of_floats = synth(note_sequence, sample_rate=SAMPLE_RATE)
|
| 119 |
-
|
|
|
|
|
|
|
| 120 |
|
| 121 |
title = "Music generation with GPT-2"
|
| 122 |
|
| 123 |
iface = gr.Interface(
|
| 124 |
fn=process,
|
| 125 |
inputs=[gr.inputs.Textbox(placeholder="PIECE_START")],
|
| 126 |
-
outputs='audio',
|
| 127 |
title=title,
|
| 128 |
examples=[["PIECE_START"], ["PIECE_START STYLE=JSFAKES GENRE=JSFAKES TRACK_START INST=48 BAR_START NOTE_ON=61"]]
|
| 129 |
)
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
import note_seq
|
| 3 |
+
|
| 4 |
+
from bokeh.embed import file_html
|
| 5 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 6 |
|
| 7 |
tokenizer = AutoTokenizer.from_pretrained("TristanBehrens/js-fakes-4bars")
|
|
|
|
| 119 |
note_sequence = token_sequence_to_note_sequence(generated_sequence)
|
| 120 |
synth = note_seq.midi_synth.synthesize
|
| 121 |
array_of_floats = synth(note_sequence, sample_rate=SAMPLE_RATE)
|
| 122 |
+
note_plot = note_seq.plot_sequence(note_sequence)
|
| 123 |
+
html = file_html(note_plot)
|
| 124 |
+
return (SAMPLE_RATE, array_of_floats), html
|
| 125 |
|
| 126 |
title = "Music generation with GPT-2"
|
| 127 |
|
| 128 |
iface = gr.Interface(
|
| 129 |
fn=process,
|
| 130 |
inputs=[gr.inputs.Textbox(placeholder="PIECE_START")],
|
| 131 |
+
outputs=['audio', 'html'],
|
| 132 |
title=title,
|
| 133 |
examples=[["PIECE_START"], ["PIECE_START STYLE=JSFAKES GENRE=JSFAKES TRACK_START INST=48 BAR_START NOTE_ON=61"]]
|
| 134 |
)
|