cobramv12 commited on
Commit
b7ab207
·
verified ·
1 Parent(s): cc07efa

Fix: Critical audioop-lts dependency and early patch in app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -16
app.py CHANGED
@@ -1,24 +1,26 @@
1
  import sys
2
- import os
 
 
 
 
 
 
 
 
3
 
4
- # --- PARCHE DE COMPATIBILIDAD INVESTIGADO (CRÍTICO) ---
5
- # Este parche corrige el bug de 'bool' en gradio_client que afecta a Gradio 5
6
  try:
7
  import gradio_client.utils as client_utils
8
- old_get_type = client_utils.get_type
9
  def new_get_type(schema):
10
  if isinstance(schema, bool): return "Any"
11
- return old_get_type(schema)
12
- client_utils.get_type = new_get_type
13
-
14
- old_json_to_python = client_utils._json_schema_to_python_type
15
- def new_json_to_python(schema, defs=None):
16
- if isinstance(schema, bool): return "Any"
17
- return old_json_to_python(schema, defs)
18
- client_utils._json_schema_to_python_type = new_json_to_python
19
- except Exception as e:
20
- print(f"Aviso: No se pudo aplicar el parche de gradio_client: {e}")
21
- # ------------------------------------------------------
22
 
23
  import spaces
24
  import gradio as gr
@@ -103,5 +105,4 @@ with gr.Blocks(title="Image Utility v2.1") as demo:
103
  v_out = gr.Video(label="Sequence Output")
104
  v_btn.click(generate_video, [v_p, v_img, v_ls], v_out)
105
 
106
- # Al usar SDK nativo, no definimos server_name ni port. HuggingFace lo inyecta solo.
107
  demo.launch(show_api=False)
 
1
  import sys
2
+ # --- LÍNEA 1: PARCHE DE AUDIO PARA PYTHON 3.13 ---
3
+ try:
4
+ import audioop_lts
5
+ sys.modules["audioop"] = audioop_lts
6
+ except ImportError:
7
+ # Si no está, creamos un mock para que Gradio no colapse
8
+ from unittest.mock import MagicMock
9
+ sys.modules["audioop"] = MagicMock()
10
+ # ------------------------------------------------
11
 
12
+ # --- PARCHE DE GRADIO_CLIENT (BOOL BUG) ---
 
13
  try:
14
  import gradio_client.utils as client_utils
 
15
  def new_get_type(schema):
16
  if isinstance(schema, bool): return "Any"
17
+ try: return old_get_type(schema)
18
+ except: return "Any"
19
+ if hasattr(client_utils, "get_type"):
20
+ old_get_type = client_utils.get_type
21
+ client_utils.get_type = new_get_type
22
+ except: pass
23
+ # ------------------------------------------
 
 
 
 
24
 
25
  import spaces
26
  import gradio as gr
 
105
  v_out = gr.Video(label="Sequence Output")
106
  v_btn.click(generate_video, [v_p, v_img, v_ls], v_out)
107
 
 
108
  demo.launch(show_api=False)