remove some debug logging, plus some general minor cleanup
This commit is contained in:
parent
4bab3f11a9
commit
6e8128defd
5 changed files with 2 additions and 88 deletions
|
|
@ -41,7 +41,7 @@ impl ShortcutAction for TranscribeAction {
|
||||||
if let Some(samples) = rm.stop_recording(&binding_id) {
|
if let Some(samples) = rm.stop_recording(&binding_id) {
|
||||||
match tm.transcribe(samples) {
|
match tm.transcribe(samples) {
|
||||||
Ok(transcription) => {
|
Ok(transcription) => {
|
||||||
println!("Global Shortcut Transcription: {}", transcription);
|
println!("Transcription Result: {}", transcription);
|
||||||
if !transcription.is_empty() {
|
if !transcription.is_empty() {
|
||||||
utils::paste(transcription, ah);
|
utils::paste(transcription, ah);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,13 +85,6 @@ pub fn run() {
|
||||||
let autostart_manager = app.autolaunch();
|
let autostart_manager = app.autolaunch();
|
||||||
// Enable autostart
|
// Enable autostart
|
||||||
let _ = autostart_manager.enable();
|
let _ = autostart_manager.enable();
|
||||||
// Check enable state
|
|
||||||
println!(
|
|
||||||
"registered for autostart? {}",
|
|
||||||
autostart_manager.is_enabled().unwrap()
|
|
||||||
);
|
|
||||||
// Disable autostart
|
|
||||||
let _ = autostart_manager.disable();
|
|
||||||
|
|
||||||
let recording_manager = Arc::new(
|
let recording_manager = Arc::new(
|
||||||
AudioRecordingManager::new(app).expect("Failed to initialize recording manager"),
|
AudioRecordingManager::new(app).expect("Failed to initialize recording manager"),
|
||||||
|
|
@ -121,9 +114,6 @@ pub fn run() {
|
||||||
if let Err(e) = res {
|
if let Err(e) = res {
|
||||||
println!("Failed to set activation policy: {}", e);
|
println!("Failed to set activation policy: {}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO may be different on windows, this works for macos
|
|
||||||
// tauri::AppHandle::hide(window.app_handle()).unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
||||||
|
|
@ -137,14 +137,9 @@ impl AudioRecordingManager {
|
||||||
if let Ok(mut vad) = vad_clone.lock() {
|
if let Ok(mut vad) = vad_clone.lock() {
|
||||||
match vad.compute(&chunk) {
|
match vad.compute(&chunk) {
|
||||||
Ok(result) => {
|
Ok(result) => {
|
||||||
println!("VAD PROB {}", result.prob);
|
|
||||||
if result.prob > 0.1 {
|
if result.prob > 0.1 {
|
||||||
let mut buffer = buffer_clone.lock().unwrap();
|
let mut buffer = buffer_clone.lock().unwrap();
|
||||||
buffer.extend_from_slice(&chunk);
|
buffer.extend_from_slice(&chunk);
|
||||||
println!(
|
|
||||||
"EXTENDED BUFFER. BUFFER LENGTH {}",
|
|
||||||
buffer.len()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
|
|
@ -284,14 +279,10 @@ impl AudioRecordingManager {
|
||||||
println!("Stopped recording for binding {}", binding_id);
|
println!("Stopped recording for binding {}", binding_id);
|
||||||
|
|
||||||
let mut buffer = self.buffer.lock().unwrap();
|
let mut buffer = self.buffer.lock().unwrap();
|
||||||
println!("READING BUFFER");
|
|
||||||
let audio_data: Vec<f32> = buffer.drain(..).collect();
|
let audio_data: Vec<f32> = buffer.drain(..).collect();
|
||||||
println!("READ BUFFER");
|
|
||||||
|
|
||||||
let samples = audio_data.len();
|
let samples = audio_data.len();
|
||||||
|
|
||||||
println!("SAMPLE AFTER VAD {}, DURATION {}", samples, samples / 1000);
|
|
||||||
|
|
||||||
if samples < WHISPER_SAMPLE_RATE && samples > 1000 {
|
if samples < WHISPER_SAMPLE_RATE && samples > 1000 {
|
||||||
let target_samples = WHISPER_SAMPLE_RATE * 5 / 4; // sample rate * 1.25
|
let target_samples = WHISPER_SAMPLE_RATE * 5 / 4; // sample rate * 1.25
|
||||||
let mut padded_audio = audio_data;
|
let mut padded_audio = audio_data;
|
||||||
|
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
// use kalosm::sound::rodio::buffer::SamplesBuffer;
|
|
||||||
// use kalosm::sound::{ModelLoadingProgress, TextStream, Whisper, WhisperBuilder, WhisperSource};
|
|
||||||
|
|
||||||
// pub struct TranscriptionManager {
|
|
||||||
// model: Whisper,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// impl TranscriptionManager {
|
|
||||||
// pub fn new() -> Result<Self, Box<dyn std::error::Error>> {
|
|
||||||
// let model = tauri::async_runtime::block_on(async {
|
|
||||||
// WhisperBuilder::default()
|
|
||||||
// .with_source(WhisperSource::Small)
|
|
||||||
// .build_with_loading_handler(|progress| match progress {
|
|
||||||
// ModelLoadingProgress::Downloading {
|
|
||||||
// source,
|
|
||||||
// start_time,
|
|
||||||
// progress,
|
|
||||||
// } => {
|
|
||||||
// let progress = (progress * 100.0) as u32;
|
|
||||||
// let elapsed = start_time.elapsed().as_secs_f32();
|
|
||||||
// println!("Downloading file {source} {progress}% ({elapsed}s)");
|
|
||||||
// }
|
|
||||||
// ModelLoadingProgress::Loading { progress } => {
|
|
||||||
// let progress = (progress * 100.0) as u32;
|
|
||||||
// println!("Loading model {progress}%");
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .await
|
|
||||||
// })?;
|
|
||||||
|
|
||||||
// Ok(Self { model })
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pub fn transcribe(&self, audio: SamplesBuffer<f32>) -> Result<String, anyhow::Error> {
|
|
||||||
// let mut result = String::new();
|
|
||||||
|
|
||||||
// println!("lot line transcribing");
|
|
||||||
// let mut transcribed = self.model.transcribe(audio)?;
|
|
||||||
// println!("Sync transcribing finished");
|
|
||||||
|
|
||||||
// use std::time::Instant;
|
|
||||||
|
|
||||||
// let start = Instant::now();
|
|
||||||
// tauri::async_runtime::block_on(async {
|
|
||||||
// transcribed.to_std_out().await.unwrap();
|
|
||||||
// });
|
|
||||||
// let duration = start.elapsed();
|
|
||||||
// println!("Time elapsed: {:?}", duration);
|
|
||||||
|
|
||||||
// // let segments = tauri::async_runtime::block_on(async {
|
|
||||||
// // let mut segments = Vec::new();
|
|
||||||
// // let mut stream = transcribed;
|
|
||||||
// // while let Some(segment) = stream.next().await {
|
|
||||||
// // segments.push(segment);
|
|
||||||
// // }
|
|
||||||
// // segments
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// // for segment in segments {
|
|
||||||
// // if segment.probability_of_no_speech() < 0.10 {
|
|
||||||
// // result.push_str(segment.text());
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// Ok(result)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
@ -71,7 +71,7 @@ impl TranscriptionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
let et = std::time::Instant::now();
|
let et = std::time::Instant::now();
|
||||||
println!("\n\ntook {}ms", (et - st).as_millis());
|
println!("\ntook {}ms", (et - st).as_millis());
|
||||||
|
|
||||||
Ok(result.trim().to_string())
|
Ok(result.trim().to_string())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue