优化tts逻辑
This commit is contained in:
@@ -17,7 +17,7 @@ Usage:
|
||||
if config_manager.validate():
|
||||
print("Config is valid!")
|
||||
"""
|
||||
from .schema import ReelForgeConfig, LLMConfig, TTSConfig, ImageConfig
|
||||
from .schema import ReelForgeConfig, LLMConfig, ComfyUIConfig, TTSSubConfig, ImageSubConfig
|
||||
from .manager import ConfigManager
|
||||
from .loader import load_config_dict, save_config_dict
|
||||
|
||||
@@ -27,8 +27,9 @@ config_manager = ConfigManager()
|
||||
__all__ = [
|
||||
"ReelForgeConfig",
|
||||
"LLMConfig",
|
||||
"TTSConfig",
|
||||
"ImageConfig",
|
||||
"ComfyUIConfig",
|
||||
"TTSSubConfig",
|
||||
"ImageSubConfig",
|
||||
"ConfigManager",
|
||||
"config_manager",
|
||||
"load_config_dict",
|
||||
|
||||
@@ -93,21 +93,26 @@ class ConfigManager:
|
||||
}
|
||||
})
|
||||
|
||||
def get_image_config(self) -> dict:
|
||||
"""Get image configuration as dict"""
|
||||
def get_comfyui_config(self) -> dict:
|
||||
"""Get ComfyUI configuration as dict"""
|
||||
return {
|
||||
"default_workflow": self.config.image.default_workflow,
|
||||
"comfyui_url": self.config.image.comfyui_url,
|
||||
"runninghub_api_key": self.config.image.runninghub_api_key,
|
||||
"prompt_prefix": self.config.image.prompt_prefix,
|
||||
"comfyui_url": self.config.comfyui.comfyui_url,
|
||||
"runninghub_api_key": self.config.comfyui.runninghub_api_key,
|
||||
"tts": {
|
||||
"default_workflow": self.config.comfyui.tts.default_workflow,
|
||||
},
|
||||
"image": {
|
||||
"default_workflow": self.config.comfyui.image.default_workflow,
|
||||
"prompt_prefix": self.config.comfyui.image.prompt_prefix,
|
||||
}
|
||||
}
|
||||
|
||||
def set_image_config(
|
||||
def set_comfyui_config(
|
||||
self,
|
||||
comfyui_url: Optional[str] = None,
|
||||
runninghub_api_key: Optional[str] = None
|
||||
):
|
||||
"""Set image configuration"""
|
||||
"""Set ComfyUI global configuration"""
|
||||
updates = {}
|
||||
if comfyui_url is not None:
|
||||
updates["comfyui_url"] = comfyui_url
|
||||
@@ -115,5 +120,5 @@ class ConfigManager:
|
||||
updates["runninghub_api_key"] = runninghub_api_key
|
||||
|
||||
if updates:
|
||||
self.update({"image": updates})
|
||||
self.update({"comfyui": updates})
|
||||
|
||||
|
||||
@@ -13,32 +13,37 @@ class LLMConfig(BaseModel):
|
||||
model: str = Field(default="", description="LLM Model Name")
|
||||
|
||||
|
||||
class TTSConfig(BaseModel):
|
||||
"""TTS configuration"""
|
||||
class TTSSubConfig(BaseModel):
|
||||
"""TTS-specific configuration (under comfyui.tts)"""
|
||||
model_config = {"populate_by_name": True} # Allow both field name and alias
|
||||
|
||||
default_workflow: str = Field(default="edge", description="Default TTS workflow", alias="default")
|
||||
default_workflow: str = Field(default=None, description="Default TTS workflow (required, no fallback)", alias="default")
|
||||
|
||||
|
||||
class ImageConfig(BaseModel):
|
||||
"""Image generation configuration"""
|
||||
class ImageSubConfig(BaseModel):
|
||||
"""Image-specific configuration (under comfyui.image)"""
|
||||
model_config = {"populate_by_name": True} # Allow both field name and alias
|
||||
|
||||
default_workflow: str = Field(default=None, description="Default image workflow (required, no fallback)", alias="default")
|
||||
comfyui_url: str = Field(default="http://127.0.0.1:8188", description="ComfyUI Server URL")
|
||||
runninghub_api_key: str = Field(default="", description="RunningHub API Key (optional)")
|
||||
prompt_prefix: str = Field(
|
||||
default="Pure white background, minimalist illustration, matchstick figure style, black and white line drawing, simple clean lines",
|
||||
description="Prompt prefix for all image generation"
|
||||
)
|
||||
|
||||
|
||||
class ComfyUIConfig(BaseModel):
|
||||
"""ComfyUI configuration (includes global settings and service-specific configs)"""
|
||||
comfyui_url: str = Field(default="http://127.0.0.1:8188", description="ComfyUI Server URL")
|
||||
runninghub_api_key: str = Field(default="", description="RunningHub API Key (optional)")
|
||||
tts: TTSSubConfig = Field(default_factory=TTSSubConfig, description="TTS-specific configuration")
|
||||
image: ImageSubConfig = Field(default_factory=ImageSubConfig, description="Image-specific configuration")
|
||||
|
||||
|
||||
class ReelForgeConfig(BaseModel):
|
||||
"""ReelForge main configuration"""
|
||||
project_name: str = Field(default="ReelForge", description="Project name")
|
||||
llm: LLMConfig = Field(default_factory=LLMConfig)
|
||||
tts: TTSConfig = Field(default_factory=TTSConfig)
|
||||
image: ImageConfig = Field(default_factory=ImageConfig)
|
||||
comfyui: ComfyUIConfig = Field(default_factory=ComfyUIConfig)
|
||||
|
||||
def is_llm_configured(self) -> bool:
|
||||
"""Check if LLM is properly configured"""
|
||||
|
||||
Reference in New Issue
Block a user