[feat] ensure cleanup of .last_model
file between and after runs
This commit is contained in:
11
TODO.md
11
TODO.md
@@ -1,26 +1,19 @@
|
|||||||
- [x] update the project to no more use features
|
- [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"
|
- rename project to "PolyScribe"
|
||||||
|
- add tests
|
||||||
- update local models using hashes (--update-models)
|
- 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 folder models/ if not present -> use /usr/share/polyscribe/models/ for release version, use ./models/ for development version
|
||||||
- create missing folders for output files
|
- create missing folders for output files
|
||||||
|
|
||||||
- for merging (command line flag) -> if not present, treat each file as separate output (--merge | -m)
|
- 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)
|
- 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)
|
- set speaker-names per input-file -> prompt user for each file if flag is set (--set-speaker-names)
|
||||||
- fix cli output for model display
|
- fix cli output for model display
|
||||||
- refactor into proper cli app
|
- refactor into proper cli app
|
||||||
|
|
||||||
- add support for video files -> use ffmpeg to extract audio
|
- add support for video files -> use ffmpeg to extract audio
|
||||||
|
|
||||||
- detect gpus and use them
|
- detect gpus and use them
|
||||||
- add error handling
|
- add error handling
|
||||||
- add tests
|
|
||||||
|
|
||||||
- add verbose flag (--verbose | -v) + add logging
|
- add verbose flag (--verbose | -v) + add logging
|
||||||
|
|
||||||
- add documentation
|
- add documentation
|
||||||
- package into executable
|
- package into executable
|
||||||
- add CI
|
- add CI
|
||||||
|
17
src/main.rs
17
src/main.rs
@@ -334,9 +334,26 @@ fn transcribe_native(audio_path: &Path, speaker: &str, lang_opt: Option<&str>) -
|
|||||||
Ok(items)
|
Ok(items)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct LastModelCleanup {
|
||||||
|
path: PathBuf,
|
||||||
|
}
|
||||||
|
impl Drop for LastModelCleanup {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
let _ = std::fs::remove_file(&self.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let args = Args::parse();
|
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 requested, run the interactive model downloader first. If no inputs were provided, exit after downloading.
|
||||||
if args.download_models {
|
if args.download_models {
|
||||||
if let Err(e) = models::run_interactive_model_downloader() {
|
if let Err(e) = models::run_interactive_model_downloader() {
|
||||||
|
Reference in New Issue
Block a user