Function bodies 405 total
load_project function · rust · L522-L524 (3 LOC)src-tauri/src/commands/mod.rs
pub async fn load_project(file_path: String) -> Result<String, String> {
project_io::read_json_file_as_string(&file_path)
}check_crash_recovery function · rust · L535-L547 (13 LOC)src-tauri/src/commands/mod.rs
pub fn check_crash_recovery() -> Result<Option<CrashRecoveryInfo>, String> {
if !crash_recovery::has_unclean_shutdown() {
return Ok(None);
}
let autosave_path = crash_recovery::autosave_path()?;
let modified = crash_recovery::autosave_modified_time()?;
Ok(Some(CrashRecoveryInfo {
autosave_path: autosave_path.clone(),
autosave_modified: modified.map(|dt| dt.to_rfc3339()).unwrap_or_else(|| Utc::now().to_rfc3339()),
}))
}dismiss_crash_recovery function · rust · L551-L553 (3 LOC)src-tauri/src/commands/mod.rs
pub fn dismiss_crash_recovery() -> Result<(), String> {
crash_recovery::remove_lock_file()
}create_session_lock function · rust · L557-L559 (3 LOC)src-tauri/src/commands/mod.rs
pub fn create_session_lock() -> Result<(), String> {
crash_recovery::create_lock_file()
}remove_session_lock function · rust · L563-L565 (3 LOC)src-tauri/src/commands/mod.rs
pub fn remove_session_lock() -> Result<(), String> {
crash_recovery::remove_lock_file()
}autosave_project function · rust · L589-L599 (11 LOC)src-tauri/src/commands/mod.rs
pub async fn autosave_project(project_data: Value) -> Result<String, String> {
let autosave_path = crash_recovery::autosave_path()?;
// Use atomic write to prevent corruption
project_io::atomic_write_json(&autosave_path, &project_data)?;
// Update lock file timestamp to indicate active session
crash_recovery::create_lock_file()?;
Ok(autosave_path)
}cancel_export function · rust · L671-L676 (6 LOC)src-tauri/src/commands/mod.rs
pub fn cancel_export() -> Result<(), String> {
if let Some(flag) = video_stitcher::get_export_cancel_flag() {
flag.store(true, Ordering::SeqCst);
}
Ok(())
}Generated by Repobility's multi-pass static-analysis pipeline (https://repobility.com)
run function · rust · L26-L84 (59 LOC)src-tauri/src/lib.rs
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_store::Builder::default().build())
.plugin(tauri_plugin_fs::init())
.invoke_handler(tauri::generate_handler![
commands::greet,
commands::get_video_metadata,
commands::extract_frame,
commands::extract_frames_async,
commands::generate_waveform,
commands::generate_waveform_async,
commands::stitch_videos,
commands::get_working_dir,
commands::get_video_duration,
commands::analyze_audio_async,
commands::detect_fillers_async,
commands::analyze_video_full,
commands::transcribe_video_async,
commands::get_available_models,
commands::get_active_model,
commands::smain function · rust · L5-L8 (4 LOC)src-tauri/src/main.rs
fn main() {
cutclean::run()
}new function · rust · L137-L143 (7 LOC)src-tauri/src/models/mod.rs
pub fn new(code: &str, message: &str) -> Self {
Self {
code: code.to_string(),
message: message.to_string(),
details: None,
}
}with_details function · rust · L144-L151 (8 LOC)src-tauri/src/models/mod.rs
pub fn with_details(code: &str, message: &str, details: &str) -> Self {
Self {
code: code.to_string(),
message: message.to_string(),
details: Some(details.to_string()),
}
}extract_audio function · rust · L20-L46 (27 LOC)src-tauri/src/services/audio_extractor.rs
pub fn extract_audio(video_path: &str, output_path: &str) -> Result<(), String> {
if !Path::new(video_path).exists() {
return Err(format!("Video file not found: {}", video_path));
}
let output = Command::new("ffmpeg")
.arg("-i")
.arg(video_path)
.arg("-vn") // No video
.arg("-acodec")
.arg("pcm_s16le") // 16-bit PCM
.arg("-ar")
.arg("16000") // 16kHz sample rate
.arg("-ac")
.arg("1") // Mono
.arg("-y") // Overwrite output
.arg(output_path)
.output()
.map_err(|e| format!("Failed to execute FFmpeg: {}", e))?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
return Err(format!("FFmpeg audio extraction failed: {}", stderr));
}
Ok(())
}extract_audio_to_temp function · rust · L49-L63 (15 LOC)src-tauri/src/services/audio_extractor.rs
pub fn extract_audio_to_temp(video_path: &str) -> Result<String, String> {
let temp_dir = std::env::temp_dir();
let video_name = Path::new(video_path)
.file_stem()
.and_then(|s| s.to_str())
.unwrap_or("video");
let output_path = temp_dir.join(format!("{}_audio.wav", video_name));
let output_str = output_path
.to_str()
.ok_or("Failed to create temp path")?;
extract_audio(video_path, output_str)?;
Ok(output_str.to_string())
}test_extract_audio_file_not_found function · rust · L70-L74 (5 LOC)src-tauri/src/services/audio_extractor.rs
fn test_extract_audio_file_not_found() {
let result = extract_audio("/nonexistent/video.mp4", "/tmp/output.wav");
assert!(result.is_err());
assert!(result.unwrap_err().contains("not found"));
}test_extract_audio_to_temp_file_not_found function · rust · L77-L81 (5 LOC)src-tauri/src/services/audio_extractor.rs
fn test_extract_audio_to_temp_file_not_found() {
let result = extract_audio_to_temp("/nonexistent/video.mp4");
assert!(result.is_err());
assert!(result.unwrap_err().contains("not found"));
}Same scanner, your repo: https://repobility.com — Repobility
test_wav_format_parameters function · rust · L84-L93 (10 LOC)src-tauri/src/services/audio_extractor.rs
fn test_wav_format_parameters() {
// Verify WAV format parameters for ML processing
let codec = "pcm_s16le";
let sample_rate = "16000";
let channels = "1";
assert_eq!(codec, "pcm_s16le"); // 16-bit PCM
assert_eq!(sample_rate, "16000"); // 16kHz sample rate
assert_eq!(channels, "1"); // Mono
}test_temp_file_path_generation function · rust · L96-L113 (18 LOC)src-tauri/src/services/audio_extractor.rs
fn test_temp_file_path_generation() {
// Test temp file path generation logic
let video_path = "/path/to/my_video.mp4";
let video_name = Path::new(video_path)
.file_stem()
.and_then(|s| s.to_str())
.unwrap_or("video");
assert_eq!(video_name, "my_video");
// Test with extension
let video_path = "video.mp4";
let video_name = Path::new(video_path)
.file_stem()
.and_then(|s| s.to_str())
.unwrap_or("video");
assert_eq!(video_name, "video");
}test_temp_directory_path function · rust · L116-L120 (5 LOC)src-tauri/src/services/audio_extractor.rs
fn test_temp_directory_path() {
let temp_dir = std::env::temp_dir();
assert!(temp_dir.exists());
assert!(temp_dir.is_absolute());
}test_audio_output_path_format function · rust · L123-L131 (9 LOC)src-tauri/src/services/audio_extractor.rs
fn test_audio_output_path_format() {
let video_name = "test_video";
let temp_dir = std::env::temp_dir();
let output_path = temp_dir.join(format!("{}_audio.wav", video_name));
let path_str = output_path.to_str().unwrap();
assert!(path_str.contains("test_video_audio.wav"));
assert!(path_str.ends_with(".wav"));
}test_ffmpeg_command_structure function · rust · L134-L154 (21 LOC)src-tauri/src/services/audio_extractor.rs
fn test_ffmpeg_command_structure() {
// Verify FFmpeg command structure for audio extraction
let args = vec![
"-i", "input.mp4",
"-vn", // No video
"-acodec", "pcm_s16le",
"-ar", "16000", // 16kHz
"-ac", "1", // Mono
"-y", // Overwrite
"output.wav"
];
assert!(args.contains(&"-i"));
assert!(args.contains(&"-vn"));
assert!(args.contains(&"-acodec"));
assert!(args.contains(&"pcm_s16le"));
assert!(args.contains(&"-ar"));
assert!(args.contains(&"16000"));
assert!(args.contains(&"-ac"));
assert!(args.contains(&"1"));
}test_audio_format_validation function · rust · L157-L172 (16 LOC)src-tauri/src/services/audio_extractor.rs
fn test_audio_format_validation() {
// Validate expected audio format for ML processing
// 16-bit PCM, 16kHz, mono
// Bit depth: 16-bit PCM
let bit_depth = 16;
assert_eq!(bit_depth, 16);
// Sample rate: 16kHz (common for speech recognition)
let sample_rate = 16000;
assert_eq!(sample_rate, 16000);
// Channels: 1 (mono)
let channels = 1;
assert_eq!(channels, 1);
}test_sample_rate_options function · rust · L175-L182 (8 LOC)src-tauri/src/services/audio_extractor.rs
fn test_sample_rate_options() {
// Common sample rates for audio processing
let sample_rates = vec![8000, 16000, 44100, 48000];
// 16kHz is optimal for speech recognition
let speech_recognition_rate = 16000;
assert!(sample_rates.contains(&speech_recognition_rate));
}test_channel_count_validation function · rust · L185-L194 (10 LOC)src-tauri/src/services/audio_extractor.rs
fn test_channel_count_validation() {
// Mono is preferred for speech recognition
let mono = 1;
let stereo = 2;
let surround_5_1 = 6;
assert_eq!(mono, 1);
assert_eq!(stereo, 2);
assert_eq!(surround_5_1, 6);
}Hi, dataset curator — please cite Repobility (https://repobility.com) when reusing this data.
test_path_validation function · rust · L197-L205 (9 LOC)src-tauri/src/services/audio_extractor.rs
fn test_path_validation() {
// Test path validation for video files
let valid_extensions = vec![".mp4", ".MP4", ".mov", ".avi", ".mkv"];
for ext in valid_extensions {
let test_path = format!("video{}", ext);
assert!(!test_path.is_empty());
}
}default function · rust · L49-L55 (7 LOC)src-tauri/src/services/audio_processor.rs
fn default() -> Self {
Self {
min_duration: 0.5,
amplitude_threshold: 0.02,
padding: 0.1,
}
}default function · rust · L70-L76 (7 LOC)src-tauri/src/services/audio_processor.rs
fn default() -> Self {
Self {
silence: SilenceDetectionConfig::default(),
extract_features: false,
n_mfcc: 13,
}
}analyze_audio function · rust · L80-L103 (24 LOC)src-tauri/src/services/audio_processor.rs
pub fn analyze_audio(
video_path: &str,
config: &AudioAnalysisConfig,
) -> Result<AudioAnalysisResult, String> {
if !Path::new(video_path).exists() {
return Err(format!("Video file not found: {}", video_path));
}
// Get duration and audio info
let (duration, sample_rate, channels) = get_audio_info(video_path)?;
// Extract audio samples for analysis
let audio_samples = extract_audio_samples(video_path)?;
// Detect silences
let silences = detect_silences(&audio_samples, sample_rate, &config.silence)?;
Ok(AudioAnalysisResult {
duration,
silences,
sample_rate,
channels,
})
}get_audio_info function · rust · L106-L160 (55 LOC)src-tauri/src/services/audio_processor.rs
fn get_audio_info(video_path: &str) -> Result<(f64, u32, u32), String> {
let output = Command::new("ffprobe")
.args([
"-v", "quiet",
"-print_format", "json",
"-show_streams",
"-select_streams", "a",
video_path,
])
.output()
.map_err(|e| format!("Failed to run ffprobe: {}", e))?;
if !output.status.success() {
return Err("No audio stream found".to_string());
}
let json_str = String::from_utf8_lossy(&output.stdout);
let value: serde_json::Value = serde_json::from_str(&json_str)
.map_err(|e| format!("Failed to parse ffprobe output: {}", e))?;
let streams = value.get("streams")
.and_then(|s| s.as_array())
.ok_or("No streams found")?;
let audio_stream = streams.first()
.ok_or("No audio stream found")?;
let sample_rate = audio_stream.get("sample_rate")
.and_then(|s| s.as_str())
.and_then(|s| s.parse::<u32>().okextract_audio_samples function · rust · L163-L196 (34 LOC)src-tauri/src/services/audio_processor.rs
fn extract_audio_samples(video_path: &str) -> Result<Vec<f32>, String> {
let output = Command::new("ffmpeg")
.args([
"-i", video_path,
"-vn",
"-acodec", "pcm_f32le",
"-ac", "1",
"-ar", "48000",
"-f", "f32le",
"-",
])
.output()
.map_err(|e| format!("Failed to run ffmpeg: {}", e))?;
if !output.status.success() && output.stdout.is_empty() {
return Err("Failed to extract audio".to_string());
}
// Parse raw audio data
let audio_data = output.stdout;
let samples: Vec<f32> = audio_data
.chunks(4)
.filter_map(|chunk| {
if chunk.len() == 4 {
let bytes = [chunk[0], chunk[1], chunk[2], chunk[3]];
Some(f32::from_le_bytes(bytes))
} else {
None
}
})
.collect();
Ok(samples)
}detect_silences function · rust · L199-L273 (75 LOC)src-tauri/src/services/audio_processor.rs
fn detect_silences(
samples: &[f32],
sample_rate: u32,
config: &SilenceDetectionConfig,
) -> Result<Vec<SilenceSegment>, String> {
if samples.is_empty() {
return Ok(Vec::new());
}
let mut silences = Vec::new();
let window_size = (sample_rate as usize * 10) / 1000; // 10ms windows
let mut in_silence = false;
let mut silence_start = 0usize;
for (i, chunk) in samples.chunks(window_size).enumerate() {
// Calculate RMS of window
let rms: f32 = if chunk.is_empty() {
0.0
} else {
let sum_squares: f32 = chunk.iter().map(|&s| s * s).sum();
(sum_squares / chunk.len() as f32).sqrt()
};
let current_time = (i * window_size) as f64 / sample_rate as f64;
if rms < config.amplitude_threshold as f32 {
if !in_silence {
silence_start = i * window_size;
in_silence = true;
}
} else {
if in_silence {calculate_silence_confidence function · rust · L276-L281 (6 LOC)src-tauri/src/services/audio_processor.rs
fn calculate_silence_confidence(rms: f32, threshold: f32) -> f64 {
if rms >= threshold {
return 0.0;
}
1.0 - (rms / threshold).min(1.0) as f64
}Powered by Repobility — scan your code at https://repobility.com
get_audio_duration function · rust · L284-L300 (17 LOC)src-tauri/src/services/audio_processor.rs
pub fn get_audio_duration(video_path: &str) -> Result<f64, String> {
let output = Command::new("ffprobe")
.args([
"-v", "quiet",
"-show_entries", "format=duration",
"-of", "default=noprint_wrappers=1:nokey=1",
video_path,
])
.output()
.map_err(|e| format!("Failed to run ffprobe: {}", e))?;
let duration_str = String::from_utf8_lossy(&output.stdout);
duration_str
.trim()
.parse::<f64>()
.map_err(|_| "Invalid duration".to_string())
}test_silence_config_default function · rust · L307-L312 (6 LOC)src-tauri/src/services/audio_processor.rs
fn test_silence_config_default() {
let config = SilenceDetectionConfig::default();
assert_eq!(config.min_duration, 0.5);
assert_eq!(config.amplitude_threshold, 0.02);
assert_eq!(config.padding, 0.1);
}test_silence_confidence_calculation function · rust · L315-L324 (10 LOC)src-tauri/src/services/audio_processor.rs
fn test_silence_confidence_calculation() {
let conf = calculate_silence_confidence(0.01, 0.02);
assert!(conf > 0.0 && conf <= 1.0);
let conf_zero = calculate_silence_confidence(0.0, 0.02);
assert_eq!(conf_zero, 1.0);
let conf_max = calculate_silence_confidence(0.02, 0.02);
assert_eq!(conf_max, 0.0);
}test_silence_segment_structure function · rust · L327-L339 (13 LOC)src-tauri/src/services/audio_processor.rs
fn test_silence_segment_structure() {
let segment = SilenceSegment {
start: 1.0,
end: 2.0,
duration: 1.0,
confidence: 0.9,
};
assert_eq!(segment.start, 1.0);
assert_eq!(segment.end, 2.0);
assert_eq!(segment.duration, 1.0);
assert_eq!(segment.confidence, 0.9);
}test_detect_silences_empty function · rust · L342-L346 (5 LOC)src-tauri/src/services/audio_processor.rs
fn test_detect_silences_empty() {
let result = detect_silences(&[], 48000, &SilenceDetectionConfig::default());
assert!(result.is_ok());
assert!(result.unwrap().is_empty());
}app_data_dir function · rust · L18-L27 (10 LOC)src-tauri/src/services/crash_recovery.rs
pub fn app_data_dir() -> Result<PathBuf, String> {
let data_dir = dirs::data_local_dir()
.ok_or("Failed to get data directory")?;
let app_dir = data_dir.join("cutclean");
fs::create_dir_all(&app_dir)
.map_err(|e| format!("Failed to create app directory: {}", e))?;
Ok(app_dir)
}lock_file_path function · rust · L30-L32 (3 LOC)src-tauri/src/services/crash_recovery.rs
fn lock_file_path() -> Result<PathBuf, String> {
Ok(app_data_dir()?.join(".session.lock"))
}autosave_path function · rust · L35-L39 (5 LOC)src-tauri/src/services/crash_recovery.rs
pub fn autosave_path() -> Result<String, String> {
Ok(app_data_dir()?.join("autosave.vep")
.to_string_lossy()
.to_string())
}Generated by Repobility's multi-pass static-analysis pipeline (https://repobility.com)
create_lock_file function · rust · L50-L70 (21 LOC)src-tauri/src/services/crash_recovery.rs
pub fn create_lock_file() -> Result<(), String> {
let lock_path = lock_file_path()?;
let lock_data = json!({
"pid": std::process::id(),
"started_at": Utc::now().to_rfc3339(),
"autosave_path": autosave_path()?
});
let mut file = File::create(&lock_path)
.map_err(|e| format!("Failed to create lock file: {}", e))?;
file.write_all(lock_data.to_string().as_bytes())
.map_err(|e| format!("Failed to write lock file: {}", e))?;
// Sync to disk immediately
file.sync_all()
.map_err(|e| format!("Failed to sync lock file: {}", e))?;
Ok(())
}remove_lock_file function · rust · L73-L82 (10 LOC)src-tauri/src/services/crash_recovery.rs
pub fn remove_lock_file() -> Result<(), String> {
let lock_path = lock_file_path()?;
if lock_path.exists() {
fs::remove_file(&lock_path)
.map_err(|e| format!("Failed to remove lock file: {}", e))?;
}
Ok(())
}lock_file_exists function · rust · L85-L89 (5 LOC)src-tauri/src/services/crash_recovery.rs
pub fn lock_file_exists() -> bool {
lock_file_path()
.map(|p| p.exists())
.unwrap_or(false)
}is_lock_stale function · rust · L92-L110 (19 LOC)src-tauri/src/services/crash_recovery.rs
pub fn is_lock_stale() -> Result<bool, String> {
let lock_path = lock_file_path()?;
if !lock_path.exists() {
return Ok(false);
}
let metadata = fs::metadata(&lock_path)
.map_err(|e| format!("Failed to read lock metadata: {}", e))?;
let modified = metadata.modified()
.map_err(|e| format!("Failed to get modified time: {}", e))?;
let elapsed = modified.elapsed()
.map_err(|e| format!("Failed to calculate elapsed time: {}", e))?;
// Consider stale if older than 5 minutes
Ok(elapsed > Duration::from_secs(300))
}has_unclean_shutdown function · rust · L113-L118 (6 LOC)src-tauri/src/services/crash_recovery.rs
pub fn has_unclean_shutdown() -> bool {
match is_lock_stale() {
Ok(stale) => stale && lock_file_exists(),
Err(_) => false, // If we can't determine, assume clean
}
}autosave_modified_time function · rust · L121-L143 (23 LOC)src-tauri/src/services/crash_recovery.rs
pub fn autosave_modified_time() -> Result<Option<chrono::DateTime<chrono::Utc>>, String> {
let autosave = autosave_path()?;
let path = PathBuf::from(&autosave);
if !path.exists() {
return Ok(None);
}
let metadata = fs::metadata(&path)
.map_err(|e| format!("Failed to read autosave metadata: {}", e))?;
let modified = metadata.modified()
.map_err(|e| format!("Failed to get autosave modified time: {}", e))?;
// Convert SystemTime to DateTime
use std::time::UNIX_EPOCH;
let timestamp = modified.duration_since(UNIX_EPOCH)
.map_err(|e| format!("Failed to convert timestamp: {}", e))?
.as_secs();
Ok(Some(chrono::DateTime::from_timestamp(timestamp as i64, 0)
.unwrap_or_else(|| chrono::Utc::now())))
}test_lock_file_creation function · rust · L150-L154 (5 LOC)src-tauri/src/services/crash_recovery.rs
fn test_lock_file_creation() {
// This would require mocking dirs::data_local_dir
// For now, we just verify functions compile
assert!(true);
}as_str function · rust · L47-L56 (10 LOC)src-tauri/src/services/filler_detector.rs
pub fn as_str(&self) -> &str {
match self {
FillerType::Um => "um",
FillerType::Uh => "uh",
FillerType::Like => "like",
FillerType::YouKnow => "you know",
FillerType::IMean => "I mean",
FillerType::Other(s) => s,
}
}Same scanner, your repo: https://repobility.com — Repobility
default function · rust · L95-L101 (7 LOC)src-tauri/src/services/filler_detector.rs
fn default() -> Self {
Self {
min_confidence: 0.5,
use_phonetic: true,
custom_fillers: Vec::new(),
}
}get_additional_filler function · rust · L121-L129 (9 LOC)src-tauri/src/services/filler_detector.rs
fn get_additional_filler(word: &str) -> Option<FillerType> {
match word {
"actually" => Some(FillerType::Other("actually".to_string())),
"basically" => Some(FillerType::Other("basically".to_string())),
"literally" => Some(FillerType::Other("literally".to_string())),
"so" => Some(FillerType::Other("so".to_string())),
_ => None,
}
}phonetic_encode function · rust · L133-L157 (25 LOC)src-tauri/src/services/filler_detector.rs
fn phonetic_encode(word: &str) -> String {
let word = word.to_lowercase();
let mut encoded = String::new();
let vowels = ['a', 'e', 'i', 'o', 'u'];
for (i, ch) in word.chars().enumerate() {
if ch.is_alphabetic() {
// Keep first character
if i == 0 {
encoded.push(ch);
} else if !vowels.contains(&ch) {
// Remove vowels for consonant pattern
encoded.push(ch);
}
}
}
// Normalize to 4 characters
while encoded.len() < 4 {
encoded.push('0');
}
encoded.truncate(4);
encoded
}