Fix: Convert numpy types to prevent Gradio slider error
Browse filesA `TypeError` occurred when running the synthesizer a second time after using the "Auto-Recommend (Analyze MIDI)" feature.
app.py
CHANGED
@@ -1614,7 +1614,13 @@ def process_and_render_file(input_file, *args, progress=gr.Progress()):
|
|
1614 |
|
1615 |
# Always update all 13 controls to match the final parameters used in the backend
|
1616 |
for key in s8bit_control_keys:
|
1617 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1618 |
|
1619 |
# Format the main results for the output components
|
1620 |
main_results = [
|
|
|
1614 |
|
1615 |
# Always update all 13 controls to match the final parameters used in the backend
|
1616 |
for key in s8bit_control_keys:
|
1617 |
+
value = getattr(final_params, key)
|
1618 |
+
# Explicitly convert numpy numeric types to native Python types.
|
1619 |
+
# This prevents them from being serialized as strings in the UI,
|
1620 |
+
# which would cause a TypeError on the next run.
|
1621 |
+
if isinstance(value, np.generic):
|
1622 |
+
value = value.item()
|
1623 |
+
final_ui_updates.append(value)
|
1624 |
|
1625 |
# Format the main results for the output components
|
1626 |
main_results = [
|