101 lines
2.4 KiB
Rust
101 lines
2.4 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum TaskStatus {
|
|
Queued,
|
|
Extracting,
|
|
VadProcessing,
|
|
Transcribing,
|
|
Translating,
|
|
Completed,
|
|
Failed,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum TargetLanguage {
|
|
Zh,
|
|
En,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum OutputMode {
|
|
Source,
|
|
Translate,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct SubtitleSegment {
|
|
pub id: String,
|
|
pub task_id: String,
|
|
pub start: f32,
|
|
pub end: f32,
|
|
pub source_text: String,
|
|
pub translated_text: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct SubtitleTask {
|
|
pub id: String,
|
|
pub file_path: String,
|
|
pub file_name: String,
|
|
pub source_lang: Option<String>,
|
|
pub target_lang: TargetLanguage,
|
|
pub output_mode: OutputMode,
|
|
pub bilingual_output: bool,
|
|
pub status: TaskStatus,
|
|
pub progress: f32,
|
|
pub segments: Vec<SubtitleSegment>,
|
|
pub error: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct StartTaskPayload {
|
|
pub file_path: String,
|
|
pub source_lang: Option<String>,
|
|
pub target_lang: TargetLanguage,
|
|
pub output_mode: OutputMode,
|
|
pub bilingual_output: bool,
|
|
pub translation_config: Option<TranslationConfig>,
|
|
pub whisper_model_path: Option<String>,
|
|
pub vad_model_path: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ProgressEvent {
|
|
pub task_id: String,
|
|
pub status: TaskStatus,
|
|
pub progress: f32,
|
|
pub message: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct SegmentEvent {
|
|
pub task_id: String,
|
|
pub segment: SubtitleSegment,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct ErrorEvent {
|
|
pub task_id: String,
|
|
pub message: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct TranslationConfig {
|
|
pub api_base: String,
|
|
pub api_key: String,
|
|
pub model: String,
|
|
pub batch_size: usize,
|
|
pub context_size: usize,
|
|
}
|