Skip to content

Commit

Permalink
Whisperエラー時又は1s未満の音声は、そのままVoskでの認識を採用
Browse files Browse the repository at this point in the history
  • Loading branch information
solaoi committed Oct 30, 2024
1 parent f9937f7 commit c69674f
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src-tauri/src/module/transcription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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(())
Expand Down

0 comments on commit c69674f

Please sign in to comment.