Commit Graph
15 Commits
Author SHA1 Message Date
drphero 7d12f53ca6 fix: resample inline edit output and normalize SRT segments
- resample edited segments back to original sample rate
- normalize 3D tensors after edit post-processing for SRT timing
2026-03-01 00:44:19 -03:00
diodiogod a2e11108e2 Version 4.19.5
Fix CosyVoice device mismatch in voice restoration

Technical implementation:
- Add CosyVoiceHandler.partially_load() for proper device reload
- Update base_wrapper.model_load() to use handler's partially_load()
- Move all CosyVoice components (llm, flow, hift, campplus) with nested modules
- Simplify CosyVoice engine wrapper device management (delegate to handler)
- Add CosyVoice variant setting for <restore> tags (RL/standard options)
- Update settings UI and API endpoint for variant selection

Fixes device tensor mismatch errors when TTS and VC restoration run sequentially
and prevents unnecessary model unload/reload when variants match.
2026-01-28 13:22:29 -03:00
diodiogod e840c6df4d Version 4.19.2
Add configurable VC engine for <restore> tags

Technical implementation:
- Add ComfyUI settings menu option for VC engine selection
- Support three VC engines: ChatterBox 23-Lang, ChatterBox, CosyVoice
- Fix module import to use shared sys.modules instance
- Implement file-based settings cache for persistence across restarts
- Add beforeQueuing hook to ensure settings sync before workflows
2026-01-28 12:18:54 -03:00
diodiogod 803a8878cf Fix paralinguistic tag spacing and position offset corruption
Fixed two issues with paralinguistic tag insertion in edit post-processing:

1. Spacing: Changed logic to add space before/after tags when adjacent character
   isn't already a space (previously only checked alphanumeric, causing tags to
   stick to punctuation like "Hello!<Breathing>")

2. Position offset: Removed incorrect position offset tracking when inserting
   multiple tags. Since tags are sorted descending, each insertion happens from
   right to left and doesn't affect earlier positions.

This fixes text corruption when multiple paralinguistic tags are present
(e.g., "<Br <Breathing> eathing>") and ensures proper spacing around tags.
2025-12-12 12:10:12 -03:00
diodiogod 4c1538b287 Fix Step Audio EditX duplicate model loading in edit post-processing
Fixed issue where EditPostProcessor was loading a second Step Audio EditX model (7GB+)
in VRAM during edit tag processing instead of reusing the pre-loaded engine from TTS generation.

Changes:
- Added pre_loaded_engine parameter passing through EditPostProcessor to Audio Editor
- Modified Audio Editor to wrap raw StepAudioTTS in StepAudioEditXEngine for edit_single() method
- Fixed paralinguistic code path to pass tts_engine_data instead of None
- Added debug logging to track pre-loaded engine usage

This eliminates unnecessary VRAM usage by ensuring only ONE Step Audio EditX model
is loaded during the complete TTS+editing workflow.
2025-12-12 11:12:26 -03:00
diodiogod 51408b97ad Fix Step Audio EditX duplicate model loading in edit post-processing
Eliminated duplicate model loading when EditPostProcessor applies inline edit tags:

1. **Pass pre-loaded engine directly**: EditPostProcessor now passes the TTS
   processor's pre-loaded engine to the Audio Editor node via tts_engine_data dict

2. **Audio Editor engine reuse**: Added pre_loaded_engine parameter to
   _get_or_create_engine() which returns pre-loaded engine directly if provided

3. **Fix ModelLoadConfig kwargs**: Fixed Audio Editor to pass torch_dtype and
   quantization in additional_params dict instead of as direct kwargs (was
   causing "unexpected keyword argument" error)

4. **Update EditPostProcessor**: Modified process_segments() and
   _apply_edit_via_node() to properly pass pre_loaded_engine through the chain

This prevents loading a second 7GB+ Step Audio EditX model in VRAM during
edit post-processing. The Audio Editor now reuses the same engine instance
that was already loaded for TTS generation.

Fixes duplicate VRAM usage and "Loading Step Audio EditX engine" messages
during edit tag processing in SRT and regular TTS workflows.
2025-12-12 10:17:23 -03:00
diodiogod 9907e8964c Add ComfyUI settings menu for inline edit tag precision/device control
Features:
- New settings menu under "TTS Audio Suite > Step Audio EditX (Inline Tags)"
- Precision options: auto, fp32, fp16, bf16, int8, int4
- Device options: auto, cuda, cpu, xpu
- Settings persist across ComfyUI restarts
- API endpoint for JavaScript-Python communication
- Automatic dead engine detection and reload

Implementation:
- web/tts_audio_suite_settings.js: Frontend settings UI
- __init__.py: API endpoint /api/tts-audio-suite/settings
- edit_post_processor.py: Global settings storage and retrieval
- step_audio_editx_audio_editor_node.py: Settings detection and engine reload logic

Notes:
- Settings require browser refresh (F5) to take effect (documented in tooltips)
- Only affects inline edit tags, not Step Audio EditX node direct usage
- Fixes dead engine detection after memory management unloads quantized models
2025-12-09 09:56:57 -03:00
diodiogod c8f7a4759f Fix Step Audio EditX non-quantized model CPU offloading
Fixed CPU offloading for non-quantized (bfloat16/float16/float32) models:

- StepAudioTTS components (llm, cosy_model) don't have .to() method directly
- Handler now moves model.llm and model.cosy_model.cosy_impl individually
- Updates CosyVoice.device tracker when moving cosy_impl to CPU
- Properly handles both raw StepAudioTTS and wrapped models

Fixes unload behavior for non-quantized models to actually free VRAM
instead of silently failing with "no memory freed (model may already be on CPU)"
2025-12-09 01:14:11 -03:00
diodiogod 7d3b171ab3 Add voice restoration with iteration reference support
New Feature: <restore:N@M> Syntax
- <restore> - Restore using original pre-edit audio (1 VC pass)
- <restore:N> - N VC passes using original audio as reference
- <restore:N@M> - N VC passes using audio from iteration M as reference

Implementation:
- Store audio snapshots after each edit iteration
- Parse iteration reference from @ syntax in restore tags
- Use specified iteration audio as VC reference instead of original
- Allows preserving partial effects (e.g., keep whisper, remove laughter)

Use Case Example:
<style:whisper:2> <Laughter:3> <restore:1@2>
- Applies whisper (iterations 1-2)
- Applies laughter (iterations 3-5)
- Restores using iteration 2 (whispered audio) with 1 VC pass
- Result: Keeps whisper effect but removes laughter voice degradation

Documentation:
- Updated INLINE_EDIT_TAGS_USER_GUIDE.md with restore tag section
- Added examples for basic and iteration-reference restoration
- Explained use cases and when to use each syntax
- Updated processing order and reference sections
2025-12-08 20:04:39 -03:00
diodiogod 2a2b096e45 Fix inline edit tag position tracking with space collapsing and improve progress display
Position Tracking Fixes:
- Adjust tag positions after multiple spaces are collapsed to single space
- Track cumulative position shifts from space collapsing operations
- Add space-before logic when reinserting paralinguistic tags
- Ensure proper spacing on both sides of reinserted tags (support <Laughter> hahaha)

Display Improvements:
- Show clean transcript instead of raw tag syntax in edit post-processor
- Add suppress_progress parameter to Step Audio EditX Audio Editor node
- Suppress redundant "Edit iteration 1/1" messages when called from edit_post_processor
- Edit post-processor already shows clear iteration progress (→ Iteration X/Y)

Fixes issues with:
- Tags inserted at wrong positions when separate tags create multiple spaces
- Tags glued to words without spacing (support<Laughter> instead of support <Laughter>)
- Confusing duplicate iteration progress messages
2025-12-08 19:40:36 -03:00
diodiogod 485736bc89 Fix pause tag segmentation and inline edit tag position tracking
- Refactor pause processing to return separate segments instead of combined audio
- Apply edit post-processing to individual segments after all TTS generation completes
- Fix position tracking for pipe-separated tags (e.g., <style:whisper:2|Laughter:5>)
- Adjust tag positions after leading whitespace stripping to maintain accuracy
- Fix space-after logic to only check tags from current match, not all previous tags
- Use clean text for TTS generation (strip edit tags before sending to model)
- Improve display to show clean transcript instead of raw tag syntax
- Add position offset tracking when inserting multiple paralinguistic tags

Resolves issues with:
- <restore> tag being sent to TTS model
- Paralinguistic tags inserted at wrong positions (e.g., h<Laughter> ahaha)
- Edit tags not being extracted properly in pause-segmented text
- Batch processing architecture for edit post-processing
2025-12-08 19:30:53 -03:00
diodiogod 31d243abb4 Add <restore> inline tag for voice restoration after edits
Implements voice restoration feature using ChatterBox Official 23-Lang VC
to restore original voice resemblance after Step Audio EditX edits
(especially after multiple iterations of paralinguistic/emotion/style effects).

Changes:
- Add 'restore' tag parsing to step_audio_editx_special_tags.py
  * Support <restore> and <restore:N> syntax for multi-pass VC
  * Add restore to EDIT_TYPE_VALUES and sorting priority (runs last)
- Add voice restoration to edit_post_processor.py
  * New _restore_voice_via_vc() function reusing UnifiedVoiceChangerNode
  * Store PRE-EDIT audio as voice reference (no engine changes needed)
  * Process restore tags after all other edits complete
  * Fix importlib path for VC node loading

Benefits:
- Works across all 14 engines (7 text + 7 SRT) automatically
- No engine processor changes required
- Reuses existing VC cache system
- Uses pre-edit audio as target (clean, simple)
- Supports multi-pass refinement (1-5 iterations)
- Fully backward compatible

Processing order: emotion → style → speed → paralinguistic → restore
2025-12-08 16:28:24 -03:00
diodiogod 3627980bc5 Fix VRAM management with proper model clearing and synchronization
Resolved OOM errors during model switching by implementing proper VRAM clearing:
- Added real VRAM measurement using torch.cuda.memory_allocated() in model_manager
- Removed fake VRAM reporting from VibeVoice handler
- Removed class-level caching from VibeVoice engine (unified manager handles all caching)
- Centralized device movement through ensure_device() in model manager
- Models now move to CPU instead of deletion for fast reload from cache
- Added CUDA synchronization after clearing to ensure memory is actually freed
- Fixed recursion by adding _from_ensure_device flag to model_load()
- model_load() now calls ensure_device() first to clear other models before loading

Also fixed inline edit tag spacing issues:
- Tags now properly add space after paralinguistic tags when followed by alphanumeric text
- Fixed both parser and post-processor to handle spacing correctly
2025-12-06 16:18:32 -03:00
diodiogod d1b093d273 Refactor inline edit tags to use Audio Editor node + fix unified interface
Major changes:
1. Post-processor now uses Audio Editor node instead of calling engine directly
   - Inherits progress bars, caching, tested code
   - Much simpler and more maintainable

2. Fixed unified model interface usage across Step Audio EditX
   - Adapter now loads via unified_model_interface.load_model()
   - Audio Editor node now loads via unified_model_interface.load_model()
   - Both use model_type="tts" for consistent cache keys
   - Prevents duplicate model loading (was loading twice before)

3. Fixed pause tag + edit tag interaction
   - Pause tags split FIRST, then edit tags extracted per segment
   - Allows: "Hello <Laughter> [pause:1] World <Sigh>"
   - Laughter applies to "Hello", Sigh applies to "World"

4. Added lesson to fails document
   - All engines must use unified interface in ALL code paths
   - Cache key must match across adapters/nodes/processors

Bug fixes:
- Missing Dict import in post-processor
- Import path for Audio Editor node (use importlib)
- Progress bars now work during editing

Files modified:
- utils/audio/edit_post_processor.py - refactored to use Audio Editor node
- nodes/step_audio_editx/step_audio_editx_processor.py - pause handling
- engines/adapters/step_audio_editx_adapter.py - unified interface
- nodes/step_audio_editx_special/step_audio_editx_audio_editor_node.py - unified interface
- docs/Dev reports/fails_to_avoid_TTS_Engine_Implementation.md - added lesson
2025-12-05 21:43:05 -03:00
diodiogod 1f629737d2 Implement inline edit tags for Step Audio EditX post-processing
Added support for inline edit tags in TTS text that automatically apply
Step Audio EditX edits to generated audio from ANY engine.

Syntax examples:
- <Laughter:2> - paralinguistic with iterations
- <emotion:happy:1> - emotion edit
- <style:whisper:3> - style edit
- <speed:faster> - speed adjustment
- <Laughter:2|style:whisper> - multiple effects

Key changes:
- Extended step_audio_editx_special_tags.py with EditTag dataclass and iteration parsing
- Created edit_post_processor.py for centralized post-TTS edit application
- Integrated into Step Audio EditX processor with proper pause tag handling
- Pause tags split FIRST, then edit tags extracted per pause-segment
- Reuses already-loaded engine to avoid duplicate loading

Flow:
1. Parse text, split by pause tags first
2. Extract edit tags from each pause-delimited segment
3. Generate TTS with clean text (tags stripped)
4. Post-processor applies edits to segments with tags
5. Assemble final audio

Currently working for Step Audio EditX TTS and SRT nodes.
2025-12-05 21:20:21 -03:00