Initial commit: Momentry Core v0.1

- Rust-based digital asset management system
- Video analysis: ASR, OCR, YOLO, Face, Pose
- RAG capabilities with Qdrant vector database
- Multi-database support: PostgreSQL, Redis, MongoDB
- Monitoring system with launchd plists
- n8n workflow automation integration
This commit is contained in:
accusys
2026-03-16 15:07:33 +08:00
parent ca24794853
commit 75edf0aa71
101 changed files with 19858 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
pub mod splitter;
pub mod types;
pub use splitter::{AsrSegment, ChunkSplitter};
pub use types::{Chunk, ChunkType};
+67
View File
@@ -0,0 +1,67 @@
use super::types::{Chunk, ChunkType};
use anyhow::Result;
pub struct ChunkSplitter {
time_based_duration: f64,
}
impl ChunkSplitter {
pub fn new(time_based_duration_seconds: f64) -> Self {
Self {
time_based_duration: time_based_duration_seconds,
}
}
pub fn split_time_based(&self, uuid: &str, duration: f64) -> Vec<Chunk> {
let mut chunks = Vec::new();
let mut index = 0;
let mut current_time = 0.0;
while current_time < duration {
let end_time = (current_time + self.time_based_duration).min(duration);
chunks.push(Chunk::new(
uuid.to_string(),
index,
ChunkType::TimeBased,
current_time,
end_time,
serde_json::json!({
"source": "time_based",
"duration": self.time_based_duration,
}),
));
current_time = end_time;
index += 1;
}
chunks
}
pub fn split_sentence(&self, uuid: &str, asr_segments: &[AsrSegment]) -> Vec<Chunk> {
let mut chunks = Vec::new();
for (index, segment) in asr_segments.iter().enumerate() {
chunks.push(Chunk::new(
uuid.to_string(),
index as u32,
ChunkType::Sentence,
segment.start,
segment.end,
serde_json::json!({
"text": segment.text,
"speaker_id": segment.speaker_id,
}),
));
}
chunks
}
}
#[derive(Debug, Clone)]
pub struct AsrSegment {
pub start: f64,
pub end: f64,
pub text: String,
pub speaker_id: Option<String>,
}
+52
View File
@@ -0,0 +1,52 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum ChunkType {
TimeBased,
Sentence,
Cut,
}
impl ChunkType {
pub fn as_str(&self) -> &'static str {
match self {
ChunkType::TimeBased => "time_based",
ChunkType::Sentence => "sentence",
ChunkType::Cut => "cut",
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Chunk {
pub uuid: String,
pub chunk_id: String,
pub chunk_index: u32,
pub chunk_type: ChunkType,
pub start_time: f64,
pub end_time: f64,
pub content: serde_json::Value,
}
impl Chunk {
pub fn new(
uuid: String,
chunk_index: u32,
chunk_type: ChunkType,
start_time: f64,
end_time: f64,
content: serde_json::Value,
) -> Self {
let chunk_id = format!("{}_{:04}", chunk_type.as_str(), chunk_index);
Self {
uuid,
chunk_id: chunk_id.clone(),
chunk_index,
chunk_type,
start_time,
end_time,
content,
}
}
}