feat: ASR output frame numbers + rename start/end to start_time/end_time

- Python: asr_processor.py detects FPS from CUT/ffprobe (no fallback), outputs start_frame/end_frame
- Rust: All AsrSegment structs use start_time/end_time with #[serde(alias)] for backward compat
- store_asr_chunks: prefers ASR output frames, falls back to time-based conversion
- Added backward compatibility test for old JSON format (start/end)

Breaking change: ffprobe/CUT FPS failure now aborts instead of using default 24fps
This commit is contained in:
Accusys
2026-05-19 13:22:38 +08:00
parent 26725dcab7
commit 67ca846ccd
9 changed files with 572 additions and 68 deletions
+5 -3
View File
@@ -23,8 +23,10 @@ struct CutResult {
#[derive(Debug, Deserialize)]
struct AsrSegment {
start: f64,
end: f64,
#[serde(alias = "start")]
start_time: f64,
#[serde(alias = "end")]
end_time: f64,
text: String,
}
@@ -62,7 +64,7 @@ pub async fn ingest_rule3(pool: &PgPool, file_uuid: &str) -> Result<usize> {
let mut child_ids: Vec<String> = Vec::new();
for seg in &asr_segments {
if seg.start >= scene.start_time && seg.end <= scene.end_time {
if seg.start_time >= scene.start_time && seg.end_time <= scene.end_time {
scene_text.push_str(&seg.text);
scene_text.push(' ');
// We'll look up the chunk_id from Rule 1 later if needed,
+4 -4
View File
@@ -51,8 +51,8 @@ impl ChunkSplitter {
format!("{}", index),
ChunkType::Sentence,
ChunkRule::Rule1,
segment.start,
segment.end,
segment.start_time,
segment.end_time,
self.fps,
serde_json::json!({
"text": segment.text,
@@ -67,8 +67,8 @@ impl ChunkSplitter {
#[derive(Debug, Clone)]
pub struct AsrSegment {
pub start: f64,
pub end: f64,
pub start_time: f64,
pub end_time: f64,
pub text: String,
pub speaker_id: Option<String>,
}