feat(music-lab): cover 16:9 landscape 생성 + 메타데이터 프로페셔널화
- cover.py: DALL·E 3 → 1792x1024, gpt-image-1 → 1536x1024 (모델별 자동), prompt에 'cinematic landscape composition' 명시. OPENAI_IMAGE_SIZE env로 override 가능. - metadata.py: prompt를 list+join 패턴으로 재구성 (인접 문자열/+ 충돌 해결) + lofi 채널 카피라이터 페르소나 부여. description 5-7섹션 구조 명시: 후크/분위기/사용시나리오/챕터/시청권장/콜투액션/해시태그. mix vs single 분기 + tags 가이드 + 출력 JSON schema 명시. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -113,6 +113,25 @@ async def generate(*, pipeline_id: int, genre: str, prompt_template: str,
|
||||
}
|
||||
|
||||
|
||||
def _get_image_size(model: str) -> str:
|
||||
"""모델별 16:9에 가장 가까운 landscape 사이즈.
|
||||
|
||||
OPENAI_IMAGE_SIZE 환경변수로 override 가능.
|
||||
- gpt-image-1: 1536x1024 (3:2)
|
||||
- dall-e-3: 1792x1024 (7:4)
|
||||
- 기타: 1024x1024 (square 폴백)
|
||||
"""
|
||||
override = os.getenv("OPENAI_IMAGE_SIZE", "")
|
||||
if override:
|
||||
return override
|
||||
m = (model or "").lower()
|
||||
if "dall-e-3" in m or "dalle3" in m:
|
||||
return "1792x1024"
|
||||
if "gpt-image" in m:
|
||||
return "1536x1024"
|
||||
return "1024x1024"
|
||||
|
||||
|
||||
async def _generate_with_dalle(prompt_template: str, mood: str,
|
||||
feedback: str, out_path: str,
|
||||
*, api_key: str, model: str,
|
||||
@@ -124,13 +143,15 @@ async def _generate_with_dalle(prompt_template: str, mood: str,
|
||||
prompt = f"{prompt}, {mood} mood"
|
||||
if feedback:
|
||||
prompt = f"{prompt}. 추가 지시: {feedback}"
|
||||
prompt = f"{prompt}, no text, high quality"
|
||||
# cinematic landscape 명시 — 16:9 영상에 시각적으로 fit하도록 구도 유도
|
||||
prompt = f"{prompt}, no text, high quality, cinematic landscape composition, wide aspect"
|
||||
|
||||
image_size = _get_image_size(model)
|
||||
async with httpx.AsyncClient(timeout=DALLE_TIMEOUT_S) as client:
|
||||
resp = await client.post(
|
||||
"https://api.openai.com/v1/images/generations",
|
||||
headers={"Authorization": f"Bearer {api_key}"},
|
||||
json={"model": model, "prompt": prompt, "size": "1024x1024", "n": 1},
|
||||
json={"model": model, "prompt": prompt, "size": image_size, "n": 1},
|
||||
)
|
||||
resp.raise_for_status()
|
||||
data = resp.json()["data"][0]
|
||||
|
||||
Reference in New Issue
Block a user