Spaces:
Sleeping
Sleeping
Duración del MIDI
#2
by
Just5ebas
- opened
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)
|
@@ -168,6 +172,12 @@ def main():
|
|
168 |
f.write(uploaded_file.getbuffer())
|
169 |
|
170 |
sample_file=uploaded_file.name
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
|
172 |
# Cargar modelo y pesos
|
173 |
with custom_object_scope({'mse_with_positive_pressure': mse_with_positive_pressure}):
|
@@ -216,5 +226,11 @@ def main():
|
|
216 |
mime='audio/midi'
|
217 |
)
|
218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
if __name__ == "__main__":
|
220 |
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)
|
|
|
172 |
f.write(uploaded_file.getbuffer())
|
173 |
|
174 |
sample_file=uploaded_file.name
|
175 |
+
|
176 |
+
# Duracion del MIDI
|
177 |
+
duracion = calcular_duracion_midi(sample_file)
|
178 |
+
minutos, segundos = divmod(duracion, 60)
|
179 |
+
|
180 |
+
st.write(f"La duración del archivo MIDI es: {int(minutos)} minutos y {segundos:.2f} segundos.")
|
181 |
|
182 |
# Cargar modelo y pesos
|
183 |
with custom_object_scope({'mse_with_positive_pressure': mse_with_positive_pressure}):
|
|
|
226 |
mime='audio/midi'
|
227 |
)
|
228 |
|
229 |
+
# Duracion del MIDI resultante
|
230 |
+
duracion_f = calcular_duracion_midi(sample_file)
|
231 |
+
minutos_f, segundos_f = divmod(duracion_f, 60)
|
232 |
+
|
233 |
+
st.write(f"La duración del archivo MIDI es: {int(minutos_f)} minutos y {segundos_f:.2f} segundos.")
|
234 |
+
|
235 |
if __name__ == "__main__":
|
236 |
main()
|