BBC-Esq / VectorDB-Plugin-for-LM-Studio

Plugin that lets you use LM Studio to ask questions about your documents including audio and video files.
https://www.youtube.com/@AI_For_Lawyers
273 stars 36 forks source link

setup.py Error: > Not Supported Between Instances #145

Closed pamodm closed 7 months ago

pamodm commented 7 months ago

I get this error while running setup.py

image

What could be the issue.

BBC-Esq commented 7 months ago

I get this error while running setup.py

image

What could be the issue.

Do you have CUDA installed? Are you even running a windows system? Setup.py is only for windows users currently because since version 4+ I've only had time to create windows installers. See the readme on githubfor linux or macos installation instructions for prior versions.

With that being said, if you are using Windows then a possibility is that cuda is not installed.

Try replacing line 75 of setup.py with the following instead to see if it works then:

if cuda_installed and cuda_version_num is not None and cuda_version_num >= 12.1: Obviously make sure that the indentation remains the same.

pamodm commented 7 months ago

Hi, thanx. I'm running on Windows without CUDA installed. I was able to proceed with setup by having cuda_version_num is not None. However, when I try to gui.py I get the following error

image
BBC-Esq commented 7 months ago

Try replacing the entirety of gui_tabs_tools_transcribe.py with the following code and let me know if it works now please:

from functools import partial
from PySide6.QtWidgets import (
    QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QFileDialog, QLabel, QComboBox, QSlider
)
from PySide6.QtCore import Qt
import yaml
from pathlib import Path
from transcribe_module import WhisperTranscriber
import threading
from utilities import my_cprint

class TranscriberToolSettingsTab(QWidget):

    def __init__(self):
        super().__init__()
        self.selected_audio_file = None

        self.create_layout()

    def read_config(self):
        with open('config.yaml', 'r') as file:
            return yaml.safe_load(file)

    def create_layout(self):
        main_layout = QVBoxLayout()

        model_selection_hbox = QHBoxLayout()
        model_selection_hbox.addWidget(QLabel("Whisper Model"))
        self.model_combo = QComboBox()

        self.model_name_mapping = {
            "large-v2 - float16": "ctranslate2-4you/whisper-large-v2-ct2-float16",
            "medium.en - float16": "ctranslate2-4you/whisper-medium.en-ct2-float16",
            "small.en - float16": "ctranslate2-4you/whisper-small.en-ct2-float16",
            "small - float16": "ctranslate2-4you/whisper-small-ct2-float16"
        }

        self.model_combo.addItems(list(self.model_name_mapping.keys()))

        model_selection_hbox.addWidget(self.model_combo)

        model_selection_hbox.addWidget(QLabel("Speed (more memory)"))

        self.slider_label = QLabel("8")
        self.number_slider = QSlider(Qt.Horizontal)
        self.number_slider.setMinimum(1)
        self.number_slider.setMaximum(100)
        self.number_slider.setValue(8)
        self.number_slider.valueChanged.connect(self.update_slider_label)

        model_selection_hbox.addWidget(self.number_slider)
        model_selection_hbox.addWidget(self.slider_label)

        main_layout.addLayout(model_selection_hbox)

        hbox = QHBoxLayout()
        self.select_file_button = QPushButton("Select Audio File")
        self.select_file_button.clicked.connect(self.select_audio_file)
        hbox.addWidget(self.select_file_button)

        self.transcribe_button = QPushButton("Transcribe")
        self.transcribe_button.clicked.connect(self.start_transcription)
        hbox.addWidget(self.transcribe_button)

        main_layout.addLayout(hbox)

        self.file_path_label = QLabel("No file currently selected")
        main_layout.addWidget(self.file_path_label)

        self.setLayout(main_layout)

    def update_slider_label(self, value):
        self.slider_label.setText(str(value))

    def update_config_file(self):
        with open('config.yaml', 'w') as file:
            yaml.dump(self.config, file)

    def select_audio_file(self):
        current_dir = Path(__file__).resolve().parent
        file_name, _ = QFileDialog.getOpenFileName(self, "Select Audio File", str(current_dir))
        if file_name:
            file_path = Path(file_name)
            short_path = "..." + str(Path(file_path.parent.name) / file_path.name)
            self.file_path_label.setText(short_path)
            self.selected_audio_file = file_name

    def start_transcription(self):
        if not self.selected_audio_file:
            print("Please select an audio file.")
            return

        selected_model = self.model_combo.currentText()
        selected_model_full_string = self.model_name_mapping[selected_model]
        selected_batch_size = int(self.slider_label.text())

        def transcription_thread():
            transcriber = WhisperTranscriber(model_identifier=selected_model_full_string, batch_size=selected_batch_size)
            transcriber.start_transcription_process(self.selected_audio_file)
            my_cprint("Transcription created and ready to be input into vector database.", 'green')

        threading.Thread(target=transcription_thread, daemon=True).start()
pamodm commented 7 months ago

Great, thanx. I was able to get the GUI loaded. Will test and report if I encounter any further issues.