Initial commit: audio2text 双语字幕生成服务
- 音频/视频转双语(英/中)SRT 字幕,Docker 容器化,CPU 开发/GPU 生产同一份代码 - faster-whisper ASR(词级时间戳) + 断句时间戳重算 + NLLB 翻译(模型不共驻) - 分片上传(断点续传) + SQLite 持久化 + 主页/历史/日志页面 - 历史页文件名搜索;缓存定时清理(默认保留7天,可配置) - 双 Dockerfile(cpu/gpu) + setup/start/stop 脚本
This commit is contained in:
0
app/schemas/__init__.py
Normal file
0
app/schemas/__init__.py
Normal file
69
app/schemas/task.py
Normal file
69
app/schemas/task.py
Normal file
@@ -0,0 +1,69 @@
|
||||
"""任务与分片上传接口 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
|
||||
|
||||
|
||||
class TaskListResponse(BaseModel):
|
||||
tasks: list[TaskResponse]
|
||||
total: int
|
||||
Reference in New Issue
Block a user