Spaces:
Sleeping
Sleeping
Duración del MIDI (#2)
Browse files- Duración del MIDI (78b79a635bcca50e16dec02a2ed58be5cde62401)
Co-authored-by: Ariel Maldonado <Just5ebas@users.noreply.huggingface.co>
app.py
CHANGED
@@ -126,6 +126,10 @@ def mse_with_positive_pressure(y_true: tf.Tensor, y_pred: tf.Tensor):
|
|
126 |
positive_pressure = 10 * tf.maximum(-y_pred, 0.0)
|
127 |
return tf.reduce_mean(mse + positive_pressure)
|
128 |
|
|
|
|
|
|
|
|
|
129 |
def main():
|
130 |
seed = 42
|
131 |
tf.random.set_seed(seed)
|
@@ -172,6 +176,12 @@ def main():
|
|
172 |
f.write(uploaded_file.getbuffer())
|
173 |
|
174 |
sample_file=uploaded_file.name
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
# Cargar modelo y pesos
|
177 |
with custom_object_scope({'mse_with_positive_pressure': mse_with_positive_pressure}):
|
@@ -257,5 +267,11 @@ def main():
|
|
257 |
mime='audio/midi'
|
258 |
)
|
259 |
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
if __name__ == "__main__":
|
261 |
main()
|
|
|
126 |
positive_pressure = 10 * tf.maximum(-y_pred, 0.0)
|
127 |
return tf.reduce_mean(mse + positive_pressure)
|
128 |
|
129 |
+
def calcular_duracion_midi(archivo_midi):
|
130 |
+
midi = pretty_midi.PrettyMIDI(archivo_midi)
|
131 |
+
return midi.get_end_time()
|
132 |
+
|
133 |
def main():
|
134 |
seed = 42
|
135 |
tf.random.set_seed(seed)
|
|
|
176 |
f.write(uploaded_file.getbuffer())
|
177 |
|
178 |
sample_file=uploaded_file.name
|
179 |
+
|
180 |
+
# Duracion del MIDI
|
181 |
+
duracion = calcular_duracion_midi(sample_file)
|
182 |
+
minutos, segundos = divmod(duracion, 60)
|
183 |
+
|
184 |
+
st.write(f"La duración del archivo MIDI es: {int(minutos)} minutos y {segundos:.2f} segundos.")
|
185 |
|
186 |
# Cargar modelo y pesos
|
187 |
with custom_object_scope({'mse_with_positive_pressure': mse_with_positive_pressure}):
|
|
|
267 |
mime='audio/midi'
|
268 |
)
|
269 |
|
270 |
+
# Duracion del MIDI resultante
|
271 |
+
duracion_f = calcular_duracion_midi(sample_file)
|
272 |
+
minutos_f, segundos_f = divmod(duracion_f, 60)
|
273 |
+
|
274 |
+
st.write(f"La duración del archivo MIDI es: {int(minutos_f)} minutos y {segundos_f:.2f} segundos.")
|
275 |
+
|
276 |
if __name__ == "__main__":
|
277 |
main()
|