兼容windows

This commit is contained in:
kura 2026-05-01 12:06:37 +08:00
parent bba78d1dca
commit d8759d56c6
3 changed files with 2319 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -15,6 +15,7 @@ impl AudioPipeline {
let output_path = workspace.join("normalized.wav"); let output_path = workspace.join("normalized.wav");
let mut command = Command::new(ffmpeg_path); let mut command = Command::new(ffmpeg_path);
#[cfg(target_os = "macos")]
if let Some(lib_dir) = ffmpeg_path.parent().and_then(|bin_dir| bin_dir.parent()).map(|root| root.join("lib")) { if let Some(lib_dir) = ffmpeg_path.parent().and_then(|bin_dir| bin_dir.parent()).map(|root| root.join("lib")) {
if lib_dir.exists() { if lib_dir.exists() {
command.env("DYLD_FALLBACK_LIBRARY_PATH", &lib_dir); command.env("DYLD_FALLBACK_LIBRARY_PATH", &lib_dir);

View File

@ -26,6 +26,13 @@ const DEFAULT_VAD_MODEL: &str = "model/silero_vad.onnx";
const DEFAULT_FFMPEG_BINARY: &str = "vendor/ffmpeg/macos-arm64/bin/ffmpeg"; const DEFAULT_FFMPEG_BINARY: &str = "vendor/ffmpeg/macos-arm64/bin/ffmpeg";
#[cfg(all(target_os = "macos", target_arch = "x86_64"))] #[cfg(all(target_os = "macos", target_arch = "x86_64"))]
const DEFAULT_FFMPEG_BINARY: &str = "vendor/ffmpeg/macos-x86_64/bin/ffmpeg"; const DEFAULT_FFMPEG_BINARY: &str = "vendor/ffmpeg/macos-x86_64/bin/ffmpeg";
#[cfg(target_os = "windows")]
const DEFAULT_FFMPEG_BINARY: &str = "vendor/ffmpeg/windows-x86_64/bin/ffmpeg.exe";
#[cfg(not(target_os = "windows"))]
const FFMPEG_BIN_NAME: &str = "ffmpeg";
#[cfg(target_os = "windows")]
const FFMPEG_BIN_NAME: &str = "ffmpeg.exe";
pub async fn start_task( pub async fn start_task(
app: tauri::AppHandle, app: tauri::AppHandle,
@ -128,7 +135,7 @@ fn resolve_ffmpeg_path(app: &tauri::AppHandle) -> Option<PathBuf> {
let path_var = std::env::var_os("PATH")?; let path_var = std::env::var_os("PATH")?;
for directory in std::env::split_paths(&path_var) { for directory in std::env::split_paths(&path_var) {
let candidate = directory.join("ffmpeg"); let candidate = directory.join(FFMPEG_BIN_NAME);
if candidate.exists() { if candidate.exists() {
return Some(candidate); return Some(candidate);
} }