refactor: 视频字幕AI并入视频工具 — 新增「AI智能」分组+AI字幕生成卡(语言选择/Whisper转录/SRT下载/AI翻译英日文/时间轴预览), 移除独立/video-subtitle入口, 授权与试用归入video-tools
This commit is contained in:
1 parent
6bcdfebf04
commit
98c0dedffd
8 files changed
+229
-460
No files matched your search
@@ -1731,7 +1731,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
# ---------- 视频字幕:转录 + 翻译 ----------
|
||||
def _handle_subtitle(self):
|
||||
machine = self.headers.get("X-Machine-Id", "")
|
||||
if check(machine, "video-subtitle") != 200:
|
||||
if check(machine, "video-tools") != 200:
|
||||
self._reply(403, json.dumps({"code": 403, "message": "需要授权或免费试用已结束"}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
return
|
||||
try:
|
||||
@@ -1771,7 +1771,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
lang = (q.get("lang") or [""])[0]
|
||||
result = audio_ops.run_asr(wav, lang)
|
||||
shutil.rmtree(wd, ignore_errors=True)
|
||||
log_usage(machine, "video-subtitle")
|
||||
log_usage(machine, "video-tools")
|
||||
self._reply(200, json.dumps({"code": 200, "message": "ok", "data": result}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
except Exception as e: # noqa: BLE001
|
||||
import traceback
|
||||
@@ -1781,7 +1781,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
def _handle_translate_srt(self):
|
||||
payload = self._read_payload()
|
||||
machine = str(payload.get("machine") or "")
|
||||
if check(machine, "video-subtitle") != 200:
|
||||
if check(machine, "video-tools") != 200:
|
||||
self._reply(403, json.dumps({"code": 403, "message": "需要授权或免费试用已结束"}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
return
|
||||
srt = str(payload.get("srt") or "").strip()
|
||||
@@ -1795,7 +1795,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||
{"role": "system", "content": f"你是专业字幕翻译。把用户提供的 SRT 字幕翻译成{tname}:保留序号、时间轴和空行结构完全不变,只翻译每条字幕的文字部分;译文保持口语化、简洁(每行尽量不超过原长的 1.3 倍)。只输出翻译后的 SRT,不要解释。"},
|
||||
{"role": "user", "content": srt},
|
||||
])
|
||||
log_usage(machine, "video-subtitle")
|
||||
log_usage(machine, "video-tools")
|
||||
self._reply(200, json.dumps({"code": 200, "message": "ok", "data": {"reply": reply}}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
except Exception as e: # noqa: BLE001
|
||||
self._reply(502, json.dumps({"code": 502, "message": f"翻译失败: {e}"}, ensure_ascii=False).encode(), "application/json")
|
||||
|
||||
Reference in new issue
Block a user