From 71fd3f61b969e288ff6d48a4a0e6d71d701853a0 Mon Sep 17 00:00:00 2001 From: Raivis Dejus Date: Sat, 8 Jun 2024 18:45:22 +0300 Subject: [PATCH 1/2] Fix for live transcription with Faster whisper --- buzz/transcriber/recording_transcriber.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/buzz/transcriber/recording_transcriber.py b/buzz/transcriber/recording_transcriber.py index b0fc22758..def9a3311 100644 --- a/buzz/transcriber/recording_transcriber.py +++ b/buzz/transcriber/recording_transcriber.py @@ -16,6 +16,7 @@ from buzz.transformers_whisper import TransformersWhisper import whisper +import faster_whisper class RecordingTranscriber(QObject): @@ -53,6 +54,8 @@ def start(self): model = whisper.load_model(model_path) elif self.transcription_options.model.model_type == ModelType.WHISPER_CPP: model = WhisperCpp(model_path) + elif self.transcription_options.model.model_type == ModelType.FASTER_WHISPER: + model = faster_whisper.WhisperModel(model_path) else: # ModelType.HUGGING_FACE model = transformers_whisper.load_model(model_path) @@ -113,7 +116,24 @@ def start(self): transcription_options=self.transcription_options ), ) - else: + elif ( + self.transcription_options.model.model_type + == ModelType.FASTER_WHISPER + ): + assert isinstance(model, faster_whisper.WhisperModel) + whisper_segments, info = model.transcribe( + audio=samples, + language=self.transcription_options.language + if self.transcription_options.language is not "" + else None, + task=self.transcription_options.task.value, + temperature=self.transcription_options.temperature, + initial_prompt=self.transcription_options.initial_prompt, + word_timestamps=self.transcription_options.word_level_timings, + ) + result = {"text": " ".join([segment.text for segment in whisper_segments])} + + else: # ModelType.HUGGING_FACE assert isinstance(model, TransformersWhisper) result = model.transcribe( audio=samples, From 056b81e98197af7ee7f98521bb97a893599f1434 Mon Sep 17 00:00:00 2001 From: Raivis Dejus Date: Sat, 8 Jun 2024 18:50:26 +0300 Subject: [PATCH 2/2] Will print cache dir in logs --- buzz/buzz.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buzz/buzz.py b/buzz/buzz.py index 7a0131a31..8cddf3554 100644 --- a/buzz/buzz.py +++ b/buzz/buzz.py @@ -6,7 +6,7 @@ import sys from typing import TextIO -from platformdirs import user_log_dir +from platformdirs import user_log_dir, user_cache_dir from buzz.assets import APP_BASE_DIR @@ -59,6 +59,7 @@ def main(): logging.debug("app_dir: %s", APP_BASE_DIR) logging.debug("log_dir: %s", log_dir) + logging.debug("cache_dir: %s", user_cache_dir("Buzz")) app = Application(sys.argv) parse_command_line(app)