BoxOfColors Claude Sonnet 4.6 commited on
Commit
84cc585
·
1 Parent(s): 121a071

fix: replace render=False xregen outputs with real rendered slot components

Browse files

Gradio's postprocess_data looks up output component IDs in session state.
Components created with render=False are not registered there, causing
KeyError: 153 (or whichever block ID was assigned).

Replace _xr_vid_out / _xr_wave_out (both render=False) with
taro_slot_vids[0] / taro_slot_waves[0] as dummy sinks for all three
xregen_* event handlers. The JS _listenAndApply listener applies the
returned video/HTML directly to the correct slot's DOM elements and
ignores Gradio's output routing, so these slot-0 components are never
visibly affected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -2463,8 +2463,14 @@ with gr.Blocks(title="Generate Audio for Video", css=_SLOT_CSS, js=_GLOBAL_JS) a
2463
  _xr_seg = gr.Textbox(value="0", render=False)
2464
  _xr_state = gr.Textbox(value="", render=False)
2465
  _xr_slot_id = gr.Textbox(value="", render=False)
2466
- _xr_vid_out = gr.Video(render=False)
2467
- _xr_wave_out = gr.HTML(render=False)
 
 
 
 
 
 
2468
 
2469
  # TARO cross-model regen inputs: seg_idx, state_json, slot_id, seed, cfg, steps, mode, cf_dur, cf_db
2470
  _xr_taro_seed = gr.Textbox(value="-1", render=False)
@@ -2478,7 +2484,7 @@ with gr.Blocks(title="Generate Audio for Video", css=_SLOT_CSS, js=_GLOBAL_JS) a
2478
  inputs=[_xr_seg, _xr_state, _xr_slot_id,
2479
  _xr_taro_seed, _xr_taro_cfg, _xr_taro_steps,
2480
  _xr_taro_mode, _xr_taro_cfd, _xr_taro_cfdb],
2481
- outputs=[_xr_vid_out, _xr_wave_out],
2482
  api_name="xregen_taro",
2483
  )
2484
 
@@ -2495,7 +2501,7 @@ with gr.Blocks(title="Generate Audio for Video", css=_SLOT_CSS, js=_GLOBAL_JS) a
2495
  inputs=[_xr_seg, _xr_state, _xr_slot_id,
2496
  _xr_mma_prompt, _xr_mma_neg, _xr_mma_seed,
2497
  _xr_mma_cfg, _xr_mma_steps, _xr_mma_cfd, _xr_mma_cfdb],
2498
- outputs=[_xr_vid_out, _xr_wave_out],
2499
  api_name="xregen_mmaudio",
2500
  )
2501
 
@@ -2514,7 +2520,7 @@ with gr.Blocks(title="Generate Audio for Video", css=_SLOT_CSS, js=_GLOBAL_JS) a
2514
  _xr_hf_prompt, _xr_hf_neg, _xr_hf_seed,
2515
  _xr_hf_guide, _xr_hf_steps, _xr_hf_size,
2516
  _xr_hf_cfd, _xr_hf_cfdb],
2517
- outputs=[_xr_vid_out, _xr_wave_out],
2518
  api_name="xregen_hunyuan",
2519
  )
2520
 
 
2463
  _xr_seg = gr.Textbox(value="0", render=False)
2464
  _xr_state = gr.Textbox(value="", render=False)
2465
  _xr_slot_id = gr.Textbox(value="", render=False)
2466
+ # Dummy outputs for xregen events: must be real rendered components so Gradio
2467
+ # can look them up in session state during postprocess_data. The JS listener
2468
+ # (_listenAndApply) applies the returned video/HTML directly to the correct
2469
+ # slot's DOM elements and ignores Gradio's own output routing, so these
2470
+ # slot-0 components simply act as sinks — their displayed value is overwritten
2471
+ # by the real JS update immediately after.
2472
+ _xr_dummy_vid = taro_slot_vids[0]
2473
+ _xr_dummy_wave = taro_slot_waves[0]
2474
 
2475
  # TARO cross-model regen inputs: seg_idx, state_json, slot_id, seed, cfg, steps, mode, cf_dur, cf_db
2476
  _xr_taro_seed = gr.Textbox(value="-1", render=False)
 
2484
  inputs=[_xr_seg, _xr_state, _xr_slot_id,
2485
  _xr_taro_seed, _xr_taro_cfg, _xr_taro_steps,
2486
  _xr_taro_mode, _xr_taro_cfd, _xr_taro_cfdb],
2487
+ outputs=[_xr_dummy_vid, _xr_dummy_wave],
2488
  api_name="xregen_taro",
2489
  )
2490
 
 
2501
  inputs=[_xr_seg, _xr_state, _xr_slot_id,
2502
  _xr_mma_prompt, _xr_mma_neg, _xr_mma_seed,
2503
  _xr_mma_cfg, _xr_mma_steps, _xr_mma_cfd, _xr_mma_cfdb],
2504
+ outputs=[_xr_dummy_vid, _xr_dummy_wave],
2505
  api_name="xregen_mmaudio",
2506
  )
2507
 
 
2520
  _xr_hf_prompt, _xr_hf_neg, _xr_hf_seed,
2521
  _xr_hf_guide, _xr_hf_steps, _xr_hf_size,
2522
  _xr_hf_cfd, _xr_hf_cfdb],
2523
+ outputs=[_xr_dummy_vid, _xr_dummy_wave],
2524
  api_name="xregen_hunyuan",
2525
  )
2526