File size: 2,009 Bytes
7219c67 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | """
Text Story Module for NCAkit
Generates fake iMessage-style text conversation videos.
"""
from fastapi import FastAPI
import logging
# Module Metadata
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...")
# Validate TTS config
if not config.hf_tts:
logger.warning("HF_TTS not configured! TTS generation will fail.")
# Create required directories
import os
os.makedirs("videos/text_story", exist_ok=True)
# Create gameplay backgrounds folder in persistent storage
if os.path.exists("/data"):
os.makedirs("/data/gameplay_backgrounds", exist_ok=True)
logger.info("Created /data/gameplay_backgrounds folder for gameplay videos")
# Check gameplay backgrounds
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")
# Register router
app.include_router(router)
logger.info("text_story module registered successfully")
# Export router for direct import
from .router import router
__all__ = ["router", "register", "MODULE_NAME", "MODULE_PREFIX", "MODULE_DESCRIPTION"]
|