Skip to content

Commit

Permalink
feat: add some error catching / ignoring
Browse files Browse the repository at this point in the history
needed as sometimes transcription errors out on `std::bad_cast` on Mac OS X with whisper-mlx. Does not seem to impact quality that much when these chunks are simply skipped.
  • Loading branch information
linozen committed Jan 13, 2025
1 parent 2689384 commit c49c339
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions verbatim/verbatim.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,23 @@ def transcribe_window(self) -> Tuple[List[Word], List[Word]]:
break
prefix_text += word.word
whisper_prompt = self.config.whisper_prompts[lang] if lang in self.config.whisper_prompts else self.config.whisper_prompts["en"]
transcript_words = self.models.transcriber.transcribe(
audio=self.state.rolling_window.array,
lang=lang,
prompt=whisper_prompt,
prefix=prefix_text,
window_ts=self.state.window_ts,
audio_ts=self.state.audio_ts,
whisper_beam_size=self.config.whisper_beam_size,
whisper_best_of=self.config.whisper_best_of,
whisper_patience=self.config.whisper_patience,
whisper_temperatures=self.config.whisper_temperatures,
)

try:
transcript_words = self.models.transcriber.transcribe(
audio=self.state.rolling_window.array,
lang=lang,
prompt=whisper_prompt,
prefix=prefix_text,
window_ts=self.state.window_ts,
audio_ts=self.state.audio_ts,
whisper_beam_size=self.config.whisper_beam_size,
whisper_best_of=self.config.whisper_best_of,
whisper_patience=self.config.whisper_patience,
whisper_temperatures=self.config.whisper_temperatures,
)
except RuntimeError as e:
LOG.warning(f"Transcription failed with RuntimeError: {str(e)}. Skipping this chunk.")
return [], []

self.state.transcript_candidate_history.advance(self.state.window_ts)
confirmed_words = self.state.transcript_candidate_history.confirm(
Expand Down

0 comments on commit c49c339

Please sign in to comment.