Files
audio2text/app/schemas/task.py
audio2text dev 73110848f4 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: 安装时预下载模型权重
2026-07-06 21:59:59 +08:00

75 lines
1.8 KiB
Python
Raw 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.

"""任务与分片上传接口 DTO。"""
from __future__ import annotations
from datetime import datetime
from pydantic import BaseModel, Field
# ---------------- 分片上传(对齐 server 的协议) ----------------
class CreateSessionRequest(BaseModel):
"""创建一个分片上传会话。"""
filename: str = Field(..., description="客户端原始文件名")
size_bytes: int = Field(..., ge=0, description="文件总字节数")
chunk_size: int = Field(..., gt=0, description="分片大小(字节)")
total_chunks: int = Field(..., gt=0, description="分片总数")
class CreateSessionResponse(BaseModel):
upload_id: str
filename: str
size_bytes: int
chunk_size: int
total_chunks: int
class SessionStatusResponse(BaseModel):
upload_id: str
filename: str
size_bytes: int
chunk_size: int
total_chunks: int
uploaded_chunks: list[int]
completed: bool
task_id: int | None = Field(None, description="completed=true 时指向 Task.id")
class ChunkUploadResponse(BaseModel):
upload_id: str
index: int
uploaded_chunks: list[int]
class CompleteResponse(BaseModel):
"""complete 的回执:创建出转写任务,返回 task_id。"""
task_id: int
filename: str
size_bytes: int
status: str
# ---------------- 任务查询 ----------------
class TaskResponse(BaseModel):
id: int
filename: str
status: str
progress: float
error: str | None
created_at: datetime
updated_at: datetime
# 上传会话虚拟任务用is_upload=true 时 id 无意义(固定 0
# 前端用 upload_id 轮询 /api/tasks/chunk-uploads/{upload_id}/status
size_bytes: int | None = None
is_upload: bool = False
upload_id: str | None = None
class TaskListResponse(BaseModel):
tasks: list[TaskResponse]
total: int