From 004613906c0e2f35aeba9894721dd6c2fb628c23 Mon Sep 17 00:00:00 2001 From: Raivis Dejus Date: Sat, 22 Jun 2024 19:20:22 +0300 Subject: [PATCH] Fix for default HF model (#812) --- CONTRIBUTING.md | 8 ++++++++ buzz/model_loader.py | 2 +- buzz/widgets/transcriber/hugging_face_search_line_edit.py | 5 +---- .../transcriber/transcription_options_group_box.py | 5 ++++- tests/gui_test.py | 3 +++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 853e50295..7732781ed 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,6 +54,14 @@ On versions prior to Ubuntu 24.04 install `sudo apt-get install --no-install-rec 7. Build Buzz `poetry build` 8. Run Buzz `python -m buzz` +#### Error for Faster Whisper on GPU `Could not load library libcudnn_ops_infer.so.8` + +You need to add path to the library to the `LD_LIBRARY_PATH` environment variable. +Check exact path to your poetry virtual environment, it may be different for you. + +``` + export LD_LIBRARY_PATH=/home/PutYourUserNameHere/.cache/pypoetry/virtualenvs/buzz-captions-JjGFxAW6-py3.12/lib/python3.12/site-packages/nvidia/cudnn/lib/:$LD_LIBRARY_PATH +``` ### Windows Assumes you have [Git](https://git-scm.com/downloads) and [python](https://www.python.org/downloads) installed and added to PATH. diff --git a/buzz/model_loader.py b/buzz/model_loader.py index a38b24931..d7ff524c1 100644 --- a/buzz/model_loader.py +++ b/buzz/model_loader.py @@ -114,7 +114,7 @@ def is_manually_downloadable(self): class TranscriptionModel: model_type: ModelType = ModelType.WHISPER whisper_model_size: Optional[WhisperModelSize] = WhisperModelSize.TINY - hugging_face_model_id: Optional[str] = None + hugging_face_model_id: Optional[str] = "openai/whisper-tiny" def __str__(self): match self.model_type: diff --git a/buzz/widgets/transcriber/hugging_face_search_line_edit.py b/buzz/widgets/transcriber/hugging_face_search_line_edit.py index c39c344bb..efb319bea 100644 --- a/buzz/widgets/transcriber/hugging_face_search_line_edit.py +++ b/buzz/widgets/transcriber/hugging_face_search_line_edit.py @@ -29,12 +29,10 @@ class HuggingFaceSearchLineEdit(LineEdit): def __init__( self, + default_value: str, network_access_manager: Optional[QNetworkAccessManager] = None, parent: Optional[QWidget] = None, ): - self.settings = QSettings(APP_NAME) - default_value = self.settings.value("hugging_face_model_id", "openai/whisper-tiny") - super().__init__(default_value, parent) self.setMinimumWidth(150) @@ -76,7 +74,6 @@ def on_select_item(self): item = self.popup.currentItem() self.setText(item.text()) - self.settings.setValue("hugging_face_model_id", item.text()) QMetaObject.invokeMethod(self, "returnPressed") self.model_selected.emit(item.data(Qt.ItemDataRole.UserRole)) diff --git a/buzz/widgets/transcriber/transcription_options_group_box.py b/buzz/widgets/transcriber/transcription_options_group_box.py index afb85738d..dee9ca8a5 100644 --- a/buzz/widgets/transcriber/transcription_options_group_box.py +++ b/buzz/widgets/transcriber/transcription_options_group_box.py @@ -1,3 +1,4 @@ +import logging from typing import Optional, List from PyQt6.QtCore import pyqtSignal @@ -65,7 +66,9 @@ def __init__( self.on_openai_access_token_edit_changed ) - self.hugging_face_search_line_edit = HuggingFaceSearchLineEdit() + self.hugging_face_search_line_edit = HuggingFaceSearchLineEdit( + default_value=default_transcription_options.model.hugging_face_model_id + ) self.hugging_face_search_line_edit.model_selected.connect( self.on_hugging_face_model_changed ) diff --git a/tests/gui_test.py b/tests/gui_test.py index 780fa8509..c13554ad7 100644 --- a/tests/gui_test.py +++ b/tests/gui_test.py @@ -161,6 +161,7 @@ def test_should_validate_temperature(self, text: str, state: QValidator.State): class TestHuggingFaceSearchLineEdit: def test_should_update_selected_model_on_type(self, qtbot: QtBot): widget = HuggingFaceSearchLineEdit( + default_value="", network_access_manager=self.network_access_manager() ) qtbot.add_widget(widget) @@ -173,6 +174,7 @@ def test_should_update_selected_model_on_type(self, qtbot: QtBot): def test_should_show_list_of_models(self, qtbot: QtBot): widget = HuggingFaceSearchLineEdit( + default_value="", network_access_manager=self.network_access_manager() ) qtbot.add_widget(widget) @@ -184,6 +186,7 @@ def test_should_show_list_of_models(self, qtbot: QtBot): def test_should_select_model_from_list(self, qtbot: QtBot): widget = HuggingFaceSearchLineEdit( + default_value="", network_access_manager=self.network_access_manager() ) qtbot.add_widget(widget)