- Moved TTS nodes into a dedicated 'nodes' directory for better organization. - Introduced a base class `NodeTTSBase` to handle common functionality for TTS nodes. - Added new TTS nodes: `TTS_KokoroNode`, `TTS_ChatterboxNode`, `TTS_StyleTTS2Node`, `TTS_KittenTTSNode`, `TTS_F5TTSNode`, and `TTS_GlobalPresetNode`. - Updated the main module to include mappings for new nodes and their display names. - Removed the old `tts_webui_openai_tts.py` file and integrated its functionality into the new structure. - Created utility functions for audio processing and file handling in the `utils` module. - Added unit tests for the `TTS_ChatterboxNode` to ensure functionality and reliability. - Deprecated the `_shared.py` module in favor of explicit per-node payloads and the new base class.
17 lines
546 B
Python
17 lines
546 B
Python
import os
|
|
import time
|
|
import uuid
|
|
from .paths import get_output_directory
|
|
from .naming import _sanitize
|
|
|
|
|
|
def _save_wav(bytes_data: bytes, prefix: str, model: str) -> str:
|
|
out_dir = get_output_directory()
|
|
audio_dir = os.path.join(out_dir, "audio")
|
|
os.makedirs(audio_dir, exist_ok=True)
|
|
fname = f"{_sanitize(prefix)}_{_sanitize(model)}_{time.strftime('%Y%m%d_%H%M%S')}_{uuid.uuid4().hex[:8]}.wav"
|
|
path = os.path.join(audio_dir, fname)
|
|
with open(path, "wb") as f:
|
|
f.write(bytes_data)
|
|
return path
|