-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(audio): implement MKL-accelerated speech-to-text for Mac #328
Changes from 3 commits
dc37a35
f873fba
3ecb0fb
7c46091
d8b8621
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,10 +80,12 @@ criterion = { workspace = true } | |
memory-stats = "1.0" | ||
|
||
[features] | ||
default = ["metal"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why metal? and remove cuda? ??? windows / linux user dont want to use metal |
||
metal = ["candle/metal", "candle-nn/metal", "candle-transformers/metal"] | ||
cuda = ["candle/cuda", "candle-nn/cuda", "candle-transformers/cuda"] | ||
mkl = ["candle/mkl", "candle-nn/mkl", "candle-transformers/mkl"] | ||
|
||
|
||
|
||
[[bin]] | ||
name = "screenpipe-audio" | ||
path = "src/bin/screenpipe-audio.rs" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,8 +40,8 @@ pub struct WhisperModel { | |
impl WhisperModel { | ||
pub fn new(engine: Arc<AudioTranscriptionEngine>) -> Result<Self> { | ||
debug!("Initializing WhisperModel"); | ||
let device = Device::new_metal(0).unwrap_or(Device::new_cuda(0).unwrap_or(Device::Cpu)); | ||
info!("device = {:?}", device); | ||
let device = Self::get_optimal_device()?; | ||
info!("Using device: {:?}", device); | ||
|
||
debug!("Fetching model files"); | ||
let (config_filename, tokenizer_filename, weights_filename) = { | ||
|
@@ -86,6 +86,17 @@ impl WhisperModel { | |
device, | ||
}) | ||
} | ||
|
||
fn get_optimal_device() -> Result<Device> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why removed cuda? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, it was an oversight. Thank you. |
||
if let Ok(device) = Device::new_metal(0) { | ||
info!("Using Metal GPU"); | ||
Ok(device) | ||
} else { | ||
info!("Metal not available, falling back to CPU"); | ||
Ok(Device::Cpu) | ||
} | ||
} | ||
|
||
} | ||
|
||
#[derive(Debug, Clone)] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this do?