Files
audio2text/app/services/types.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

39 lines
760 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.

"""管线各阶段共享的数据传输对象DTO
独立于任何模型加载逻辑——segmenter纯算法和 srt_writer纯 IO可以只依赖
本模块,不拉入 faster_whisper / torch。
"""
from __future__ import annotations
from dataclasses import dataclass
@dataclass
class Word:
"""ASR 识别出的单个词,带时间戳。"""
text: str
start: float # 秒
end: float
probability: float = 1.0
@dataclass
class Segment:
"""ASR 输出的一段文本,可能含词级时间戳。"""
text: str
start: float
end: float
words: list[Word]
@dataclass
class Subtitle:
"""断句后的一条字幕:英文文本 + 起止时间戳。"""
text: str
start: float
end: float