diff --git a/Cargo.lock b/Cargo.lock index e799a2cd0b..e8442271b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -517,27 +517,21 @@ dependencies = [ "anyhow", "apalis", "apalis-cron", - "async-stream", "async-stripe", "auth-interface", "axum 0.8.4", - "buffer", "bytes", "calendar-google", "calendar-interface", - "calendar-outlook", "chrono", "clerk-rs", - "codes-iso-639", "db-admin", "db-core", "db-user", "dotenv", - "futures-core", "futures-util", "listener-interface", "nango", - "notion", "openai", "s3", "schemars", @@ -557,9 +551,7 @@ dependencies = [ "tracing-axiom", "tracing-subscriber", "turso", - "url", "uuid", - "ws-utils", ] [[package]] @@ -2424,7 +2416,6 @@ dependencies = [ "serde", "thiserror 2.0.12", "tokio", - "tracing", "vad", ] @@ -2572,7 +2563,6 @@ dependencies = [ "serde", "serde_json", "thiserror 2.0.12", - "tokio", "tonic 0.12.3", "tonic-build", "url", @@ -3365,7 +3355,6 @@ dependencies = [ "db-core", "libsql", "listener-interface", - "serde", "serde_json", "tokio", ] @@ -3377,7 +3366,6 @@ dependencies = [ "buffer", "calendar-interface", "chrono", - "codes-iso-639", "data", "db-core", "db-script", @@ -3390,7 +3378,6 @@ dependencies = [ "serde_json", "specta", "strum 0.26.3", - "thiserror 2.0.12", "tokio", "uuid", ] @@ -7823,7 +7810,6 @@ dependencies = [ "encoding_rs", "futures-util", "gbnf", - "gbnf-validator", "gguf", "listener-interface", "llama-cpp-2", @@ -9216,23 +9202,6 @@ dependencies = [ "asn1-rs", ] -[[package]] -name = "ollama-rs" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5df54edb7e1264719be607cd40590d3769b5b35a2623e6e02681e6591aea5b8" -dependencies = [ - "async-stream", - "log", - "reqwest 0.12.15", - "schemars", - "serde", - "serde_json", - "static_assertions", - "thiserror 2.0.12", - "url", -] - [[package]] name = "once_cell" version = "1.21.3" @@ -10366,7 +10335,20 @@ dependencies = [ ] [[package]] -name = "pyannote" +name = "pyannote-cloud" +version = "0.1.0" +dependencies = [ + "data", + "reqwest 0.12.15", + "rodio", + "serde", + "specta", + "tokio", + "url", +] + +[[package]] +name = "pyannote-local" version = "0.1.0" dependencies = [ "anyhow", @@ -10382,7 +10364,6 @@ dependencies = [ "specta", "thiserror 2.0.12", "tokio", - "url", ] [[package]] @@ -11237,18 +11218,9 @@ dependencies = [ name = "rtzr" version = "0.1.0" dependencies = [ - "anyhow", - "bytes", - "futures-util", "prost 0.13.5", - "reqwest 0.12.15", - "serde", - "serde_json", - "thiserror 2.0.12", - "tokio", "tonic 0.12.3", "tonic-build", - "url", ] [[package]] @@ -12950,22 +12922,17 @@ dependencies = [ "audio-utils", "bytes", "clova", - "codes-iso-639", "data", - "db-user", "deepgram", "futures-util", "hound", "language", "listener-interface", - "rtzr", - "serde", "serde_json", "serial_test", - "specta", "thiserror 2.0.12", "tokio", - "whisper", + "whisper-cloud", ] [[package]] @@ -13441,7 +13408,6 @@ version = "0.1.0" dependencies = [ "analytics", "serde", - "serde_json", "specta", "specta-typescript", "strum 0.26.3", @@ -13451,7 +13417,6 @@ dependencies = [ "tauri-plugin-store2", "tauri-specta", "thiserror 2.0.12", - "tracing", ] [[package]] @@ -13465,7 +13430,6 @@ dependencies = [ "chrono", "db-user", "serde", - "serde_json", "specta", "specta-typescript", "tauri", @@ -13486,7 +13450,6 @@ dependencies = [ "base64 0.22.1", "keyring", "minijinja", - "schemars", "serde", "serde_json", "serde_qs 0.14.0", @@ -13551,8 +13514,6 @@ dependencies = [ "tauri-plugin-store2", "tauri-specta", "thiserror 2.0.12", - "tokio", - "tracing", "url", ] @@ -13564,17 +13525,14 @@ dependencies = [ "db-user", "listener-interface", "serde", - "serde_json", "specta", "specta-typescript", - "strum 0.26.3", "tauri", "tauri-plugin", "tauri-specta", "thiserror 2.0.12", "tokio", "tracing", - "turso", "uuid", ] @@ -13621,7 +13579,6 @@ name = "tauri-plugin-flags" version = "0.1.0" dependencies = [ "serde", - "serde_json", "specta", "specta-typescript", "strum 0.26.3", @@ -13630,7 +13587,6 @@ dependencies = [ "tauri-plugin-store2", "tauri-specta", "thiserror 2.0.12", - "tracing", ] [[package]] @@ -13747,7 +13703,6 @@ dependencies = [ "futures-util", "gbnf", "llama", - "ollama-rs", "reqwest 0.12.15", "serde", "serde_json", @@ -13774,7 +13729,6 @@ dependencies = [ "bytes", "chunker", "data", - "db-user", "dirs 6.0.0", "file", "futures-util", @@ -13782,7 +13736,7 @@ dependencies = [ "kalosm-sound", "language", "listener-interface", - "pyannote", + "pyannote-local", "reqwest 0.12.15", "rodio", "serde", @@ -13803,6 +13757,7 @@ dependencies = [ "tower-http 0.6.4", "tracing", "whisper", + "whisper-local", "ws-utils", ] @@ -13849,16 +13804,12 @@ dependencies = [ "host", "indoc", "regex", - "serde", - "serde_json", "specta", "specta-typescript", - "strum 0.26.3", "tauri", "tauri-plugin", "tauri-plugin-opener", "tauri-specta", - "tracing", "vergen-gix", ] @@ -13871,10 +13822,8 @@ dependencies = [ "chrono", "db-user", "detect", - "keygen-rs", "notification2", "serde", - "serde_json", "specta", "specta-typescript", "strum 0.26.3", @@ -14048,13 +13997,11 @@ dependencies = [ "futures-util", "reqwest 0.12.15", "serde", - "serde_json", "specta", "specta-typescript", "tauri", "tauri-plugin", "tauri-specta", - "thiserror 2.0.12", "tokio", "tracing", ] @@ -14097,7 +14044,6 @@ dependencies = [ name = "tauri-plugin-task" version = "0.1.0" dependencies = [ - "chrono", "serde", "serde_json", "specta", @@ -14117,7 +14063,6 @@ name = "tauri-plugin-template" version = "0.1.0" dependencies = [ "insta", - "serde", "serde_json", "specta", "specta-typescript", @@ -14134,7 +14079,6 @@ version = "0.1.0" dependencies = [ "specta", "specta-typescript", - "strum 0.26.3", "tauri", "tauri-plugin", "tauri-plugin-windows", @@ -15245,7 +15189,6 @@ dependencies = [ "cached", "reqwest 0.12.15", "serde", - "serde_json", "thiserror 2.0.12", "tokio", "url", @@ -15639,7 +15582,6 @@ dependencies = [ "ort", "serde", "thiserror 2.0.12", - "tracing", ] [[package]] @@ -16133,10 +16075,36 @@ dependencies = [ [[package]] name = "whisper" version = "0.1.0" +dependencies = [ + "strum 0.26.3", +] + +[[package]] +name = "whisper-cloud" +version = "0.1.0" dependencies = [ "audio-utils", "bytes", - "cpal", + "data", + "dirs 6.0.0", + "futures-util", + "kalosm-sound", + "llama", + "rodio", + "serde", + "serde_json", + "tokio", + "url", + "whisper", + "ws", +] + +[[package]] +name = "whisper-local" +version = "0.1.0" +dependencies = [ + "audio-utils", + "dasp", "data", "dirs 6.0.0", "futures-util", @@ -16147,19 +16115,17 @@ dependencies = [ "rodio", "serde", "serde_json", - "strum 0.26.3", "thiserror 2.0.12", "tokio", "tracing", - "url", + "whisper", "whisper-rs", - "ws", ] [[package]] name = "whisper-rs" -version = "0.14.2" -source = "git+https://github.com/tazz4843/whisper-rs?rev=de30f9c#de30f9c23da52c81b06fa78bab005ab353d74637" +version = "0.14.3" +source = "git+https://github.com/tazz4843/whisper-rs?rev=e3d67d5#e3d67d513b86c6360f62e1f563bc4601c87946d6" dependencies = [ "tracing", "whisper-rs-sys", @@ -16167,8 +16133,8 @@ dependencies = [ [[package]] name = "whisper-rs-sys" -version = "0.12.1" -source = "git+https://github.com/tazz4843/whisper-rs?rev=de30f9c#de30f9c23da52c81b06fa78bab005ab353d74637" +version = "0.13.0" +source = "git+https://github.com/tazz4843/whisper-rs?rev=e3d67d5#e3d67d513b86c6360f62e1f563bc4601c87946d6" dependencies = [ "bindgen 0.71.1", "cfg-if", @@ -16971,7 +16937,6 @@ dependencies = [ "bytes", "futures-util", "serde", - "serde_json", "thiserror 2.0.12", "tokio", "tokio-tungstenite 0.26.2", diff --git a/Cargo.toml b/Cargo.toml index 75a8f55461..159511864c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ hypr-calendar-google = { path = "crates/calendar-google", package = "calendar-go hypr-calendar-interface = { path = "crates/calendar-interface", package = "calendar-interface" } hypr-calendar-outlook = { path = "crates/calendar-outlook", package = "calendar-outlook" } hypr-chunker = { path = "crates/chunker", package = "chunker" } +hypr-clova = { path = "crates/clova", package = "clova" } hypr-data = { path = "crates/data", package = "data" } hypr-db-admin = { path = "crates/db-admin", package = "db-admin" } hypr-db-core = { path = "crates/db-core", package = "db-core" } @@ -50,7 +51,9 @@ hypr-notification2 = { path = "crates/notification2", package = "notification2" hypr-notion = { path = "crates/notion", package = "notion" } hypr-onnx = { path = "crates/onnx", package = "onnx" } hypr-openai = { path = "crates/openai", package = "openai" } -hypr-pyannote = { path = "crates/pyannote", package = "pyannote" } +hypr-pyannote-cloud = { path = "crates/pyannote-cloud", package = "pyannote-cloud" } +hypr-pyannote-local = { path = "crates/pyannote-local", package = "pyannote-local" } +hypr-rtzr = { path = "crates/rtzr", package = "rtzr" } hypr-s3 = { path = "crates/s3", package = "s3" } hypr-slack = { path = "crates/slack", package = "slack" } hypr-stt = { path = "crates/stt", package = "stt", features = ["realtime", "recorded"] } @@ -58,6 +61,8 @@ hypr-template = { path = "crates/template", package = "template" } hypr-turso = { path = "crates/turso", package = "turso" } hypr-vad = { path = "crates/vad", package = "vad" } hypr-whisper = { path = "crates/whisper", package = "whisper" } +hypr-whisper-cloud = { path = "crates/whisper-cloud", package = "whisper-cloud" } +hypr-whisper-local = { path = "crates/whisper-local", package = "whisper-local" } hypr-ws = { path = "crates/ws", package = "ws" } hypr-ws-utils = { path = "crates/ws-utils", package = "ws-utils" } diff --git a/apps/app/server/Cargo.toml b/apps/app/server/Cargo.toml index b2f4e33e0c..ab5150d2f5 100644 --- a/apps/app/server/Cargo.toml +++ b/apps/app/server/Cargo.toml @@ -10,26 +10,19 @@ dotenv = { workspace = true } hypr-auth-interface = { workspace = true } hypr-listener-interface = { workspace = true } +futures-util = { workspace = true } hypr-analytics = { workspace = true } -hypr-buffer = { workspace = true } hypr-calendar-google = { workspace = true } hypr-calendar-interface = { workspace = true } -hypr-calendar-outlook = { workspace = true } hypr-db-admin = { workspace = true } hypr-db-core = { workspace = true } hypr-db-user = { workspace = true } hypr-nango = { workspace = true } -hypr-notion = { workspace = true } hypr-openai = { workspace = true } hypr-s3 = { workspace = true } hypr-slack = { workspace = true } hypr-stt = { workspace = true, features = ["realtime", "recorded"] } hypr-turso = { workspace = true } -hypr-ws-utils = { workspace = true } - -async-stream = { workspace = true } -futures-core = { workspace = true } -futures-util = { workspace = true } tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } axum = { workspace = true, features = ["ws"] } @@ -47,10 +40,8 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } anyhow = { workspace = true } bytes = { workspace = true } chrono = { workspace = true } -codes-iso-639 = { workspace = true } dotenv = { workspace = true } thiserror = { workspace = true } -url = { workspace = true } uuid = { workspace = true } serde = { workspace = true, features = ["derive"] } diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 0d717b1aad..0692ce855b 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -93,3 +93,25 @@ tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } tokio-stream = { workspace = true } hound = { workspace = true } + +[features] +macos-default = ["llm-metal", "stt-metal", "stt-coreml"] +windows-default = ["llm-vulkan", "llm-native", "stt-vulkan", "stt-openblas", "stt-directml"] + +llm-metal = ["tauri-plugin-local-llm/metal"] +llm-cuda = ["tauri-plugin-local-llm/cuda"] +llm-vulkan = ["tauri-plugin-local-llm/vulkan"] +llm-native = ["tauri-plugin-local-llm/native"] + +stt-coreml = ["tauri-plugin-local-stt/coreml"] +stt-directml = ["tauri-plugin-local-stt/directml"] +stt-cuda = ["tauri-plugin-local-stt/cuda"] +stt-hipblas = ["tauri-plugin-local-stt/hipblas"] +stt-openblas = ["tauri-plugin-local-stt/openblas"] +stt-metal = ["tauri-plugin-local-stt/metal"] +stt-vulkan = ["tauri-plugin-local-stt/vulkan"] +stt-openmp = ["tauri-plugin-local-stt/openmp"] + +metal = ["llm-metal", "stt-metal"] +cuda = ["llm-cuda", "stt-cuda"] +vulkan = ["llm-vulkan", "stt-vulkan"] diff --git a/apps/desktop/src-tauri/build.rs b/apps/desktop/src-tauri/build.rs index d860e1e6a7..b4d27bfc2e 100644 --- a/apps/desktop/src-tauri/build.rs +++ b/apps/desktop/src-tauri/build.rs @@ -1,3 +1,15 @@ fn main() { + let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); + + match target_os.as_str() { + "macos" => { + println!("cargo:rustc-cfg=feature=\"macos-default\""); + } + "windows" => { + println!("cargo:rustc-cfg=feature=\"windows-default\""); + } + _ => {} + } + tauri_build::build() } diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs index 2db5cda4c7..15114eabbb 100644 --- a/apps/desktop/src-tauri/src/lib.rs +++ b/apps/desktop/src-tauri/src/lib.rs @@ -87,6 +87,7 @@ pub async fn main() { .plugin(tauri_plugin_auth::init()) .plugin(tauri_plugin_clipboard_manager::init()) .plugin(tauri_plugin_shell::init()) + .plugin(tauri_plugin_task::init()) .plugin(tauri_plugin_http::init()) .plugin(tauri_plugin_machine_uid::init()) .plugin(tauri_plugin_analytics::init()) diff --git a/crates/chunker/Cargo.toml b/crates/chunker/Cargo.toml index a1a222bcac..ea862bc808 100644 --- a/crates/chunker/Cargo.toml +++ b/crates/chunker/Cargo.toml @@ -16,4 +16,3 @@ futures-util = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } -tracing = { workspace = true } diff --git a/crates/clova/Cargo.toml b/crates/clova/Cargo.toml index ca63dee060..db39fe8f0b 100644 --- a/crates/clova/Cargo.toml +++ b/crates/clova/Cargo.toml @@ -18,7 +18,6 @@ serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } futures-util = { workspace = true } -tokio = { workspace = true } prost = { workspace = true } tonic = { workspace = true, features = ["channel", "tls-native-roots"] } diff --git a/crates/db-script/Cargo.toml b/crates/db-script/Cargo.toml index 31297695da..ae74a4a9c5 100644 --- a/crates/db-script/Cargo.toml +++ b/crates/db-script/Cargo.toml @@ -6,8 +6,6 @@ edition = "2021" [dependencies] hypr-listener-interface = { workspace = true } libsql = { workspace = true } - -serde = { workspace = true } serde_json = { workspace = true } [dev-dependencies] diff --git a/crates/db-user/Cargo.toml b/crates/db-user/Cargo.toml index 458d09069c..f678f94e1f 100644 --- a/crates/db-user/Cargo.toml +++ b/crates/db-user/Cargo.toml @@ -23,7 +23,5 @@ schemars = { workspace = true, features = ["chrono"] } specta = { workspace = true, features = ["derive", "chrono", "serde_json"] } chrono = { workspace = true, features = ["serde"] } -codes-iso-639 = { workspace = true } indoc = { workspace = true } -thiserror = { workspace = true } uuid = { workspace = true, features = ["v4", "serde"] } diff --git a/crates/llama/Cargo.toml b/crates/llama/Cargo.toml index eb7ac33c93..5c2153f4e9 100644 --- a/crates/llama/Cargo.toml +++ b/crates/llama/Cargo.toml @@ -3,11 +3,20 @@ name = "llama" version = "0.1.0" edition = "2021" +# https://github.com/utilityai/llama-cpp-rs/blob/update-llama-cpp-2025-05-28/llama-cpp-2/Cargo.toml +[features] +default = [] +metal = ["llama-cpp-2/metal"] +cuda = ["llama-cpp-2/cuda"] +vulkan = ["llama-cpp-2/vulkan"] +native = ["llama-cpp-2/native"] +openmp = ["llama-cpp-2/openmp"] + [dependencies] hypr-gguf = { workspace = true } encoding_rs = "0.8.35" -gbnf-validator = { workspace = true } +llama-cpp-2 = { git = "https://github.com/utilityai/llama-cpp-rs", default-features = false, branch = "update-llama-cpp-2025-05-28" } async-openai = { workspace = true } futures-util = { workspace = true } @@ -18,15 +27,6 @@ tracing = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } -[target.'cfg(not(target_os = "macos"))'.dependencies] -llama-cpp-2 = { git = "https://github.com/utilityai/llama-cpp-rs", default-features = false, features = ["openmp"], branch = "update-llama-cpp-2025-05-28" } - -[target.'cfg(all(target_os = "macos", target_arch = "aarch64"))'.dependencies] -llama-cpp-2 = { git = "https://github.com/utilityai/llama-cpp-rs", features = ["openmp", "metal"], branch = "update-llama-cpp-2025-05-28" } - -[target.'cfg(all(target_os = "macos", target_arch = "x86_64"))'.dependencies] -llama-cpp-2 = { git = "https://github.com/utilityai/llama-cpp-rs", features = ["native"], branch = "update-llama-cpp-2025-05-28" } - [dev-dependencies] hypr-buffer = { workspace = true } hypr-data = { workspace = true } diff --git a/crates/llama/src/lib.rs b/crates/llama/src/lib.rs index 923751e97b..f03d13ca7a 100644 --- a/crates/llama/src/lib.rs +++ b/crates/llama/src/lib.rs @@ -77,7 +77,8 @@ impl Llama { } pub fn new(model_path: impl AsRef) -> Result { - send_logs_to_tracing(LogOptions::default().with_logs_enabled(false)); + let show_logs = if cfg!(debug_assertions) { true } else { false }; + send_logs_to_tracing(LogOptions::default().with_logs_enabled(show_logs)); let fmt = model_path.gguf_chat_format()?.unwrap(); let tpl = LlamaChatTemplate::new(fmt.as_ref()).unwrap(); diff --git a/crates/onnx/Cargo.toml b/crates/onnx/Cargo.toml index 67569689e8..93ab45a3ef 100644 --- a/crates/onnx/Cargo.toml +++ b/crates/onnx/Cargo.toml @@ -3,6 +3,11 @@ name = "onnx" version = "0.1.0" edition = "2021" +[features] +default = [] +coreml = ["ort/coreml"] +directml = ["ort/directml"] + [dependencies] ndarray = "0.16" -ort = "=2.0.0-rc.9" +ort = { version = "=2.0.0-rc.9" } diff --git a/crates/pyannote-cloud/Cargo.toml b/crates/pyannote-cloud/Cargo.toml new file mode 100644 index 0000000000..89e4d602fb --- /dev/null +++ b/crates/pyannote-cloud/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "pyannote-cloud" +version = "0.1.0" +edition = "2021" + +[dependencies] +reqwest = { workspace = true, features = ["json"] } +url = { workspace = true } + +serde = { workspace = true, features = ["derive"] } +specta = { workspace = true, features = ["derive"] } + +[dev-dependencies] +hypr-data = { workspace = true } + +reqwest = { workspace = true, features = ["json"] } +rodio = { workspace = true } +tokio = { workspace = true, features = ["rt", "macros"] } diff --git a/crates/pyannote/src/cloud/get_job.rs b/crates/pyannote-cloud/src/get_job.rs similarity index 100% rename from crates/pyannote/src/cloud/get_job.rs rename to crates/pyannote-cloud/src/get_job.rs diff --git a/crates/pyannote/src/cloud/mod.rs b/crates/pyannote-cloud/src/lib.rs similarity index 100% rename from crates/pyannote/src/cloud/mod.rs rename to crates/pyannote-cloud/src/lib.rs diff --git a/crates/pyannote/src/cloud/submit_diarization_job.rs b/crates/pyannote-cloud/src/submit_diarization_job.rs similarity index 100% rename from crates/pyannote/src/cloud/submit_diarization_job.rs rename to crates/pyannote-cloud/src/submit_diarization_job.rs diff --git a/crates/pyannote/src/cloud/test_key.rs b/crates/pyannote-cloud/src/test_key.rs similarity index 100% rename from crates/pyannote/src/cloud/test_key.rs rename to crates/pyannote-cloud/src/test_key.rs diff --git a/crates/pyannote/Cargo.toml b/crates/pyannote-local/Cargo.toml similarity index 55% rename from crates/pyannote/Cargo.toml rename to crates/pyannote-local/Cargo.toml index 672e454a66..359686fd50 100644 --- a/crates/pyannote/Cargo.toml +++ b/crates/pyannote-local/Cargo.toml @@ -1,21 +1,19 @@ [package] -name = "pyannote" +name = "pyannote-local" version = "0.1.0" edition = "2021" [features] default = [] -cloud = ["dep:reqwest", "dep:url"] -local = ["dep:hypr-onnx", "dep:knf-rs", "dep:simsimd", "dep:dasp"] +coreml = ["hypr-onnx/coreml"] +directml = ["hypr-onnx/directml"] [dependencies] -reqwest = { workspace = true, features = ["json"], optional = true } -url = { workspace = true, optional = true } +hypr-onnx = { workspace = true } -dasp = { workspace = true, optional = true } -hypr-onnx = { workspace = true, optional = true } -knf-rs = { git = "https://github.com/thewh1teagle/pyannote-rs", rev = "d97bd3b", package = "knf-rs", optional = true } -simsimd = { version = "6", optional = true } +dasp = { workspace = true } +knf-rs = { git = "https://github.com/thewh1teagle/pyannote-rs", rev = "d97bd3b", package = "knf-rs" } +simsimd = { version = "6" } anyhow = { workspace = true } thiserror = { workspace = true } diff --git a/crates/pyannote/src/local/data/embedding.onnx b/crates/pyannote-local/src/data/embedding.onnx similarity index 100% rename from crates/pyannote/src/local/data/embedding.onnx rename to crates/pyannote-local/src/data/embedding.onnx diff --git a/crates/pyannote/src/local/data/female_welcome_1.mp3 b/crates/pyannote-local/src/data/female_welcome_1.mp3 similarity index 100% rename from crates/pyannote/src/local/data/female_welcome_1.mp3 rename to crates/pyannote-local/src/data/female_welcome_1.mp3 diff --git a/crates/pyannote/src/local/data/male_welcome_1.mp3 b/crates/pyannote-local/src/data/male_welcome_1.mp3 similarity index 100% rename from crates/pyannote/src/local/data/male_welcome_1.mp3 rename to crates/pyannote-local/src/data/male_welcome_1.mp3 diff --git a/crates/pyannote/src/local/data/male_welcome_2.mp3 b/crates/pyannote-local/src/data/male_welcome_2.mp3 similarity index 100% rename from crates/pyannote/src/local/data/male_welcome_2.mp3 rename to crates/pyannote-local/src/data/male_welcome_2.mp3 diff --git a/crates/pyannote/src/local/data/segmentation.onnx b/crates/pyannote-local/src/data/segmentation.onnx similarity index 100% rename from crates/pyannote/src/local/data/segmentation.onnx rename to crates/pyannote-local/src/data/segmentation.onnx diff --git a/crates/pyannote/src/local/embedding.rs b/crates/pyannote-local/src/embedding.rs similarity index 95% rename from crates/pyannote/src/local/embedding.rs rename to crates/pyannote-local/src/embedding.rs index 44e743fe6f..667a707c60 100644 --- a/crates/pyannote/src/local/embedding.rs +++ b/crates/pyannote-local/src/embedding.rs @@ -1,5 +1,4 @@ -use dasp::sample::{FromSample, Sample, ToSample}; -use simsimd::SpatialSimilarity; +use dasp::sample::ToSample; use hypr_onnx::{ ndarray::{self, Array2}, @@ -40,7 +39,7 @@ impl EmbeddingExtractor { Ok(embeddings) } - pub fn cluster(&self, n_clusters: usize, embeddings: &[f32]) -> Vec { + pub fn cluster(&self, _n_clusters: usize, embeddings: &[f32]) -> Vec { let assignments = vec![0; embeddings.len()]; assignments } @@ -50,6 +49,8 @@ impl EmbeddingExtractor { mod tests { use super::*; + use dasp::sample::{FromSample, Sample}; + fn get_audio>(path: &str) -> Vec { let base = std::path::Path::new(env!("CARGO_MANIFEST_DIR")); let p = base.join("src/local/data").join(path); diff --git a/crates/pyannote/src/local/mod.rs b/crates/pyannote-local/src/lib.rs similarity index 100% rename from crates/pyannote/src/local/mod.rs rename to crates/pyannote-local/src/lib.rs diff --git a/crates/pyannote/src/local/segmentation.rs b/crates/pyannote-local/src/segmentation.rs similarity index 100% rename from crates/pyannote/src/local/segmentation.rs rename to crates/pyannote-local/src/segmentation.rs diff --git a/crates/pyannote/src/lib.rs b/crates/pyannote/src/lib.rs deleted file mode 100644 index bf06af06a7..0000000000 --- a/crates/pyannote/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[cfg(feature = "cloud")] -pub mod cloud; - -#[cfg(feature = "local")] -pub mod local; diff --git a/crates/rtzr/Cargo.toml b/crates/rtzr/Cargo.toml index a4dc214502..c8cdfaf26c 100644 --- a/crates/rtzr/Cargo.toml +++ b/crates/rtzr/Cargo.toml @@ -10,18 +10,5 @@ generate = [] tonic-build = { workspace = true } [dependencies] -anyhow = { workspace = true } -thiserror = { workspace = true } - -bytes = { workspace = true } -serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } - -futures-util = { workspace = true } -tokio = { workspace = true } - prost = { workspace = true } tonic = { workspace = true, features = ["channel", "tls-native-roots"] } - -reqwest = { workspace = true, features = ["multipart", "stream", "json"] } -url = { workspace = true } diff --git a/crates/stt/Cargo.toml b/crates/stt/Cargo.toml index c5f1397898..a877d0c93d 100644 --- a/crates/stt/Cargo.toml +++ b/crates/stt/Cargo.toml @@ -4,19 +4,16 @@ version = "0.1.0" edition = "2021" [features] -default = ["realtime", "recorded", "local"] +default = ["realtime", "recorded"] realtime = [] recorded = [] -local = [] [dependencies] hypr-audio-utils = { workspace = true } -hypr-clova = { path = "../clova", package = "clova" } -hypr-db-user = { workspace = true } +hypr-clova = { workspace = true } hypr-language = { workspace = true, features = ["deepgram", "whisper"] } hypr-listener-interface = { workspace = true } -hypr-rtzr = { path = "../rtzr", package = "rtzr" } -hypr-whisper = { workspace = true, features = ["cloud"] } +hypr-whisper-cloud = { workspace = true } deepgram = { workspace = true, default-features = false, features = ["listen"] } @@ -24,18 +21,14 @@ anyhow = { workspace = true } thiserror = { workspace = true } bytes = { workspace = true } -codes-iso-639 = { workspace = true } - -serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } -specta = { workspace = true, features = ["derive"] } futures-util = { workspace = true } tokio = { workspace = true } [dev-dependencies] -hypr-audio = { path = "../audio", package = "audio" } -hypr-data = { path = "../data", package = "data" } +hypr-audio = { workspace = true } +hypr-data = { workspace = true } async-stream = { workspace = true } hound = { workspace = true } diff --git a/crates/stt/src/realtime/mod.rs b/crates/stt/src/realtime/mod.rs index 265011783f..eb5c0ae694 100644 --- a/crates/stt/src/realtime/mod.rs +++ b/crates/stt/src/realtime/mod.rs @@ -54,7 +54,7 @@ impl ClientBuilder { pub enum MultiClient { Clova(hypr_clova::realtime::Client), Deepgram(DeepgramClient), - Whisper(hypr_whisper::cloud::WhisperClient), + Whisper(hypr_whisper_cloud::WhisperClient), } #[derive(Debug, Clone)] @@ -80,7 +80,7 @@ impl Client { MultiClient::Clova(clova) } hypr_language::ISO639::De => { - let whisper = hypr_whisper::cloud::WhisperClient::builder() + let whisper = hypr_whisper_cloud::WhisperClient::builder() .api_base(std::env::var("WHISPER_API_BASE").unwrap()) .api_key(std::env::var("WHISPER_API_KEY").unwrap()) .language(language.try_into().unwrap()) diff --git a/crates/stt/src/realtime/whisper.rs b/crates/stt/src/realtime/whisper.rs index bd88a14786..81ab81e365 100644 --- a/crates/stt/src/realtime/whisper.rs +++ b/crates/stt/src/realtime/whisper.rs @@ -2,7 +2,7 @@ use bytes::Bytes; use futures_util::{Stream, StreamExt}; use std::error::Error; -use hypr_whisper::cloud::WhisperClient; +use hypr_whisper_cloud::WhisperClient; use super::RealtimeSpeechToText; use hypr_listener_interface::{ListenOutputChunk, Word}; diff --git a/crates/turso/Cargo.toml b/crates/turso/Cargo.toml index d18bcbb2c9..c577420e3d 100644 --- a/crates/turso/Cargo.toml +++ b/crates/turso/Cargo.toml @@ -7,7 +7,6 @@ edition = "2021" cached = { workspace = true } reqwest = { workspace = true, features = ["json"] } serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } thiserror = { workspace = true } url = { workspace = true } diff --git a/crates/vad/Cargo.toml b/crates/vad/Cargo.toml index 2fb621fc37..c29ace3691 100644 --- a/crates/vad/Cargo.toml +++ b/crates/vad/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [dependencies] serde = { workspace = true } thiserror = { workspace = true } -tracing = { workspace = true } ndarray = "0.16" ort = "=2.0.0-rc.9" diff --git a/crates/whisper-cloud/Cargo.toml b/crates/whisper-cloud/Cargo.toml new file mode 100644 index 0000000000..5f179b90d1 --- /dev/null +++ b/crates/whisper-cloud/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "whisper-cloud" +version = "0.1.0" +edition = "2021" + +[dev-dependencies] +hypr-data = { workspace = true } +hypr-llama = { workspace = true } + +dirs = { workspace = true } +futures-util = { workspace = true } +tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } + +[dependencies] +hypr-audio-utils = { workspace = true } +hypr-whisper = { workspace = true } +hypr-ws = { workspace = true } + +bytes = { workspace = true } +futures-util = { workspace = true } +kalosm-sound = { workspace = true, default-features = false } +rodio = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +url = { workspace = true } diff --git a/crates/whisper/src/cloud/client.rs b/crates/whisper-cloud/src/client.rs similarity index 95% rename from crates/whisper/src/cloud/client.rs rename to crates/whisper-cloud/src/client.rs index 5af582bf0f..7e4105edb4 100644 --- a/crates/whisper/src/cloud/client.rs +++ b/crates/whisper-cloud/src/client.rs @@ -2,6 +2,7 @@ use futures_util::Stream; use kalosm_sound::AsyncSource; use hypr_audio_utils::AudioFormatExt; +use hypr_whisper::Language; use hypr_ws::client::{ClientRequestBuilder, Message, WebSocketClient, WebSocketIO}; use super::WhisperOutput; @@ -10,7 +11,7 @@ use super::WhisperOutput; pub struct WhisperClientBuilder { api_base: Option, api_key: Option, - language: Option, + language: Option, } #[derive(Debug, Clone)] @@ -29,7 +30,7 @@ impl WhisperClientBuilder { self } - pub fn language(mut self, language: crate::Language) -> Self { + pub fn language(mut self, language: Language) -> Self { self.language = Some(language); self } diff --git a/crates/whisper/src/cloud/mod.rs b/crates/whisper-cloud/src/lib.rs similarity index 100% rename from crates/whisper/src/cloud/mod.rs rename to crates/whisper-cloud/src/lib.rs diff --git a/crates/whisper/src/cloud/types.rs b/crates/whisper-cloud/src/types.rs similarity index 100% rename from crates/whisper/src/cloud/types.rs rename to crates/whisper-cloud/src/types.rs diff --git a/crates/whisper-local/Cargo.toml b/crates/whisper-local/Cargo.toml new file mode 100644 index 0000000000..4c6625243d --- /dev/null +++ b/crates/whisper-local/Cargo.toml @@ -0,0 +1,42 @@ +[package] +name = "whisper-local" +version = "0.1.0" +edition = "2021" + +# https://github.com/tazz4843/whisper-rs/blob/e3d67d5/Cargo.toml +[features] +default = [] +coreml = ["whisper-rs/coreml"] +cuda = ["whisper-rs/cuda"] +hipblas = ["whisper-rs/hipblas"] +openblas = ["whisper-rs/openblas"] +metal = ["whisper-rs/metal"] +vulkan = ["whisper-rs/vulkan"] +openmp = ["whisper-rs/openmp"] + +[dev-dependencies] +hypr-data = { workspace = true } +hypr-llama = { workspace = true } + +dirs = { workspace = true } +futures-util = { workspace = true } +tokio = { workspace = true } + +[dependencies] +hypr-audio-utils = { workspace = true } +hypr-whisper = { workspace = true } + +dasp = { workspace = true } +kalosm-sound = { workspace = true, default-features = false } +rodio = { workspace = true } +whisper-rs = { git = "https://github.com/tazz4843/whisper-rs", rev = "e3d67d5", features = ["raw-api", "tracing_backend"] } + +futures-util = { workspace = true } +tracing = { workspace = true } + +serde = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } + +lazy_static = { workspace = true } +regex = { workspace = true } diff --git a/crates/whisper/src/local/error.rs b/crates/whisper-local/src/error.rs similarity index 100% rename from crates/whisper/src/local/error.rs rename to crates/whisper-local/src/error.rs diff --git a/crates/whisper/src/local/mod.rs b/crates/whisper-local/src/lib.rs similarity index 100% rename from crates/whisper/src/local/mod.rs rename to crates/whisper-local/src/lib.rs diff --git a/crates/whisper/src/local/model.rs b/crates/whisper-local/src/model.rs similarity index 95% rename from crates/whisper/src/local/model.rs rename to crates/whisper-local/src/model.rs index 88782f1518..22c5cd529a 100644 --- a/crates/whisper/src/local/model.rs +++ b/crates/whisper-local/src/model.rs @@ -8,6 +8,8 @@ use whisper_rs::{ WhisperToken, }; +use hypr_whisper::Language; + lazy_static! { static ref TRAILING_DOTS: Regex = Regex::new(r"\.{2,}$").unwrap(); } @@ -15,7 +17,7 @@ lazy_static! { #[derive(Default)] pub struct WhisperBuilder { model_path: Option, - language: Option, + language: Option, static_prompt: Option, dynamic_prompt: Option, } @@ -26,7 +28,7 @@ impl WhisperBuilder { self } - pub fn language(mut self, language: crate::Language) -> Self { + pub fn language(mut self, language: Language) -> Self { self.language = Some(language); self } @@ -42,10 +44,15 @@ impl WhisperBuilder { } pub fn build(self) -> Whisper { - unsafe { Self::suppress_log() }; + if !cfg!(debug_assertions) { + unsafe { Self::suppress_log() }; + } let context_param = { let mut p = WhisperContextParameters::default(); + p.gpu_device = 0; + p.use_gpu = true; + p.flash_attn = false; // crash on macos p.dtw_parameters.mode = whisper_rs::DtwMode::None; p }; @@ -57,7 +64,7 @@ impl WhisperBuilder { let token_eot = ctx.token_eot(); let token_beg = ctx.token_beg(); - let language = self.language.unwrap_or(crate::Language::En); + let language = self.language.unwrap_or(Language::En); Whisper { language, @@ -81,7 +88,7 @@ impl WhisperBuilder { } pub struct Whisper { - language: crate::Language, + language: Language, static_prompt: String, dynamic_prompt: String, state: WhisperState, diff --git a/crates/whisper/src/local/stream.rs b/crates/whisper-local/src/stream.rs similarity index 98% rename from crates/whisper/src/local/stream.rs rename to crates/whisper-local/src/stream.rs index 65ecb00239..3b11094607 100644 --- a/crates/whisper/src/local/stream.rs +++ b/crates/whisper-local/src/stream.rs @@ -3,7 +3,7 @@ use std::{ task::{Context, Poll}, }; -use cpal::FromSample; +use dasp::sample::FromSample; use futures_util::{Stream, StreamExt}; use rodio::Source; diff --git a/crates/whisper/Cargo.toml b/crates/whisper/Cargo.toml index a0f509c3ae..cf944162b4 100644 --- a/crates/whisper/Cargo.toml +++ b/crates/whisper/Cargo.toml @@ -3,43 +3,5 @@ name = "whisper" version = "0.1.0" edition = "2021" -[features] -default = [] -local = ["whisper-rs", "lazy_static", "regex"] -cloud = [] - -[dev-dependencies] -hypr-data = { workspace = true } -hypr-llama = { workspace = true } - -dirs = { workspace = true } -futures-util = { workspace = true } -tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } - [dependencies] -hypr-audio-utils = { workspace = true } -hypr-ws = { workspace = true } - -bytes = { workspace = true } -cpal = { workspace = true } -futures-util = { workspace = true } -kalosm-sound = { workspace = true, default-features = false } -rodio = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } strum = { workspace = true, features = ["derive"] } -thiserror = { workspace = true } -tracing = { workspace = true } -url = { workspace = true } - -lazy_static = { workspace = true, optional = true } -regex = { workspace = true, optional = true } - -[target.'cfg(not(target_os = "macos"))'.dependencies] -whisper-rs = { git = "https://github.com/tazz4843/whisper-rs", rev = "de30f9c", features = ["raw-api", "tracing_backend"], optional = true } - -[target.'cfg(all(target_os = "macos", target_arch = "aarch64"))'.dependencies] -whisper-rs = { git = "https://github.com/tazz4843/whisper-rs", rev = "de30f9c", features = ["raw-api", "metal", "tracing_backend"], optional = true } - -[target.'cfg(all(target_os = "macos", target_arch = "x86_64"))'.dependencies] -whisper-rs = { git = "https://github.com/tazz4843/whisper-rs", rev = "de30f9c", features = ["raw-api", "tracing_backend"], optional = true } diff --git a/crates/whisper/src/lib.rs b/crates/whisper/src/lib.rs index 4779baffc1..7e144329ac 100644 --- a/crates/whisper/src/lib.rs +++ b/crates/whisper/src/lib.rs @@ -1,9 +1,3 @@ -#[cfg(feature = "local")] -pub mod local; - -#[cfg(feature = "cloud")] -pub mod cloud; - // https://github.com/openai/whisper/blob/ba3f3cd/whisper/tokenizer.py#L10-L128 #[derive(strum::EnumString, strum::Display, strum::AsRefStr)] pub enum Language { diff --git a/crates/ws/Cargo.toml b/crates/ws/Cargo.toml index 6cc559af7e..dec5683c82 100644 --- a/crates/ws/Cargo.toml +++ b/crates/ws/Cargo.toml @@ -11,7 +11,6 @@ server = [] [dependencies] bytes = { workspace = true } serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } thiserror = { workspace = true } async-stream = { workspace = true } diff --git a/plugins/analytics/Cargo.toml b/plugins/analytics/Cargo.toml index c2c2368e64..0a17505b43 100644 --- a/plugins/analytics/Cargo.toml +++ b/plugins/analytics/Cargo.toml @@ -23,9 +23,7 @@ tauri = { workspace = true, features = ["test"] } tauri-specta = { workspace = true, features = ["derive", "typescript"] } serde = { workspace = true } -serde_json = { workspace = true } specta = { workspace = true } strum = { workspace = true, features = ["derive"] } thiserror = { workspace = true } -tracing = { workspace = true } diff --git a/plugins/apple-calendar/Cargo.toml b/plugins/apple-calendar/Cargo.toml index 1115577527..44dff5ef0c 100644 --- a/plugins/apple-calendar/Cargo.toml +++ b/plugins/apple-calendar/Cargo.toml @@ -24,7 +24,6 @@ tauri = { workspace = true, features = ["test"] } tauri-specta = { workspace = true, features = ["derive", "typescript"] } serde = { workspace = true } -serde_json = { workspace = true } specta = { workspace = true } chrono = { workspace = true } diff --git a/plugins/auth/Cargo.toml b/plugins/auth/Cargo.toml index 124fbbccb2..e01dab688d 100644 --- a/plugins/auth/Cargo.toml +++ b/plugins/auth/Cargo.toml @@ -23,8 +23,6 @@ tauri-specta = { workspace = true, features = ["derive", "typescript"] } keyring = { version = "3", features = ["apple-native", "windows-native", "sync-secret-service"] } minijinja = { workspace = true } - -schemars = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } serde_qs = { workspace = true } diff --git a/plugins/connector/Cargo.toml b/plugins/connector/Cargo.toml index 590f78cddc..62b804e8a9 100644 --- a/plugins/connector/Cargo.toml +++ b/plugins/connector/Cargo.toml @@ -29,6 +29,4 @@ serde_json = { workspace = true } specta = { workspace = true } strum = { workspace = true, features = ["derive"] } thiserror = { workspace = true } -tokio = { workspace = true } -tracing = { workspace = true } url = { workspace = true } diff --git a/plugins/db/Cargo.toml b/plugins/db/Cargo.toml index edec33fea9..20da6cf518 100644 --- a/plugins/db/Cargo.toml +++ b/plugins/db/Cargo.toml @@ -17,15 +17,12 @@ specta-typescript = { workspace = true } hypr-db-core = { workspace = true } hypr-db-user = { workspace = true } hypr-listener-interface = { workspace = true } -hypr-turso = { workspace = true } specta = { workspace = true } tauri = { workspace = true, features = ["test"] } tauri-specta = { workspace = true, features = ["derive", "typescript"] } serde = { workspace = true } -serde_json = { workspace = true } -strum = { workspace = true, features = ["derive"] } thiserror = { workspace = true } uuid = { workspace = true } diff --git a/plugins/flags/Cargo.toml b/plugins/flags/Cargo.toml index 78a84ba6f2..f2cd7f4f99 100644 --- a/plugins/flags/Cargo.toml +++ b/plugins/flags/Cargo.toml @@ -19,9 +19,7 @@ tauri-plugin-store2 = { workspace = true } tauri-specta = { workspace = true, features = ["derive", "typescript"] } serde = { workspace = true } -serde_json = { workspace = true } specta = { workspace = true } strum = { workspace = true, features = ["derive"] } thiserror = { workspace = true } -tracing = { workspace = true } diff --git a/plugins/local-llm/Cargo.toml b/plugins/local-llm/Cargo.toml index abd50422db..7664899035 100644 --- a/plugins/local-llm/Cargo.toml +++ b/plugins/local-llm/Cargo.toml @@ -7,6 +7,13 @@ exclude = ["/js", "/node_modules"] links = "tauri-plugin-local-llm" description = "" +[features] +default = [] +metal = ["hypr-llama/metal"] +cuda = ["hypr-llama/cuda"] +vulkan = ["hypr-llama/vulkan"] +native = ["hypr-llama/native"] + [build-dependencies] tauri-plugin = { workspace = true, features = ["build"] } @@ -40,5 +47,3 @@ futures-util = { workspace = true } reqwest = { workspace = true, features = ["stream"] } tokio = { workspace = true, features = ["rt", "macros"] } tower-http = { workspace = true, features = ["cors", "trace"] } - -ollama-rs = "0.2.6" diff --git a/plugins/local-stt/Cargo.toml b/plugins/local-stt/Cargo.toml index 0cea955de7..30b70d73be 100644 --- a/plugins/local-stt/Cargo.toml +++ b/plugins/local-stt/Cargo.toml @@ -7,6 +7,17 @@ exclude = ["/js", "/node_modules"] links = "tauri-plugin-local-stt" description = "" +[features] +default = [] +coreml = ["hypr-whisper-local/coreml", "hypr-pyannote-local/coreml"] +directml = ["hypr-pyannote-local/directml"] +cuda = ["hypr-whisper-local/cuda"] +hipblas = ["hypr-whisper-local/hipblas"] +openblas = ["hypr-whisper-local/openblas"] +metal = ["hypr-whisper-local/metal"] +vulkan = ["hypr-whisper-local/vulkan"] +openmp = ["hypr-whisper-local/openmp"] + [build-dependencies] tauri-plugin = { workspace = true, features = ["build"] } @@ -26,11 +37,11 @@ tracing = { workspace = true } [dependencies] hypr-audio-utils = { workspace = true } hypr-chunker = { workspace = true } -hypr-db-user = { workspace = true } hypr-file = { workspace = true } hypr-listener-interface = { workspace = true } -hypr-pyannote = { workspace = true, features = ["local"] } -hypr-whisper = { workspace = true, features = ["local"] } +hypr-pyannote-local = { workspace = true } +hypr-whisper = { workspace = true } +hypr-whisper-local = { workspace = true } hypr-ws-utils = { workspace = true } tauri = { workspace = true, features = ["test"] } diff --git a/plugins/local-stt/src/ext.rs b/plugins/local-stt/src/ext.rs index c714b44d76..7e91b20e8e 100644 --- a/plugins/local-stt/src/ext.rs +++ b/plugins/local-stt/src/ext.rs @@ -179,14 +179,14 @@ impl> LocalSttPluginExt for T { let samples_i16 = hypr_audio_utils::f32_to_i16_samples(&samples_f32); - let mut model = hypr_whisper::local::Whisper::builder() + let mut model = hypr_whisper_local::Whisper::builder() .model_path(model_path.as_ref().to_str().unwrap()) .language(hypr_whisper::Language::En) .static_prompt("") .dynamic_prompt("") .build(); - let mut segmenter = hypr_pyannote::local::segmentation::Segmenter::new(16000).unwrap(); + let mut segmenter = hypr_pyannote_local::segmentation::Segmenter::new(16000).unwrap(); let segments = segmenter.process(&samples_i16, 16000).unwrap(); let mut words = Vec::new(); diff --git a/plugins/local-stt/src/server.rs b/plugins/local-stt/src/server.rs index e4034d5cca..bf54a90d0f 100644 --- a/plugins/local-stt/src/server.rs +++ b/plugins/local-stt/src/server.rs @@ -130,7 +130,7 @@ async fn websocket_with_model( hypr_whisper::Language::En }); - let model = hypr_whisper::local::Whisper::builder() + let model = hypr_whisper_local::Whisper::builder() .model_path(model_path.to_str().unwrap()) .language(language) .static_prompt(¶ms.static_prompt) @@ -141,13 +141,13 @@ async fn websocket_with_model( } #[tracing::instrument(skip_all)] -async fn websocket(socket: WebSocket, model: hypr_whisper::local::Whisper, guard: ConnectionGuard) { +async fn websocket(socket: WebSocket, model: hypr_whisper_local::Whisper, guard: ConnectionGuard) { let (mut ws_sender, ws_receiver) = socket.split(); let mut stream = { let audio_source = WebSocketAudioSource::new(ws_receiver, 16 * 1000); let chunked = audio_source.chunks(hypr_chunker::RMS::new(), std::time::Duration::from_secs(15)); - hypr_whisper::local::TranscribeChunkedAudioStreamExt::transcribe(chunked, model) + hypr_whisper_local::TranscribeChunkedAudioStreamExt::transcribe(chunked, model) }; loop { diff --git a/plugins/misc/Cargo.toml b/plugins/misc/Cargo.toml index 60277a8737..6a455ec0a9 100644 --- a/plugins/misc/Cargo.toml +++ b/plugins/misc/Cargo.toml @@ -24,10 +24,5 @@ tauri = { workspace = true, features = ["test"] } tauri-plugin-opener = { workspace = true } tauri-specta = { workspace = true, features = ["derive", "typescript"] } -tracing = { workspace = true } - regex = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } specta = { workspace = true } -strum = { workspace = true, features = ["derive"] } diff --git a/plugins/notification/Cargo.toml b/plugins/notification/Cargo.toml index bddf981d6f..bbe41a200c 100644 --- a/plugins/notification/Cargo.toml +++ b/plugins/notification/Cargo.toml @@ -23,7 +23,6 @@ tauri-plugin-db = { workspace = true } tauri-plugin-store2 = { workspace = true } serde = { workspace = true } -serde_json = { workspace = true } specta = { workspace = true } strum = { workspace = true, features = ["derive"] } thiserror = { workspace = true } @@ -37,5 +36,3 @@ tauri-specta = { workspace = true, features = ["derive", "typescript"] } apalis = { workspace = true } apalis-cron = { workspace = true } chrono = { workspace = true } - -keygen-rs = { version = "0.4.3", default-features = false, features = ["native-tls"] } diff --git a/plugins/sse/Cargo.toml b/plugins/sse/Cargo.toml index 964a6faf8f..a63cb2fdee 100644 --- a/plugins/sse/Cargo.toml +++ b/plugins/sse/Cargo.toml @@ -25,5 +25,3 @@ reqwest = { workspace = true, features = ["stream"] } tracing = { workspace = true } serde = { workspace = true } -serde_json = { workspace = true } -thiserror = { workspace = true } diff --git a/plugins/task/Cargo.toml b/plugins/task/Cargo.toml index e3041cb9ae..47de0b3222 100644 --- a/plugins/task/Cargo.toml +++ b/plugins/task/Cargo.toml @@ -19,7 +19,6 @@ tauri = { workspace = true, features = ["test"] } tauri-plugin-store2 = { workspace = true } tauri-specta = { workspace = true, features = ["derive", "typescript"] } -chrono = { workspace = true, features = ["serde"] } serde = { workspace = true } serde_json = { workspace = true } specta = { workspace = true } diff --git a/plugins/template/Cargo.toml b/plugins/template/Cargo.toml index 07a2d8a259..d2eecac4cc 100644 --- a/plugins/template/Cargo.toml +++ b/plugins/template/Cargo.toml @@ -16,8 +16,6 @@ specta-typescript = { workspace = true } [dependencies] hypr-template = { workspace = true } - -serde = { workspace = true } serde_json = { workspace = true } tracing = { workspace = true } diff --git a/plugins/tray/Cargo.toml b/plugins/tray/Cargo.toml index 4e3c98261e..81e8841184 100644 --- a/plugins/tray/Cargo.toml +++ b/plugins/tray/Cargo.toml @@ -18,5 +18,4 @@ tauri = { workspace = true, features = ["tray-icon", "image-png"] } tauri-plugin-windows = { workspace = true } specta = { workspace = true } -strum = { workspace = true, features = ["derive"] } tauri-specta = { workspace = true, features = ["derive", "typescript"] } diff --git a/scripts/pre_build.py b/scripts/pre_build.py new file mode 100755 index 0000000000..ca1f55e888 --- /dev/null +++ b/scripts/pre_build.py @@ -0,0 +1,190 @@ +#!/usr/bin/env python3 + +# https://github.com/thewh1teagle/vibe/blob/9ffde8a/scripts/pre_build.js + +import os +import sys +import json +import subprocess +import urllib.request +import shutil +import platform +from pathlib import Path + +# BLAS +# https://github.com/utilityai/llama-cpp-rs/blob/2f433cd/llama-cpp-sys-2/build.rs#L279-L281 + +# OPENMP +# Can cause `the code execution cannot proceed because VCOMP140.DLL was not found` error on Windows + + +CONFIG = { + "openblas_realname": "openblas", + "vulkan_runtime_real_name": "vulkan_runtime", + "vulkan_sdk_real_name": "vulkan_sdk", + "windows": { + "openblas_name": "OpenBLAS-0.3.26-x64", + "openblas_url": "https://github.com/OpenMathLib/OpenBLAS/releases/download/v0.3.26/OpenBLAS-0.3.26-x64.zip", + "vulkan_runtime_name": "VulkanRT-1.3.290.0-Components", + "vulkan_runtime_url": "https://sdk.lunarg.com/sdk/download/1.3.290.0/windows/VulkanRT-1.3.290.0-Components.zip", + "vulkan_sdk_name": "VulkanSDK-1.3.290.0-Installer", + "vulkan_sdk_url": "https://sdk.lunarg.com/sdk/download/1.3.290.0/windows/VulkanSDK-1.3.290.0-Installer.exe", + "vcpkg_packages": [], + }, +} + + +script_dir = Path(__file__).parent +tauri_dir = script_dir.parent / "apps" / "desktop" / "src-tauri" +os.chdir(tauri_dir) + + +cwd = Path.cwd() + + +def is_windows(): + return platform.system() == "Windows" + + +def is_linux(): + return platform.system() == "Linux" + + +def is_macos(): + return platform.system() == "Darwin" + + +def has_feature(name: str) -> bool: + return f"--{name}" in sys.argv or name in sys.argv + + +def run_command(cmd: str, quiet: bool = False) -> subprocess.CompletedProcess: + try: + result = subprocess.run( + cmd, shell=True, capture_output=quiet, text=True, check=False + ) + + if result.returncode != 0 and not quiet: + print(f"Command failed: {cmd}") + if result.stderr: + print(f"Error: {result.stderr}") + + return result + except Exception as e: + print(f"Error running command '{cmd}': {e}") + raise + + +def wget(url: str, file_path: str): + """Download a file using urllib""" + try: + print(f"Downloading: {file_path}") + urllib.request.urlretrieve(url, file_path) + print(f"Downloaded: {file_path}") + except Exception as e: + raise Exception(f"Failed to download {url}: {e}") + + +def setup_windows(): + openblas_path = cwd / CONFIG["openblas_realname"] + if not openblas_path.exists() and has_feature("openblas"): + openblas_archive = f"{CONFIG['windows']['openblas_name']}.zip" + wget(CONFIG["windows"]["openblas_url"], openblas_archive) + run_command( + f'"C:\\Program Files\\7-Zip\\7z.exe" x {openblas_archive} -o{CONFIG["openblas_realname"]}' + ) + os.remove(openblas_archive) + + # Copy include to lib + include_src = openblas_path / "include" + lib_dst = openblas_path / "lib" + if include_src.exists(): + shutil.copytree(str(include_src), str(lib_dst), dirs_exist_ok=True) + + # Copy libopenblas.lib to openblas.lib + libopenblas = lib_dst / "libopenblas.lib" + openblas_lib = lib_dst / "openblas.lib" + if libopenblas.exists(): + shutil.copy2(str(libopenblas), str(openblas_lib)) + + # Setup Vulkan + vulkan_sdk_path = cwd / CONFIG["vulkan_sdk_real_name"] + if not vulkan_sdk_path.exists() and has_feature("vulkan"): + # Download and install Vulkan SDK + vulkan_sdk_exe = f"{CONFIG['windows']['vulkan_sdk_name']}.exe" + wget(CONFIG["windows"]["vulkan_sdk_url"], vulkan_sdk_exe) + + executable = cwd / vulkan_sdk_exe + vulkan_sdk_root = cwd / CONFIG["vulkan_sdk_real_name"] + run_command( + f'{executable} --root "{vulkan_sdk_root}" --accept-licenses --default-answer --confirm-command install copy_only=1' + ) + + # Download and extract Vulkan Runtime + vulkan_runtime_archive = f"{CONFIG['windows']['vulkan_runtime_name']}.zip" + wget(CONFIG["windows"]["vulkan_runtime_url"], vulkan_runtime_archive) + run_command(f'"C:\\Program Files\\7-Zip\\7z.exe" x {vulkan_runtime_archive}') + shutil.move( + CONFIG["windows"]["vulkan_runtime_name"], CONFIG["vulkan_runtime_real_name"] + ) + + # Cleanup + os.remove(vulkan_sdk_exe) + os.remove(vulkan_runtime_archive) + + # Setup vcpkg packages + if CONFIG["windows"]["vcpkg_packages"]: + packages = " ".join(CONFIG["windows"]["vcpkg_packages"]) + run_command(f"C:\\vcpkg\\vcpkg.exe install {packages}", quiet=True) + + +def setup_openblas(): + if not has_feature("openblas"): + return + + if is_windows(): + config_file = cwd / "tauri.windows.conf.json" + if config_file.exists(): + with open(config_file, "r") as f: + tauri_config = json.load(f) + + resources = tauri_config.setdefault("bundle", {}).setdefault( + "resources", {} + ) + resources["openblas\\bin\\*.dll"] = "./" + + with open(config_file, "w") as f: + json.dump(tauri_config, f, indent=4) + + +def setup_vulkan(): + if not has_feature("vulkan"): + return + + vulkan_path = cwd / CONFIG["vulkan_sdk_real_name"] + vulkan_runtime_path = cwd / CONFIG["vulkan_runtime_real_name"] + + if is_windows(): + config_file = cwd / "tauri.windows.conf.json" + if config_file.exists(): + with open(config_file, "r") as f: + tauri_config = json.load(f) + + resources = tauri_config.setdefault("bundle", {}).setdefault( + "resources", {} + ) + resources["vulkan_runtime\\x64\\*.dll"] = "./" + + with open(config_file, "w") as f: + json.dump(tauri_config, f, indent=4) + + +def main(): + if is_windows(): + setup_windows() + setup_vulkan() + + +if __name__ == "__main__": + # main() + print(tauri_dir)