Skip to content

Commit

Permalink
Merge pull request #80 from solaoi/main
Browse files Browse the repository at this point in the history
update to v0.9.4
  • Loading branch information
solaoi authored Aug 31, 2023
2 parents c0d0901 + a0fac2b commit 070a34d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lycoris",
"private": true,
"version": "0.9.3",
"version": "0.9.4",
"type": "module",
"license": "MIT",
"engines": {
Expand Down
11 changes: 6 additions & 5 deletions src-tauri/Cargo.lock

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

6 changes: 4 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lycoris"
version = "0.9.3"
version = "0.9.4"
description = "Lycoris is an offline voice memo"
authors = ["solaoi"]
license = "MIT"
Expand All @@ -25,7 +25,7 @@ once_cell = "1.13.1"
crossbeam-channel = "0.5.6"
chrono = "0.4.22"
hound = "3.4.0"
whisper-rs = "0.4.0"
whisper-rs = "0.8.0"
rusqlite = "*"
samplerate-rs = "0.1.0"
# download model and openai request
Expand All @@ -41,6 +41,8 @@ features = ["sqlite"]
[dependencies.tauri-plugin-window-state]
git = "https://github.com/tauri-apps/plugins-workspace"
branch = "dev"
[target.'cfg(target_arch = "aarch64")'.dependencies.whisper-rs]
features = ["coreml"]

[features]
# by default Tauri runs in production mode
Expand Down
22 changes: 20 additions & 2 deletions src-tauri/src/module/downloader/whisper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl WhisperModelDownloader {

#[tokio::main]
pub async fn download(&self, model_type: ModelTypeWhisper) {
let model_path: &str = &format!("resources/whisper/ggml-{}.bin", model_type.as_str());
let model_path: &str = &format!("resources/whisper/ggml-{}.zip", model_type.as_str());
let path: &str = &self
.app_handle
.path_resolver()
Expand All @@ -34,7 +34,7 @@ impl WhisperModelDownloader {
.to_string_lossy()
.to_string();
let url: &str = &format!(
"https://object-storage.tyo1.conoha.io/v1/nc_b22de95e3cf1434da07499038766e2b7/lycoris/ggml-{}.bin",
"https://object-storage.tyo1.conoha.io/v1/nc_b22de95e3cf1434da07499038766e2b7/lycoris/ggml-{}.zip",
model_type.as_str()
);
let res = reqwest::get(url).await.unwrap();
Expand Down Expand Up @@ -91,6 +91,24 @@ impl WhisperModelDownloader {
}
}

let dir: &str = &self
.app_handle
.path_resolver()
.resolve_resource("resources/whisper")
.unwrap()
.to_string_lossy()
.to_string();
let _ = std::process::Command::new("sh")
.arg("-c")
.arg(format!("unzip {} -d {}", path, dir))
.output()
.expect("failed");
let _ = std::process::Command::new("sh")
.arg("-c")
.arg(format!("rm {}", path))
.output()
.expect("failed");

let _ = Sqlite::new().update_model_is_downloaded(model_type.as_str().to_string(), 1);

let _ = &self.app_handle.emit_all(
Expand Down
14 changes: 7 additions & 7 deletions src-tauri/src/module/transcription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Transcription {
),
}
let data = if spec.channels != 1 {
whisper_rs::convert_stereo_to_mono_audio(&data)
whisper_rs::convert_stereo_to_mono_audio(&data).unwrap()
} else {
data
};
Expand All @@ -116,21 +116,21 @@ impl Transcription {
)
.unwrap();

// let mut ctx = Transcriber::build(self.app_handle.clone());
// let mut ctx = self.ctx;
let result = self.ctx.full(
let mut state = self.ctx.create_state().expect("failed to create state");
let result = state.full(
Transcriber::build_params(
self.speaker_language.clone(),
self.transcription_accuracy.clone(),
),
&audio_data[..],
);
if result.is_ok() {
let num_segments = self.ctx.full_n_segments();
let num_segments = state
.full_n_segments()
.expect("failed to get number of segments");
let mut converted: Vec<String> = vec!["".to_string()];
for i in 0..num_segments {
let segment = self
.ctx
let segment = state
.full_get_segment_text(i)
.expect("failed to get segment");
converted.push(segment.to_string());
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "Lycoris",
"version": "0.9.3"
"version": "0.9.4"
},
"tauri": {
"allowlist": {
Expand Down

0 comments on commit 070a34d

Please sign in to comment.