Commit
·
b8b60db
1
Parent(s):
bf57798
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,11 +36,11 @@ st.sidebar.markdown(ABOUT_TEXT)
|
|
| 36 |
st.sidebar.markdown(CONTACT_TEXT)
|
| 37 |
|
| 38 |
|
| 39 |
-
def inference(audio, num_epoch,
|
| 40 |
generator = Generator()
|
| 41 |
if chord_duration == 0.0:
|
| 42 |
chord_duration = None
|
| 43 |
-
output_midi_data = generator(audio, num_epoch=int(num_epoch),
|
| 44 |
name = uuid.uuid4()
|
| 45 |
output_midi_data.write(f'{name}.mid')
|
| 46 |
fs = FluidSynth("font.sf2")
|
|
@@ -54,7 +54,7 @@ def inference(audio, num_epoch, tonic_name, chord_duration):
|
|
| 54 |
st.title("Accompaniment Generator")
|
| 55 |
|
| 56 |
st.markdown(
|
| 57 |
-
"App to generate accompaniment for MIDI music file with Evolutionary algorithm. Check out [project repository](https://github.com/AlekseyKorshuk/accompaniment-generator)
|
| 58 |
|
| 59 |
article = "<p style='text-align: center'>" \
|
| 60 |
"<a href='https://github.com/AlekseyKorshuk/accompaniment-generator' target='_blank'>Github Repo</a>" \
|
|
@@ -89,11 +89,6 @@ chord_duration = st.number_input("Custom chord duration is seconds (leave zero f
|
|
| 89 |
format="%.4f"
|
| 90 |
)
|
| 91 |
|
| 92 |
-
tonic_name = st.selectbox(
|
| 93 |
-
'Select tonic:',
|
| 94 |
-
["minor", "major"]
|
| 95 |
-
)
|
| 96 |
-
|
| 97 |
generate_image_button = st.button("Generate")
|
| 98 |
|
| 99 |
if generate_image_button:
|
|
@@ -104,7 +99,7 @@ if generate_image_button:
|
|
| 104 |
f.write(uploaded_file.getvalue())
|
| 105 |
# print(uploaded_file.getvalue())
|
| 106 |
with st.spinner(text=f"Generating, this may take some time..."):
|
| 107 |
-
before, after = inference(input_file, num_epoch,
|
| 108 |
st.markdown("Before:")
|
| 109 |
st.audio(before)
|
| 110 |
st.markdown("After:")
|
|
|
|
| 36 |
st.sidebar.markdown(CONTACT_TEXT)
|
| 37 |
|
| 38 |
|
| 39 |
+
def inference(audio, num_epoch, chord_duration):
|
| 40 |
generator = Generator()
|
| 41 |
if chord_duration == 0.0:
|
| 42 |
chord_duration = None
|
| 43 |
+
output_midi_data = generator(audio, num_epoch=int(num_epoch), chord_duration=chord_duration)[0]
|
| 44 |
name = uuid.uuid4()
|
| 45 |
output_midi_data.write(f'{name}.mid')
|
| 46 |
fs = FluidSynth("font.sf2")
|
|
|
|
| 54 |
st.title("Accompaniment Generator")
|
| 55 |
|
| 56 |
st.markdown(
|
| 57 |
+
"App to generate accompaniment for MIDI music file with Evolutionary algorithm. Check out [project repository](https://github.com/AlekseyKorshuk/accompaniment-generator).")
|
| 58 |
|
| 59 |
article = "<p style='text-align: center'>" \
|
| 60 |
"<a href='https://github.com/AlekseyKorshuk/accompaniment-generator' target='_blank'>Github Repo</a>" \
|
|
|
|
| 89 |
format="%.4f"
|
| 90 |
)
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
generate_image_button = st.button("Generate")
|
| 93 |
|
| 94 |
if generate_image_button:
|
|
|
|
| 99 |
f.write(uploaded_file.getvalue())
|
| 100 |
# print(uploaded_file.getvalue())
|
| 101 |
with st.spinner(text=f"Generating, this may take some time..."):
|
| 102 |
+
before, after = inference(input_file, num_epoch, chord_duration)
|
| 103 |
st.markdown("Before:")
|
| 104 |
st.audio(before)
|
| 105 |
st.markdown("After:")
|