Spaces:
Runtime error
Runtime error
Add length and randomness options.
Browse files
app.py
CHANGED
@@ -47,7 +47,7 @@ print("Ready to use.")
|
|
47 |
|
48 |
|
49 |
|
50 |
-
def process_midi(MIDI_File,
|
51 |
if MIDI_File is not None:
|
52 |
name = Path(MIDI_File.name)
|
53 |
else:
|
@@ -57,7 +57,12 @@ def process_midi(MIDI_File, text_for_sonification, randomness):
|
|
57 |
item = MusicItem.from_file(name, data.vocab)
|
58 |
|
59 |
# full is the prediction appended to the input
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
# convert to stream and then MIDI file
|
63 |
stream = full.to_stream()
|
@@ -78,7 +83,8 @@ iface = gr.Interface(
|
|
78 |
inputs=[
|
79 |
gr.inputs.File(optional=True),
|
80 |
"text",
|
81 |
-
gr.inputs.Slider(0, 100)
|
|
|
82 |
],
|
83 |
outputs="audio",
|
84 |
# examples=['C major scale.midi']
|
|
|
47 |
|
48 |
|
49 |
|
50 |
+
def process_midi(MIDI_File, Text_to_Sonify, Randomness, Amount_of_Music_to_Add):
|
51 |
if MIDI_File is not None:
|
52 |
name = Path(MIDI_File.name)
|
53 |
else:
|
|
|
57 |
item = MusicItem.from_file(name, data.vocab)
|
58 |
|
59 |
# full is the prediction appended to the input
|
60 |
+
temp = Randomness / 100
|
61 |
+
pred, full = learner.predict(
|
62 |
+
item,
|
63 |
+
n_words=Amount_of_Music_to_Add,
|
64 |
+
temperatures=(temp, temp)
|
65 |
+
)
|
66 |
|
67 |
# convert to stream and then MIDI file
|
68 |
stream = full.to_stream()
|
|
|
83 |
inputs=[
|
84 |
gr.inputs.File(optional=True),
|
85 |
"text",
|
86 |
+
gr.inputs.Slider(0, 250, default=100, step=50),
|
87 |
+
gr.inputs.Radio([100, 200, 500], type="value", default=100)
|
88 |
],
|
89 |
outputs="audio",
|
90 |
# examples=['C major scale.midi']
|