fix: 统一编辑模式枚举名并删除重复workflow #32
@@ -1,113 +0,0 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: runtime-builder:host
|
||||
container:
|
||||
image: localhost:5000/xiaoxia-ci-python:3.12
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
python - <<'PY'
|
||||
import io
|
||||
import os
|
||||
import tarfile
|
||||
import urllib.request
|
||||
|
||||
url = f"{os.environ['GITHUB_API_URL']}/repos/{os.environ['GITHUB_REPOSITORY']}/archive/{os.environ['GITHUB_SHA']}.tar.gz"
|
||||
request = urllib.request.Request(url, headers={"Authorization": f"token {os.environ['GITHUB_TOKEN']}"})
|
||||
with urllib.request.urlopen(request, timeout=120) as response:
|
||||
archive = response.read()
|
||||
|
||||
with tarfile.open(fileobj=io.BytesIO(archive), mode='r:gz') as tar:
|
||||
root_prefix = tar.getmembers()[0].name.split('/', 1)[0] + '/'
|
||||
for member in tar.getmembers():
|
||||
name = member.name
|
||||
if name == root_prefix[:-1]:
|
||||
continue
|
||||
if name.startswith(root_prefix):
|
||||
member.name = name[len(root_prefix):]
|
||||
if member.name:
|
||||
tar.extract(member, '.')
|
||||
PY
|
||||
|
||||
- name: Show Python version
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
python --version
|
||||
python -m pip --version
|
||||
|
||||
- name: Install dependencies
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
python -m pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
||||
python -m pip install -r requirements.txt -r requirements-dev.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
||||
|
||||
- name: Run tests
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
PYTHONPATH="$PWD/apps/api:$PWD" python -m pytest tests/unit -q
|
||||
|
||||
lint:
|
||||
runs-on: runtime-builder:host
|
||||
container:
|
||||
image: localhost:5000/xiaoxia-ci-python:3.12
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
python - <<'PY'
|
||||
import io
|
||||
import os
|
||||
import tarfile
|
||||
import urllib.request
|
||||
|
||||
url = f"{os.environ['GITHUB_API_URL']}/repos/{os.environ['GITHUB_REPOSITORY']}/archive/{os.environ['GITHUB_SHA']}.tar.gz"
|
||||
request = urllib.request.Request(url, headers={"Authorization": f"token {os.environ['GITHUB_TOKEN']}"})
|
||||
with urllib.request.urlopen(request, timeout=120) as response:
|
||||
archive = response.read()
|
||||
|
||||
with tarfile.open(fileobj=io.BytesIO(archive), mode='r:gz') as tar:
|
||||
root_prefix = tar.getmembers()[0].name.split('/', 1)[0] + '/'
|
||||
for member in tar.getmembers():
|
||||
name = member.name
|
||||
if name == root_prefix[:-1]:
|
||||
continue
|
||||
if name.startswith(root_prefix):
|
||||
member.name = name[len(root_prefix):]
|
||||
if member.name:
|
||||
tar.extract(member, '.')
|
||||
PY
|
||||
|
||||
- name: Install dependencies
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
python -m pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
||||
python -m pip install -r requirements.txt -r requirements-dev.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
||||
|
||||
- name: Run Black (check only)
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
python -m black --check alembic apps packages tests scripts
|
||||
|
||||
- name: Run Flake8
|
||||
shell: sh
|
||||
run: |
|
||||
set -eu
|
||||
python -m flake8 apps packages tests --count --statistics
|
||||
@@ -205,10 +205,10 @@ def auto_generate_edit_plan(
|
||||
|
||||
根据素材的分类结果和质量评分,自动编排剪辑计划。
|
||||
支持多种剪辑模式:
|
||||
- one-take: 按分类分组,组内按质量排序,顺序拼接
|
||||
- one_take: 按分类分组,组内按质量排序,顺序拼接
|
||||
- pip: 第一个高质量素材为主画面,其余为画中画
|
||||
- voiceover: person 类素材为主播口播,其余穿插为 B-roll
|
||||
- voice_pip: 结合 voiceover 和 pip,第一个高质量 person 素材为主画面
|
||||
- voice_over: person 类素材为主播口播,其余穿插为 B-roll
|
||||
- voice_pip: 结合 voice_over 和 pip,第一个高质量 person 素材为主画面
|
||||
"""
|
||||
_ensure_project(
|
||||
project_id, request.workspace_id, authenticated_user, project_repository, workspace_member_repository
|
||||
|
||||
@@ -35,7 +35,7 @@ class EditPlanResponse(BaseModel):
|
||||
title_id: str = ""
|
||||
status: str
|
||||
summary: str
|
||||
editing_mode: str | None = None # one-take, pip, voiceover, voice_pip
|
||||
editing_mode: str | None = None # one_take, pip, voice_over, voice_pip
|
||||
clips: list[EditPlanClipResponse] = Field(default_factory=list)
|
||||
created_at: datetime | None = None
|
||||
updated_at: datetime | None = None
|
||||
@@ -53,8 +53,8 @@ class AutoGenerateEditPlanRequest(BaseModel):
|
||||
workspace_id: str
|
||||
asset_library_id: str
|
||||
editing_mode: str = Field(
|
||||
default="one-take",
|
||||
description="剪辑模式: one-take, pip, voiceover, voice_pip"
|
||||
default="one_take",
|
||||
description="剪辑模式: one_take, pip, voice_over, voice_pip"
|
||||
)
|
||||
target_duration: float = Field(
|
||||
default=30.0,
|
||||
|
||||
@@ -14,9 +14,9 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class EditingMode(StrEnum):
|
||||
"""剪辑模式枚举"""
|
||||
ONE_TAKE = "one-take" # 顺序拼接模式
|
||||
ONE_TAKE = "one_take" # 顺序拼接模式
|
||||
PIP = "pip" # 画中画模式
|
||||
VOICEOVER = "voiceover" # 口播+B-roll模式
|
||||
VOICE_OVER = "voice_over" # 口播+B-roll模式
|
||||
VOICE_PIP = "voice_pip" # 口播+画中画组合模式
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class SmartEditPlanGenerator:
|
||||
智能剪辑计划生成器
|
||||
|
||||
根据素材的分类结果和质量评分,自动编排剪辑计划。
|
||||
支持多种剪辑模式:one-take, pip, voiceover, voice_pip
|
||||
支持多种剪辑模式:one_take, pip, voice_over, voice_pip
|
||||
"""
|
||||
|
||||
def __init__(self, project_id: str, assets: list[Asset]):
|
||||
@@ -278,7 +278,7 @@ class SmartEditPlanGenerator:
|
||||
_calculate_start_times(clips)
|
||||
return EditPlanResult(
|
||||
project_id=self.project_id,
|
||||
editing_mode=EditingMode.VOICEOVER,
|
||||
editing_mode=EditingMode.VOICE_OVER,
|
||||
clips=clips,
|
||||
total_duration=total_duration,
|
||||
summary=f"Voiceover 模式:{person_count} 段口播 + {len(clips) - person_count} 段 B-roll"
|
||||
@@ -347,14 +347,14 @@ class SmartEditPlanGenerator:
|
||||
|
||||
def generate_plan(
|
||||
self,
|
||||
editing_mode: str = "one-take",
|
||||
editing_mode: str = "one_take",
|
||||
target_duration: float = 30.0
|
||||
) -> EditPlanResult:
|
||||
"""
|
||||
生成剪辑计划
|
||||
|
||||
Args:
|
||||
editing_mode: 剪辑模式 (one-take/pip/voiceover/voice_pip)
|
||||
editing_mode: 剪辑模式 (one_take/pip/voice_over/voice_pip)
|
||||
target_duration: 目标时长(秒)
|
||||
|
||||
Returns:
|
||||
@@ -378,7 +378,7 @@ class SmartEditPlanGenerator:
|
||||
return self._generate_one_take(target_duration)
|
||||
elif mode == EditingMode.PIP:
|
||||
return self._generate_pip(target_duration)
|
||||
elif mode == EditingMode.VOICEOVER:
|
||||
elif mode == EditingMode.VOICE_OVER:
|
||||
return self._generate_voiceover(target_duration)
|
||||
elif mode == EditingMode.VOICE_PIP:
|
||||
return self._generate_voice_pip(target_duration)
|
||||
|
||||
Reference in New Issue
Block a user