Initial commit: audio2text 双语字幕生成服务

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

57
config.cpu.yaml Normal file
View File

@@ -0,0 +1,57 @@
# audio2text — CPU 开发配置
# 模型选同系列最小尺寸,验证流程 + 贴近 GPU 生产环境:
# ASR = whisper tiny.en39M英文专用Whisper 同系列最小)
# 翻译 = opus-mt-en-zh~300MBNLLB-600M 需 ~2.4GB 内存2GB 开发机 OOM
# 故回退到最轻量英译中模型。翻译质量与 GPU 的 NLLB 有差异,但流程一致)
# 其余配置(存储、断句、输出格式)与 GPU 版完全一致,仅模型/device/compute_type 不同。
server:
host: 0.0.0.0
port: 8000
workers: 1
storage:
upload_dir: /data/uploads
work_dir: /data/.work
output_dir: /data/outputs
chunk_bytes: 1048576
chunk_session_ttl_seconds: 300
cache_retention_days: 7 # 任务产物保留天数,超期清理(字幕/中间音频/保留的原始视频+DB记录
cache_cleanup_interval_hours: 24 # 定时清理间隔(启动时跑一次,之后循环)
processing:
delete_original_after_extract: true
keep_audio: false
asr:
model: tiny.en # Whisper 同系列最小39M英文专用
device: cpu
compute_type: int8 # CPU 量化,最省内存
language: en
word_timestamps: true
vad_filter: true
translation:
model: Helsinki-NLP/opus-mt-en-zh # 最轻量英译中(~300MBNLLB-600M 需 ~2.4GB2GB 机 OOM
device: cpu
src_lang: eng_Latn
tgt_lang: zho_Hans
batch_size: 8 # opus-mt 轻量batch 适中
max_length: 256
segmentation:
max_words_per_line: 14
max_duration_seconds: 7.0
min_duration_seconds: 1.0
max_chars_per_line: 42
logging:
level: info # debug=详细子步骤, info=仅阶段转换, error=完整 traceback
buffer_size: 2000
docs:
enabled: true
username: admin
password: "CHANGE_ME"
realm: "audio2text docs"