feat: 调度器+并发管线+GPU优化+日志分级+前端修复
- scheduler: ffmpeg 异步线程 + GPU 串行调度 + 模型复用(2N→2 次加载) - pipeline: 阶段拆分(extract/asr/translate),中间数据存 Task 字段 - translate_service: 长度排序批处理,padding 浪费减少 91% - model_manager: ASR/翻译不共驻,BatchedInferencePipeline 批量解码 - 日志分级: INFO=任务流转里程碑,DEBUG=进度详情;默认 INFO - 前端: 日志最新在上+滚动感知+退避轮询;24h 时间;上传中状态显示 - /health: 返回完整 Whisper/NLLB 配置 - upload_service: 单事务 complete + 扩展名白名单 - task_router: 合并 UploadSession 虚拟任务到列表 - Dockerfile: CPU/GPU 独立构建链,deps 缓存稳定 - prefetch_models: 安装时预下载模型权重
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""运行时配置:所有参数从 config.yaml 读取,对齐 server/config.py 的风格。
|
||||
"""运行时配置:所有参数从 config.yaml 读取。
|
||||
|
||||
CPU dev / GPU prod 仅靠 device / model / compute_type 三项切换,代码完全不变。
|
||||
默认值与 config.example.yaml 对齐,确保无 yaml 时也能用最小配置启动。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -40,21 +41,23 @@ class ProcessingConfig(BaseModel):
|
||||
|
||||
|
||||
class AsrConfig(BaseModel):
|
||||
model: str = "small"
|
||||
device: str = "cpu" # cpu | cuda
|
||||
compute_type: str = "int8" # cpu: int8;gpu: float16
|
||||
model: str = "tiny.en" # CPU: tiny.en;GPU: large-v3-turbo
|
||||
device: str = "cpu" # cpu | cuda
|
||||
compute_type: str = "int8" # cpu: int8;gpu: float16
|
||||
language: str = "en"
|
||||
word_timestamps: bool = True
|
||||
vad_filter: bool = True
|
||||
batch_size: int = 8 # BatchedInferencePipeline 的音频块批大小;GPU 建议 16
|
||||
|
||||
|
||||
class TranslationConfig(BaseModel):
|
||||
model: str = "facebook/nllb-200-distilled-1.3B"
|
||||
device: str = "cpu" # cpu | cuda
|
||||
src_lang: str = "eng_Latn"
|
||||
tgt_lang: str = "zho_Hans"
|
||||
batch_size: int = 16
|
||||
max_length: int = 256
|
||||
model: str = "Helsinki-NLP/opus-mt-en-zh" # CPU: opus-mt(轻量);GPU: facebook/nllb-200-distilled-1.3B
|
||||
device: str = "cpu" # cpu | cuda
|
||||
src_lang: str = "eng_Latn" # NLLB 语言码:英语
|
||||
tgt_lang: str = "zho_Hans" # NLLB 语言码:简体中文
|
||||
batch_size: int = 8 # 排序后单批最大条数;CPU: 8,GPU: 32(显存独占可用大 batch)
|
||||
max_length: int = 256 # 单条最大生成 token 数
|
||||
sort_by_length: bool = True # 按句子长度排序后分批,减少批内 padding 浪费(GPU 收益大)
|
||||
|
||||
|
||||
class SegmentationConfig(BaseModel):
|
||||
@@ -68,8 +71,8 @@ class LoggingConfig(BaseModel):
|
||||
"""日志配置:控制台 + 内存缓冲的最低级别,以及缓冲条数。
|
||||
|
||||
分层语义:
|
||||
- debug:详细(ffmpeg 命令、模型加载/卸载、转写逐段、翻译逐批进度)
|
||||
- info:简略(仅任务阶段转换,如 "任务 N [transcribing 55%]")
|
||||
- debug:进度详情(任务 [status pct%]、转写/翻译逐批统计、ffmpeg 命令)
|
||||
- info:任务流转里程碑(音频提取/ASR/翻译 的开始与完成、模型加载与卸载)
|
||||
- error:详细错误(完整 traceback,由 logger.exception 自带)
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user