crosssubtitle-ai/src/lib/types.ts
2026-03-18 22:14:49 +08:00

71 lines
1.3 KiB
TypeScript

export type TaskStatus =
| 'queued'
| 'extracting'
| 'vad_processing'
| 'transcribing'
| 'translating'
| 'completed'
| 'failed'
export type TargetLanguage = 'zh' | 'en'
export type OutputMode = 'source' | 'translate'
export interface SubtitleSegment {
id: string
taskId: string
start: number
end: number
sourceText: string
translatedText?: string | null
}
export interface SubtitleTask {
id: string
filePath: string
fileName: string
sourceLang?: string | null
targetLang: TargetLanguage
outputMode: OutputMode
bilingualOutput: boolean
status: TaskStatus
progress: number
segments: SubtitleSegment[]
error?: string | null
}
export interface TranslationConfig {
apiBase: string
apiKey: string
model: string
batchSize: number
contextSize: number
}
export interface StartTaskPayload {
filePath: string
sourceLang?: string | null
targetLang: TargetLanguage
outputMode: OutputMode
bilingualOutput: boolean
translationConfig?: TranslationConfig | null
whisperModelPath?: string | null
vadModelPath?: string | null
}
export interface ProgressEvent {
taskId: string
status: TaskStatus
progress: number
message: string
}
export interface SegmentEvent {
taskId: string
segment: SubtitleSegment
}
export interface ErrorEvent {
taskId: string
message: string
}