Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
421 changes: 421 additions & 0 deletions docs/windows-sherpa-onnx-asr-plan.md

Large diffs are not rendered by default.

75 changes: 68 additions & 7 deletions openless-all/app/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions openless-all/app/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ tauri-plugin-autostart = "2"
tauri-plugin-dialog = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sha2 = "0.10"
bzip2 = "0.4"
tar = "0.4"
tokio = { version = "1", features = ["full"] }
tokio-tungstenite = { version = "0.24", features = ["rustls-tls-native-roots"] }
futures-util = "0.3"
Expand Down Expand Up @@ -81,6 +84,7 @@ libc = "0.2"
[target.'cfg(target_os = "windows")'.dependencies]
foundry-local-sdk = { version = "1.1.0", features = ["winml"] }
raw-window-handle = "0.6"
sherpa-onnx = { version = "1.13.2", default-features = false, features = ["static"] }
windows = { version = "0.58", features = [
"Win32_Foundation",
"Win32_Globalization",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ mod asr {
}
}
}

pub mod sherpa {
pub const DEFAULT_MODEL_ALIAS: &str = "sense-voice-small-zh";
pub const PROVIDER_ID: &str = "sherpa-onnx-local";

pub fn is_sherpa_onnx_local(id: &str) -> bool {
id == PROVIDER_ID
}
}
}
}

Expand Down
22 changes: 22 additions & 0 deletions openless-all/app/src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
fn main() {
#[cfg(target_os = "windows")]
link_windows_common_controls_v6_manifest_dependency();

#[cfg(target_os = "macos")]
build_qwen_asr_macos();

tauri_build::build();
}

#[cfg(target_os = "windows")]
fn link_windows_common_controls_v6_manifest_dependency() {
let mut source_path = std::path::PathBuf::from(
std::env::var_os("OUT_DIR").expect("OUT_DIR must be set by Cargo"),
);
source_path.push("common-controls-v6-manifest-dependency.c");
std::fs::write(
&source_path,
r#"#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
int openless_common_controls_v6_manifest_dependency_anchor = 0;
"#,
)
.expect("write common controls manifest dependency source");
cc::Build::new()
.file(&source_path)
.compile("openless_common_controls_v6_manifest_dependency");
println!("cargo:rustc-link-arg=/INCLUDE:openless_common_controls_v6_manifest_dependency_anchor");
}

/// 编译 vendored Open-Less/qwen-asr 的 C 源(仅 macOS)。
///
/// 上游 Makefile `make blas` 等价配置:BLAS 加速通过 Accelerate framework,
Expand Down
7 changes: 5 additions & 2 deletions openless-all/app/src-tauri/src/asr/local/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl DownloadManager {
}
}

fn build_client() -> Result<reqwest::Client> {
pub(crate) fn build_client() -> Result<reqwest::Client> {
// native-tls (macOS=SecureTransport) 不像 rustls 那样把 CDN unclean close
// 当致命错误。
//
Expand Down Expand Up @@ -476,6 +476,9 @@ const PARALLEL_FILES: usize = 3;
pub fn partial_actual_size(partial: &Path) -> u64 {
let total_size = match std::fs::metadata(partial) {
Ok(m) => m.len(),
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
return 0;
}
Err(e) => {
eprintln!(
"[local-asr] partial_actual_size: stat partial failed ({}): {}",
Expand Down Expand Up @@ -525,7 +528,7 @@ pub fn partial_actual_size(partial: &Path) -> u64 {
total
}

async fn download_one(
pub(crate) async fn download_one(
client: &reqwest::Client,
url: &str,
dest: &Path,
Expand Down
4 changes: 2 additions & 2 deletions openless-all/app/src-tauri/src/asr/local/foundry_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,12 +600,12 @@ if ($readyForFoundryX64) { exit 0 } else { exit 1 }
fn windows_app_runtime_detection_requires_complete_package_set() {
let script = super::windows_app_runtime_detection_script();

assert!(script.contains("Microsoft.WindowsAppRuntime.1.8"));
assert!(script.contains("Microsoft\\.WindowsAppRuntime\\.1\\.8"));
assert!(script.contains("frameworkX86"));
assert!(script.contains("frameworkX64"));
assert!(script.contains("readyForFoundryX64"));
assert!(script.contains("completeX64MachineRuntime"));
assert!(script.contains("Main.1.8"));
assert!(script.contains("Main\\.1\\.8"));
assert!(script.contains("Singleton"));
assert!(script.contains("ddlmX86"));
assert!(script.contains("ddlmX64"));
Expand Down
14 changes: 12 additions & 2 deletions openless-all/app/src-tauri/src/asr/local/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! 本地 ASR 引擎入口。
//!
//! 当前只在 macOS 编入 vendored Open-Less/qwen-asr (纯 C + Accelerate);Windows 端
//! 的本地推理路径见 issue #256,本期不实现。
//! 当前本地引擎:
//! - **macOS**:`antirez/qwen-asr` 纯 C + Accelerate(`local_provider` / `qwen_engine`)
//! - **Windows**:Foundry Local Whisper(`foundry_*`),以及 sherpa-onnx-local
//! 实验 provider(`sherpa*`,M1 仅骨架,详见 `docs/windows-sherpa-onnx-asr-plan.md`)

pub mod cache;
pub mod download;
Expand All @@ -11,13 +13,21 @@ pub mod foundry_provider;
pub mod foundry_runtime;
mod local_provider;
pub mod models;
pub mod sherpa;
pub mod sherpa_download;
pub mod sherpa_provider;
pub mod sherpa_runtime;
pub mod test_run;

pub use cache::LocalAsrCache;
#[allow(unused_imports)]
pub use foundry_provider::FoundryLocalWhisperAsr;
#[allow(unused_imports)]
pub use foundry_runtime::FoundryLocalRuntime;
#[allow(unused_imports)]
pub use sherpa_provider::SherpaOnnxAsr;
#[allow(unused_imports)]
pub use sherpa_runtime::SherpaOnnxRuntime;

#[cfg(target_os = "macos")]
mod qwen_engine;
Expand Down
Loading
Loading