From c69674fdd979a6f284c5fe162ae610a6473859d1 Mon Sep 17 00:00:00 2001 From: Kodai Aoyama Date: Thu, 31 Oct 2024 00:27:33 +0900 Subject: [PATCH] =?UTF-8?q?Whisper=E3=82=A8=E3=83=A9=E3=83=BC=E6=99=82?= =?UTF-8?q?=E5=8F=88=E3=81=AF1s=E6=9C=AA=E6=BA=80=E3=81=AE=E9=9F=B3?= =?UTF-8?q?=E5=A3=B0=E3=81=AF=E3=80=81=E3=81=9D=E3=81=AE=E3=81=BE=E3=81=BE?= =?UTF-8?q?Vosk=E3=81=A7=E3=81=AE=E8=AA=8D=E8=AD=98=E3=82=92=E6=8E=A1?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/module/transcription.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/module/transcription.rs b/src-tauri/src/module/transcription.rs index 95c7e26..7c17937 100644 --- a/src-tauri/src/module/transcription.rs +++ b/src-tauri/src/module/transcription.rs @@ -73,6 +73,20 @@ impl Transcription { let mut reader = hound::WavReader::open(speech.wav).unwrap(); let spec = reader.spec(); + if (reader.duration() / spec.sample_rate as u32) < 1 { + println!("input is too short, so skipping..."); + let mut updated = self + .sqlite + .update_model_vosk_to_whisper(speech.id, "".to_string()) + .unwrap(); + updated.content = speech.content; + self.app_handle + .clone() + .emit_all("finalTextConverted", updated) + .unwrap(); + return Ok(()); + } + let mut data = Vec::with_capacity((spec.channels as usize) * (reader.duration() as usize)); match (spec.bits_per_sample, spec.sample_format) { @@ -148,7 +162,16 @@ impl Transcription { .unwrap(); } } else { - println!("whisper is temporally failed, so skipping...") + println!("whisper is temporally failed, so skipping..."); + let mut updated = self + .sqlite + .update_model_vosk_to_whisper(speech.id, "".to_string()) + .unwrap(); + updated.content = speech.content; + self.app_handle + .clone() + .emit_all("finalTextConverted", updated) + .unwrap(); } Ok(())