diff --git a/TODO.md b/TODO.md index ad28bf6..f484478 100644 --- a/TODO.md +++ b/TODO.md @@ -1,26 +1,19 @@ - [x] update the project to no more use features -- update last_model to be only used during one run - +- [x] update last_model to be only used during one run - rename project to "PolyScribe" - +- add tests - update local models using hashes (--update-models) - create folder models/ if not present -> use /usr/share/polyscribe/models/ for release version, use ./models/ for development version - create missing folders for output files - - for merging (command line flag) -> if not present, treat each file as separate output (--merge | -m) - for merge + separate output -> if present, treat each file as separate output and also output a merged version (--merge-and-separate) - set speaker-names per input-file -> prompt user for each file if flag is set (--set-speaker-names) - fix cli output for model display - refactor into proper cli app - - add support for video files -> use ffmpeg to extract audio - - detect gpus and use them - add error handling -- add tests - - add verbose flag (--verbose | -v) + add logging - - add documentation - package into executable - add CI diff --git a/src/main.rs b/src/main.rs index 45b12a4..d3bcf0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -334,9 +334,26 @@ fn transcribe_native(audio_path: &Path, speaker: &str, lang_opt: Option<&str>) - Ok(items) } +struct LastModelCleanup { + path: PathBuf, +} +impl Drop for LastModelCleanup { + fn drop(&mut self) { + let _ = std::fs::remove_file(&self.path); + } +} + fn main() -> Result<()> { let args = Args::parse(); + // Remove stale last_model from previous runs and set up cleanup on exit + let models_dir = Path::new("models"); + let last_model_path = models_dir.join(".last_model"); + // Best-effort cleanup at start + let _ = std::fs::remove_file(&last_model_path); + // Ensure cleanup at end of program, regardless of exit path + let _last_model_cleanup = LastModelCleanup { path: last_model_path.clone() }; + // If requested, run the interactive model downloader first. If no inputs were provided, exit after downloading. if args.download_models { if let Err(e) = models::run_interactive_model_downloader() {