Files
audio2text/app/services/reaper.py
zikai 00e2a95fb7 Initial commit: audio2text 双语字幕生成服务
- 音频/视频转双语(英/中)SRT 字幕,Docker 容器化,CPU 开发/GPU 生产同一份代码
- faster-whisper ASR(词级时间戳) + 断句时间戳重算 + NLLB 翻译(模型不共驻)
- 分片上传(断点续传) + SQLite 持久化 + 主页/历史/日志页面
- 历史页文件名搜索;缓存定时清理(默认保留7天,可配置)
- 双 Dockerfile(cpu/gpu) + setup/start/stop 脚本
2026-07-06 06:54:19 +00:00

23 lines
621 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""后台 reaper清理被放弃的分片上传会话与临时文件。供 main.py 启动时调用。"""
from __future__ import annotations
import logging
from ..database import get_session_local
from .upload_service import UploadService
logger = logging.getLogger("audio2text.reaper")
def reap_stale_sessions() -> int:
"""执行一次过期会话清理。"""
db = get_session_local()()
try:
return UploadService(db).reap_stale_sessions()
except Exception as exc: # pragma: no cover
logger.warning("reaper 执行失败:%s", exc)
return 0
finally:
db.close()