Skip to content

Commit

Permalink
Merge pull request #185 from solaoi/main
Browse files Browse the repository at this point in the history
v0.9.24
  • Loading branch information
solaoi authored Nov 10, 2024
2 parents 4948ab6 + 49fc242 commit e9a3569
Show file tree
Hide file tree
Showing 26 changed files with 993 additions and 50 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.23",
"version": "0.9.24",
"type": "module",
"license": "MIT",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

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

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lycoris"
version = "0.9.23"
version = "0.9.24"
description = "Lycoris is an offline voice memo"
authors = ["solaoi"]
license = "MIT"
Expand Down
10 changes: 9 additions & 1 deletion src-tauri/migrations/001.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ CREATE TABLE speeches (
created_at_unixtime INTEGER DEFAULT (CAST(strftime('%s', 'now') AS INTEGER)),
content TEXT,
content_2 TEXT,
is_done_with_hybrid_reazonspeech INTEGER DEFAULT 0,
is_done_with_hybrid_whisper INTEGER DEFAULT 0,
hybrid_reazonspeech_content TEXT,
hybrid_whisper_content TEXT,
wav TEXT,
model TEXT,
-- manual|vosk|whisper
Expand Down Expand Up @@ -178,4 +182,8 @@ VALUES("jvnv-F2-jp", "style-bert-vits2-voice");
INSERT INTO models(model_name, model_type)
VALUES("jvnv-M1-jp", "style-bert-vits2-voice");
INSERT INTO models(model_name, model_type)
VALUES("jvnv-M2-jp", "style-bert-vits2-voice");
VALUES("jvnv-M2-jp", "style-bert-vits2-voice");
CREATE INDEX idx_hybrid_status ON speeches(
is_done_with_hybrid_reazonspeech,
is_done_with_hybrid_whisper
);
7 changes: 6 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
)]

use tauri::{
http::{HttpRange, ResponseBuilder}, AppHandle, Manager, PathResolver, State, Window
http::{HttpRange, ResponseBuilder},
AppHandle, Manager, PathResolver, State, Window,
};
use tauri_plugin_sql::{Migration, MigrationKind};

Expand Down Expand Up @@ -41,6 +42,7 @@ use module::{
synthesizer::{self, Synthesizer},
transcription::{TraceCompletion, Transcription},
transcription_amivoice::TranscriptionAmivoice,
transcription_hybrid::TranscriptionHybrid,
transcription_ja::TranscriptionJa,
transcription_online::TranscriptionOnline,
translation_en::TranslationEn,
Expand Down Expand Up @@ -325,6 +327,9 @@ fn start_trace_command(
} else if transcription_accuracy.starts_with("reazonspeech") {
let mut transcription_ja = TranscriptionJa::new(app_handle, note_id);
transcription_ja.start(stop_convert_rx, true);
} else if transcription_accuracy.starts_with("hybrid-transcript") {
let mut transcription_hybrid = TranscriptionHybrid::new(app_handle, note_id);
transcription_hybrid.start(stop_convert_rx, true);
} else {
let mut transcription = Transcription::new(
app_handle,
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/module/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl Action {
}

pub fn execute(&mut self) {
if self.token == "" {
if self.token.is_empty() {
println!("whisper token is empty, so skipping...");
return;
}
Expand Down
24 changes: 12 additions & 12 deletions src-tauri/src/module/chat_online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ impl ChatOnline {
}
}

pub fn start(&mut self, stop_convert_rx: Receiver<()>, is_continuous: bool) {
pub fn start(&mut self, stop_convert_rx: Receiver<()>, use_no_vosk_queue_terminate_mode: bool) {
while Self::convert(self).is_ok() {
if is_continuous {
if use_no_vosk_queue_terminate_mode {
let vosk_speech = self.sqlite.select_vosk(self.note_id);
if vosk_speech.is_err() {
self.app_handle
Expand Down Expand Up @@ -176,10 +176,10 @@ impl ChatOnline {
);
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));

let post_body = if template != "" {
if functions != "" {
let post_body = if !template.is_empty() {
if !functions.is_empty() {
let func: Value = serde_json::from_str(functions).unwrap();
if function_call != "" {
if !function_call.is_empty() {
json!({
"model": model,
"temperature": temperature,
Expand All @@ -204,9 +204,9 @@ impl ChatOnline {
})
}
} else {
if functions != "" {
if !functions.is_empty() {
let func: Value = serde_json::from_str(functions).unwrap();
if function_call != "" {
if !function_call.is_empty() {
json!({
"model": model,
"temperature": temperature,
Expand Down Expand Up @@ -243,7 +243,7 @@ impl ChatOnline {
let json_response: Value = response.json().await?;

let response_text = if status == 200 {
if functions != "" {
if !functions.is_empty() {
let name = serde_json::to_string(
&json_response["choices"][0]["message"]["function_call"]["name"],
)
Expand Down Expand Up @@ -286,7 +286,7 @@ impl ChatOnline {
let result = self.sqlite.select_ai_resource();
let resource = if result.is_ok() {
let command = result.unwrap().replace("{{question}}", &question);
if command == "" {
if command.is_empty() {
"".to_string()
} else {
let result = std::process::Command::new("sh")
Expand All @@ -305,7 +305,7 @@ impl ChatOnline {
};
let result = self.sqlite.select_ai_template();
let template = if result.is_ok() {
if resource == "" {
if resource.is_empty() {
result.unwrap()
} else {
result
Expand Down Expand Up @@ -352,7 +352,7 @@ impl ChatOnline {
} else {
"".to_string()
};
let output = if hook != "" {
let output = if !hook.is_empty() {
let command = hook
.replace("{{resource}}", &resource)
.replace("{{answer}}", &answer)
Expand All @@ -370,7 +370,7 @@ impl ChatOnline {
} else {
"".to_string()
};
let message = if output != "" {
let message = if !output.is_empty() {
format!("Q. {}\nA. {}\nCLI. {}", question, answer, output)
} else {
format!("Q. {}\nA. {}", question, answer)
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/module/deleter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl NoteDeleter {
let sqlite = Sqlite::new();
let speeches = sqlite.select_all_speeches_by(note_id).unwrap();
let _ = speeches.iter().for_each(|speech| {
if speech.wav != "" {
if !speech.wav.is_empty() {
if let Err(e) = remove_file(&speech.wav) {
eprintln!("Failed to delete file {}: {}", &speech.wav, e);
}
Expand Down
6 changes: 5 additions & 1 deletion src-tauri/src/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ mod sqlite;
pub mod synthesizer;
mod transcriber;
pub mod transcription;
pub mod transcription_ja;
pub mod transcription_amivoice;
pub mod transcription_hybrid;
mod transcription_hybrid_online;
mod transcription_hybrid_reazonspeech;
mod transcription_hybrid_whisper;
pub mod transcription_ja;
pub mod transcription_online;
pub mod translation_en;
pub mod translation_ja;
Expand Down
16 changes: 14 additions & 2 deletions src-tauri/src/module/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ use tauri::{api::path::data_dir, AppHandle, Manager};

use super::{
chat_online, recognizer::MyRecognizer, sqlite::Sqlite, transcription, transcription_amivoice,
transcription_ja, transcription_online, translation_en, translation_ja, translation_ja_high,
writer::Writer,
transcription_hybrid, transcription_ja, transcription_online, translation_en, translation_ja,
translation_ja_high, writer::Writer,
};

pub struct Record {
Expand Down Expand Up @@ -258,6 +258,17 @@ impl Record {
if let Some(singleton) = lock.as_mut() {
singleton.start(stop_convert_rx_clone, false);
}
} else if transcription_accuracy_clone.starts_with("hybrid-transcript")
{
transcription_hybrid::initialize_transcription_hybrid(
app_handle_clone,
note_id,
);
let mut lock =
transcription_hybrid::SINGLETON_INSTANCE.lock().unwrap();
if let Some(singleton) = lock.as_mut() {
singleton.start(stop_convert_rx_clone, false);
}
} else {
transcription::initialize_transcription(
app_handle_clone,
Expand Down Expand Up @@ -300,6 +311,7 @@ impl Record {
translation_ja_high::drop_translation_ja_high();
transcription_online::drop_transcription_online();
transcription_amivoice::drop_transcription_amivoice();
transcription_hybrid::drop_transcription_hybrid();
chat_online::drop_chat_online();
} else {
drop(stop_convert_tx)
Expand Down
12 changes: 11 additions & 1 deletion src-tauri/src/module/record_desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use screencapturekit::{
use vosk::Recognizer;

use super::{
chat_online, recognizer::MyRecognizer, sqlite::Sqlite, transcription, transcription_amivoice, transcription_ja, transcription_online, translation_en, translation_ja, translation_ja_high, writer::Writer
chat_online, recognizer::MyRecognizer, sqlite::Sqlite, transcription, transcription_amivoice, transcription_hybrid, transcription_ja, transcription_online, translation_en, translation_ja, translation_ja_high, writer::Writer
};

pub struct RecordDesktop {
Expand Down Expand Up @@ -288,6 +288,15 @@ impl RecordDesktop {
if let Some(singleton) = lock.as_mut() {
singleton.start(stop_convert_rx_clone, false);
}
} else if transcription_accuracy_clone.starts_with("hybrid-transcript") {
transcription_hybrid::initialize_transcription_hybrid(
app_handle_clone,
note_id,
);
let mut lock = transcription_hybrid::SINGLETON_INSTANCE.lock().unwrap();
if let Some(singleton) = lock.as_mut() {
singleton.start(stop_convert_rx_clone, false);
}
} else {
transcription::initialize_transcription(
app_handle_clone,
Expand Down Expand Up @@ -334,6 +343,7 @@ impl RecordDesktop {
translation_ja_high::drop_translation_ja_high();
transcription_online::drop_transcription_online();
transcription_amivoice::drop_transcription_amivoice();
transcription_hybrid::drop_transcription_hybrid();
chat_online::drop_chat_online();
} else {
drop(stop_convert_tx)
Expand Down
Loading

0 comments on commit e9a3569

Please sign in to comment.