-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from solaoi/feature/hybrid-transcription
Feature/hybrid transcription
- Loading branch information
Showing
20 changed files
with
963 additions
and
22 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 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
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
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,80 @@ | ||
use super::{ | ||
transcription_hybrid_online, transcription_hybrid_reazonspeech, transcription_hybrid_whisper, | ||
}; | ||
|
||
use crossbeam_channel::Receiver; | ||
use std::{sync::Mutex, thread}; | ||
use tauri::AppHandle; | ||
|
||
pub struct TranscriptionHybrid { | ||
app_handle: AppHandle, | ||
note_id: u64, | ||
} | ||
|
||
impl TranscriptionHybrid { | ||
pub fn new(app_handle: AppHandle, note_id: u64) -> Self { | ||
TranscriptionHybrid { | ||
app_handle, | ||
note_id, | ||
} | ||
} | ||
|
||
pub fn start(&mut self, stop_convert_rx: Receiver<()>, use_no_vosk_queue_terminate_mode: bool) { | ||
let note_id = self.note_id; | ||
|
||
let app_handle_clone_for_reazonspeech = self.app_handle.clone(); | ||
let app_handle_clone_for_whisper = self.app_handle.clone(); | ||
|
||
let stop_convert_rx_clone_for_reazonspeech = stop_convert_rx.clone(); | ||
let stop_convert_rx_clone_for_whisper = stop_convert_rx.clone(); | ||
|
||
thread::spawn(move || { | ||
transcription_hybrid_reazonspeech::initialize_transcription_hybrid_reazonspeech( | ||
app_handle_clone_for_reazonspeech, | ||
note_id, | ||
); | ||
let mut lock = transcription_hybrid_reazonspeech::SINGLETON_INSTANCE | ||
.lock() | ||
.unwrap(); | ||
if let Some(singleton) = lock.as_mut() { | ||
singleton.start( | ||
stop_convert_rx_clone_for_reazonspeech, | ||
use_no_vosk_queue_terminate_mode, | ||
); | ||
} | ||
}); | ||
|
||
thread::spawn(move || { | ||
transcription_hybrid_whisper::initialize_transcription_hybrid_whisper( | ||
app_handle_clone_for_whisper, | ||
note_id, | ||
); | ||
let mut lock = transcription_hybrid_whisper::SINGLETON_INSTANCE | ||
.lock() | ||
.unwrap(); | ||
if let Some(singleton) = lock.as_mut() { | ||
singleton.start( | ||
stop_convert_rx_clone_for_whisper, | ||
use_no_vosk_queue_terminate_mode, | ||
); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
pub static SINGLETON_INSTANCE: Mutex<Option<TranscriptionHybrid>> = Mutex::new(None); | ||
|
||
pub fn initialize_transcription_hybrid(app_handle: AppHandle, note_id: u64) { | ||
let mut singleton = SINGLETON_INSTANCE.lock().unwrap(); | ||
if singleton.is_none() { | ||
*singleton = Some(TranscriptionHybrid::new(app_handle, note_id)); | ||
} | ||
} | ||
|
||
pub fn drop_transcription_hybrid() { | ||
let mut singleton = SINGLETON_INSTANCE.lock().unwrap(); | ||
*singleton = None; | ||
transcription_hybrid_reazonspeech::drop_transcription_hybrid_reazonspeech(); | ||
transcription_hybrid_whisper::drop_transcription_hybrid_whisper(); | ||
transcription_hybrid_online::drop_transcription_hybrid_online(); | ||
} |
Oops, something went wrong.