From f991a47b5b25751d78bd171b8c44f419ac77027e Mon Sep 17 00:00:00 2001 From: vikingowl Date: Fri, 8 Aug 2025 09:07:09 +0200 Subject: [PATCH] [refactor] remove feature flags and simplify native whisper integration --- Cargo.toml | 6 +----- TODO.md | 2 +- src/main.rs | 19 ++++--------------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c2d4100..4970a68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,8 +12,4 @@ toml = "0.8" chrono = { version = "0.4", features = ["clock"] } reqwest = { version = "0.12", features = ["blocking", "json"] } sha2 = "0.10" -whisper-rs = { git = "https://github.com/tazz4843/whisper-rs", optional = true } - -[features] -default = ["native-whisper"] -native-whisper = ["whisper-rs"] +whisper-rs = { git = "https://github.com/tazz4843/whisper-rs" } diff --git a/TODO.md b/TODO.md index c87ed08..ad28bf6 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,4 @@ -- 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 - rename project to "PolyScribe" diff --git a/src/main.rs b/src/main.rs index 2febfb6..45b12a4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,6 @@ use clap::Parser; use serde::{Deserialize, Serialize}; use chrono::Local; -#[cfg(feature = "native-whisper")] use whisper_rs::{FullParams, SamplingStrategy, WhisperContext, WhisperContextParameters}; mod models; @@ -138,7 +137,6 @@ fn normalize_lang_code(input: &str) -> Option { -#[cfg(feature = "native-whisper")] fn find_model_file() -> Result { let models_dir = Path::new("models"); if !models_dir.exists() { @@ -245,7 +243,6 @@ fn find_model_file() -> Result { Ok(chosen) } -#[cfg(feature = "native-whisper")] fn decode_audio_to_pcm_f32_ffmpeg(audio_path: &Path) -> Result> { let output = Command::new("ffmpeg") .arg("-i").arg(audio_path) @@ -282,7 +279,6 @@ fn decode_audio_to_pcm_f32_ffmpeg(audio_path: &Path) -> Result> { } } -#[cfg(feature = "native-whisper")] fn transcribe_native(audio_path: &Path, speaker: &str, lang_opt: Option<&str>) -> Result> { let pcm = decode_audio_to_pcm_f32_ffmpeg(audio_path)?; let model = find_model_file()?; @@ -389,18 +385,11 @@ fn main() -> Result<()> { let mut buf = String::new(); if is_audio_file(path) { - #[cfg(feature = "native-whisper")] - { - let items = transcribe_native(path, &speaker, lang_hint.as_deref())?; - for e in items { - entries.push(e); - } - continue; - } - #[cfg(not(feature = "native-whisper"))] - { - return Err(anyhow!("Python transcription has been removed. Please build with --features native-whisper to transcribe audio.")); + let items = transcribe_native(path, &speaker, lang_hint.as_deref())?; + for e in items { + entries.push(e); } + continue; } else if is_json_file(path) { File::open(path) .with_context(|| format!("Failed to open: {}", input_path))?