From aab2a3199b65b30c2abf5d99a1d8751d83ff1887 Mon Sep 17 00:00:00 2001 From: "hehihoho3@gmail.com" Date: Tue, 4 Aug 2026 17:12:01 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BB=B7=EB=B3=84=20=EC=9E=90=EB=A7=89=20?= =?UTF-8?q?=EC=B6=94=EC=B6=9C=20=ED=97=AC=ED=8D=BC=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(captions=5Ffor=5Fplaces)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 받아쓰기(ASR) 결과에서 컷 구간별로 자막을 이어붙이는 순수 함수. - 시간축 겹침 판정: 닿기만(경계) 제외, 조금이라도 겹치면 포함 - 공백 정규화: 여러 칸 → 공백 하나 - 토큰 제한: cap 문자에서 자르기 (Gemini 효율) - 테스트 모두 통과 (경계 규칙·공백·길이·엣지 케이스) 다음 단계(2단)에서 세 탭이 모두 호출할 예정. Co-Authored-By: Claude Opus 5 (1M context) --- capcut_agent/pipeline.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/capcut_agent/pipeline.py b/capcut_agent/pipeline.py index 3d87a9e..79936e2 100644 --- a/capcut_agent/pipeline.py +++ b/capcut_agent/pipeline.py @@ -167,6 +167,21 @@ def _remap_placements(placements, keep_sorted): for p0, p1 in placements] +def captions_for_places(captions, places, *, cap: int = 500): + """컷 구간마다 그 구간에 걸친 자막을 이어붙인다 — 댓글 추천의 근거. + + `captions`·`places` 둘 다 **같은(압축) 타임라인** 좌표여야 한다. 겹치는 부분이 + 조금이라도 있으면 그 컷의 말로 본다(경계에 닿기만 하는 건 제외). + cap 자에서 자른다 — 그 이상은 Gemini 토큰만 먹고 매칭 정확도가 안 오른다. + Returns: places 와 같은 길이의 문자열 리스트 + """ + out = [] + for p0, p1 in places: + parts = [txt for cs, ce, txt in captions if cs < p1 and ce > p0 and txt] + out.append(" ".join(" ".join(parts).split())[:cap]) + return out + + def _safe_name(name: str) -> str: s = "".join(c for c in name if c.isalnum() or c in (" ", "_", "-", ".")).strip() return s[:60] or "video"