Spaces:
Runtime error
Runtime error
Commit
·
035d641
1
Parent(s):
34d89e8
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,9 +36,11 @@ st.sidebar.markdown(ABOUT_TEXT)
|
|
| 36 |
st.sidebar.markdown(CONTACT_TEXT)
|
| 37 |
|
| 38 |
|
| 39 |
-
def inference(audio, num_epoch, tonic_name):
|
| 40 |
generator = Generator()
|
| 41 |
-
|
|
|
|
|
|
|
| 42 |
name = uuid.uuid4()
|
| 43 |
output_midi_data.write(f'{name}.mid')
|
| 44 |
fs = FluidSynth("font.sf2")
|
|
@@ -79,6 +81,14 @@ num_epoch = st.number_input("Number of epochs:",
|
|
| 79 |
value=1,
|
| 80 |
)
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
tonic_name = st.selectbox(
|
| 83 |
'Select tonic:',
|
| 84 |
["minor", "major"]
|
|
@@ -94,7 +104,7 @@ if generate_image_button:
|
|
| 94 |
f.write(uploaded_file.getvalue())
|
| 95 |
# print(uploaded_file.getvalue())
|
| 96 |
with st.spinner(text=f"Generating, this may take some time..."):
|
| 97 |
-
before, after = inference(input_file, num_epoch, tonic_name)
|
| 98 |
st.markdown("Before:")
|
| 99 |
st.audio(before)
|
| 100 |
st.markdown("After:")
|
|
|
|
| 36 |
st.sidebar.markdown(CONTACT_TEXT)
|
| 37 |
|
| 38 |
|
| 39 |
+
def inference(audio, num_epoch, tonic_name, 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), tonic=tonic_name, chord_duration=chord_duration)[0]
|
| 44 |
name = uuid.uuid4()
|
| 45 |
output_midi_data.write(f'{name}.mid')
|
| 46 |
fs = FluidSynth("font.sf2")
|
|
|
|
| 81 |
value=1,
|
| 82 |
)
|
| 83 |
|
| 84 |
+
chord_duration = st.number_input("Custom chord duration (leave zero for auto-calculation):",
|
| 85 |
+
min_value=0.0,
|
| 86 |
+
max_value=1000.0,
|
| 87 |
+
step=0.0001,
|
| 88 |
+
value=0.0,
|
| 89 |
+
format="%.4f"
|
| 90 |
+
)
|
| 91 |
+
|
| 92 |
tonic_name = st.selectbox(
|
| 93 |
'Select tonic:',
|
| 94 |
["minor", "major"]
|
|
|
|
| 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, tonic_name, chord_duration)
|
| 108 |
st.markdown("Before:")
|
| 109 |
st.audio(before)
|
| 110 |
st.markdown("After:")
|