forked from thewh1teagle/vibe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab59b3c
commit a2cc5c4
Showing
9 changed files
with
86 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,3 @@ pub mod downloader; | |
pub mod language; | ||
pub mod model; | ||
pub mod transcript; | ||
pub mod integrity; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use crate::{config, pretty_error, APP_ASYNC_STATIC, APP_STATIC}; | ||
use log; | ||
use tauri::Manager; | ||
use vibe::transcript::Transcript; | ||
|
||
fn on_transcribe_progress(progress: i32) { | ||
if let Some(app) = &*APP_STATIC.lock().unwrap() { | ||
log::debug!("desktop progress is {}", progress); | ||
let window = app.get_webview_window("main").unwrap(); | ||
window.emit("transcribe_progress", progress).unwrap(); | ||
} else { | ||
log::error!("App instance not available"); | ||
} | ||
} | ||
|
||
async fn on_download_progress(current: u64, total: u64) { | ||
if let Some(app) = APP_ASYNC_STATIC.lock().await.as_ref() { | ||
let window: tauri::WebviewWindow = app.get_webview_window("main").unwrap(); | ||
window.emit("download_progress", (current, total)).unwrap(); | ||
} else { | ||
log::error!("App instance not available"); | ||
} | ||
} | ||
|
||
#[tauri::command] | ||
pub async fn download_model() -> Result<(), String> { | ||
let model_path = vibe::config::get_model_path().map_err(|e| pretty_error!(e))?; | ||
let mut downloader = vibe::downloader::Downloader::new(); | ||
log::debug!("Download model invoked! with path {}", model_path.display()); | ||
downloader | ||
.download(config::URL, model_path.to_owned(), on_download_progress) | ||
.await | ||
.map_err(|e| pretty_error!(e))?; | ||
Ok(()) | ||
} | ||
|
||
#[tauri::command] | ||
pub async fn get_default_model_path() -> Result<String, String> { | ||
let model_path = vibe::config::get_model_path().map_err(|e| pretty_error!(e))?; | ||
let model_path = model_path.to_str().ok_or("cant convert model path to string")?; | ||
Ok(model_path.to_string()) | ||
} | ||
|
||
#[tauri::command] | ||
pub async fn transcribe(options: vibe::config::ModelArgs) -> Result<Transcript, String> { | ||
let transcript = vibe::model::transcribe(&options, Some(on_transcribe_progress)) | ||
.map_err(|e| pretty_error!(e)) | ||
.map_err(|e| format!("{:?}\noptions: {:?}", e, options))?; | ||
Ok(transcript) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
use vibe; | ||
|
||
pub const URL: &str = vibe::config::URL; | ||
pub const HASH: &str = ""; // TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters