Skip to content

armgit / Handy

Public Imported from GitHub
0

A free, open source, and extensible speech-to-text application that works completely offline.

remove some debug logging, plus some general minor cleanup

CJ Pais6e8128defd84
diff --git a/src-tauri/src/actions.rs b/src-tauri/src/actions.rs
index ac40c765..2045db44 100644
--- a/src-tauri/src/actions.rs
+++ b/src-tauri/src/actions.rs
@@ -41,7 +41,7 @@ impl ShortcutAction for TranscribeAction {
if let Some(samples) = rm.stop_recording(&binding_id) {
match tm.transcribe(samples) {
Ok(transcription) => {
- println!("Global Shortcut Transcription: {}", transcription);
+ println!("Transcription Result: {}", transcription);
if !transcription.is_empty() {
utils::paste(transcription, ah);
}
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 26a714cb..bbad689b 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -85,13 +85,6 @@ pub fn run() {
let autostart_manager = app.autolaunch();
// Enable autostart
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(
AudioRecordingManager::new(app).expect("Failed to initialize recording manager"),
@@ -121,9 +114,6 @@ pub fn run() {
if let Err(e) = res {
println!("Failed to set activation policy: {}", e);
}
-
- // TODO may be different on windows, this works for macos
- // tauri::AppHandle::hide(window.app_handle()).unwrap();
}
}
_ => {}
diff --git a/src-tauri/src/managers/audio.rs b/src-tauri/src/managers/audio.rs
index fb6b8b01..f49a823f 100644
--- a/src-tauri/src/managers/audio.rs
+++ b/src-tauri/src/managers/audio.rs
@@ -137,14 +137,9 @@ impl AudioRecordingManager {
if let Ok(mut vad) = vad_clone.lock() {
match vad.compute(&chunk) {
Ok(result) => {
- println!("VAD PROB {}", result.prob);
if result.prob > 0.1 {
let mut buffer = buffer_clone.lock().unwrap();
buffer.extend_from_slice(&chunk);
- println!(
- "EXTENDED BUFFER. BUFFER LENGTH {}",
- buffer.len()
- );
}
}
Err(error) => {
@@ -284,14 +279,10 @@ impl AudioRecordingManager {
println!("Stopped recording for binding {}", binding_id);
let mut buffer = self.buffer.lock().unwrap();
- println!("READING BUFFER");
let audio_data: Vec<f32> = buffer.drain(..).collect();
- println!("READ BUFFER");
let samples = audio_data.len();
- println!("SAMPLE AFTER VAD {}, DURATION {}", samples, samples / 1000);
-
if samples < WHISPER_SAMPLE_RATE && samples > 1000 {
let target_samples = WHISPER_SAMPLE_RATE * 5 / 4; // sample rate * 1.25
let mut padded_audio = audio_data;
diff --git a/src-tauri/src/managers/transcription.old b/src-tauri/src/managers/transcription.old
deleted file mode 100644
index 7970d487..00000000
--- a/src-tauri/src/managers/transcription.old
+++ /dev/null
@@ -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)
-// }
-// }
\ No newline at end of file
diff --git a/src-tauri/src/managers/transcription.rs b/src-tauri/src/managers/transcription.rs
index 9757c664..4ed0f6fa 100644
--- a/src-tauri/src/managers/transcription.rs
+++ b/src-tauri/src/managers/transcription.rs
@@ -71,7 +71,7 @@ impl TranscriptionManager {
}
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())
}