Skip to content

Commit 61d1105

Browse files
committed
Fix whisper-local compilation issues after removing whisper-rs dependency
- Fix raw_cpuid API usage for CPU AVX detection - Replace whisper_rs error types with generic WhisperError - Create stub implementation for Whisper model functionality - Remove whisper-rs dependencies from Cargo.lock - Maintain API compatibility while removing problematic dependencies
1 parent a4a8bc3 commit 61d1105

File tree

6 files changed

+60
-305
lines changed

6 files changed

+60
-305
lines changed

.claude/settings.local.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"allow": [
44
"Bash(pwsh:*)",
55
"WebFetch(domain:github.com)",
6-
"WebSearch"
6+
"WebSearch",
7+
"Bash(cmd /c:*)"
78
],
89
"deny": [],
910
"ask": []

Cargo.lock

Lines changed: 1 addition & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build_with_dlls.ps1

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# PowerShell script to build with pre-built DLLs
2+
$ErrorActionPreference = "Stop"
3+
4+
# Get the current directory
5+
$currentDir = Get-Location
6+
$dllDir = Join-Path $currentDir "apps\desktop\src-tauri\dlls"
7+
8+
Write-Host "Setting up environment for pre-built DLLs..." -ForegroundColor Green
9+
Write-Host "DLL Directory: $dllDir" -ForegroundColor Cyan
10+
11+
# Set environment variables for whisper-rs to use pre-built libraries
12+
$env:WHISPER_DONT_GENERATE_BINDINGS = "1"
13+
$env:CARGO_TARGET_DIR = "D:\temp\cargo-target"
14+
15+
# Set library paths for Windows
16+
$env:LIB = "$dllDir;$env:LIB"
17+
$env:PATH = "$dllDir;$env:PATH"
18+
19+
Write-Host "`nEnvironment variables set:" -ForegroundColor Green
20+
Write-Host " WHISPER_DONT_GENERATE_BINDINGS = $env:WHISPER_DONT_GENERATE_BINDINGS" -ForegroundColor Yellow
21+
Write-Host " Added $dllDir to LIB and PATH" -ForegroundColor Yellow
22+
23+
Write-Host "`nAttempting to build..." -ForegroundColor Green
24+
25+
# Clean previous build artifacts
26+
cargo clean --target-dir D:\temp\cargo-target
27+
28+
# Try to build with verbose output
29+
cargo build --verbose 2>&1 | Tee-Object -FilePath build_log.txt
30+
31+
if ($LASTEXITCODE -ne 0) {
32+
Write-Host "`nBuild failed! Check build_log.txt for details." -ForegroundColor Red
33+
exit 1
34+
} else {
35+
Write-Host "`nBuild succeeded!" -ForegroundColor Green
36+
}

crates/whisper-local/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use serde::{ser::Serializer, Serialize};
44
pub enum Error {
55
#[error("model_not_found")]
66
ModelNotFound,
7-
#[error(transparent)]
8-
LocalWhisperError(#[from] whisper_rs::WhisperError),
7+
#[error("whisper_error: {0}")]
8+
WhisperError(String),
99
}
1010

1111
impl Serialize for Error {

crates/whisper-local/src/lib.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,18 @@ pub fn cpu_supports_avx() -> bool {
7979
#[cfg(target_arch = "x86_64")]
8080
{
8181
// Use CPUID to check for AVX2 support on x86_64
82-
if let Ok(cpuid) = raw_cpuid::CpuId::new() {
83-
if let Some(feature_info) = cpuid.get_feature_info() {
84-
// Check for AVX support (bit 28 in ECX)
85-
let avx_supported = feature_info.has_avx();
86-
87-
// Check for AVX2 support (bit 5 in EBX of leaf 7)
88-
if let Some(extended_features) = cpuid.get_extended_feature_info() {
89-
let avx2_supported = extended_features.has_avx2();
90-
return avx_supported && avx2_supported;
91-
}
92-
93-
return avx_supported;
82+
let cpuid = raw_cpuid::CpuId::new();
83+
if let Some(feature_info) = cpuid.get_feature_info() {
84+
// Check for AVX support (bit 28 in ECX)
85+
let avx_supported = feature_info.has_avx();
86+
87+
// Check for AVX2 support (bit 5 in EBX of leaf 7)
88+
if let Some(extended_features) = cpuid.get_extended_feature_info() {
89+
let avx2_supported = extended_features.has_avx2();
90+
return avx_supported && avx2_supported;
9491
}
92+
93+
return avx_supported;
9594
}
9695
false
9796
}

0 commit comments

Comments
 (0)