| """ |
| Text Story Module for NCAkit |
| Generates fake iMessage-style text conversation videos. |
| """ |
| from fastapi import FastAPI |
| import logging |
|
|
| |
| MODULE_NAME = "text_story" |
| MODULE_PREFIX = "/api/text-story" |
| MODULE_DESCRIPTION = "Generate fake iMessage-style text story videos with TTS" |
|
|
| logger = logging.getLogger(__name__) |
|
|
|
|
| def register(app: FastAPI, config): |
| """ |
| Register the text story module with FastAPI. |
| Initializes services and adds routes. |
| """ |
| from .router import router |
| |
| logger.info("Registering text_story module...") |
| |
| |
| if not config.hf_tts: |
| logger.warning("HF_TTS not configured! TTS generation will fail.") |
| |
| |
| import os |
| os.makedirs("videos/text_story", exist_ok=True) |
| |
| |
| if os.path.exists("/data"): |
| os.makedirs("/data/gameplay_backgrounds", exist_ok=True) |
| logger.info("Created /data/gameplay_backgrounds folder for gameplay videos") |
| |
| |
| backgrounds_paths = [ |
| "/data/gameplay_backgrounds", |
| "assets/gameplay_backgrounds" |
| ] |
| |
| bg_found = False |
| for path in backgrounds_paths: |
| if os.path.exists(path): |
| count = len([f for f in os.listdir(path) if f.endswith('.mp4')]) |
| if count > 0: |
| logger.info(f"Found {count} gameplay backgrounds in {path}") |
| bg_found = True |
| break |
| |
| if not bg_found: |
| logger.warning("No gameplay backgrounds found! Will use solid color background.") |
| logger.info("Add .mp4 files to /data/gameplay_backgrounds for video backgrounds") |
| |
| |
| app.include_router(router) |
| |
| logger.info("text_story module registered successfully") |
|
|
|
|
| |
| from .router import router |
|
|
| __all__ = ["router", "register", "MODULE_NAME", "MODULE_PREFIX", "MODULE_DESCRIPTION"] |
|
|