diff --git a/README.md b/README.md index 1955e4f619..895a54f34e 100644 --- a/README.md +++ b/README.md @@ -42,4 +42,8 @@ Download and run the `.exe` file in the [releases page](https://github.com/chidi ```shell sudo apt-get install libportaudio2 sudo snap install buzz +sudo snap connect buzz:audio-record +sudo snap connect buzz:password-manager-service +sudo snap connect buzz:pulseaudio +sudo snap connect buzz:removable-media ``` diff --git a/buzz/locale/lv_LV/LC_MESSAGES/buzz.po b/buzz/locale/lv_LV/LC_MESSAGES/buzz.po index 7930d86154..bf31c4333a 100644 --- a/buzz/locale/lv_LV/LC_MESSAGES/buzz.po +++ b/buzz/locale/lv_LV/LC_MESSAGES/buzz.po @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-06-07 21:05+0300\n" -"PO-Revision-Date: 2024-06-07 21:06+0300\n" +"POT-Creation-Date: 2024-06-09 13:25+0300\n" +"PO-Revision-Date: 2024-06-09 13:27+0300\n" "Last-Translator: \n" "Language-Team: \n" "Language: lv_LV\n" @@ -43,7 +43,7 @@ msgid "View Transcript Timestamps" msgstr "Aplūkot atpazīšanas laikus" #: buzz/settings/shortcut.py:25 buzz/widgets/main_window_toolbar.py:60 -#: buzz/widgets/main_window.py:200 +#: buzz/widgets/main_window.py:214 msgid "Clear History" msgstr "Notīrīt vēsturi" @@ -148,6 +148,26 @@ msgstr "" "Lūdzu pārbaudiet savas audio ierīces vai pārbaudiet lietotnes ziņojumu " "žurnālus, lai iegūtu papildu informāciju." +#: buzz/widgets/snap_notice.py:9 +msgid "Snap permission notice" +msgstr "Snap atļauju piezīme" + +#: buzz/widgets/snap_notice.py:13 +msgid "" +"No input devices found, please check that snap permissions have been granted" +msgstr "" +"Nav atrasta neviena skaņas ievades ierīce, iespējams nav piešķirtas " +"nepieciešamās snap atļaujas" + +#: buzz/widgets/snap_notice.py:16 +msgid "" +"To enable necessary permissions run the following commands in the terminal" +msgstr "Lai piešķirtu nepieciešamās atļaujas izpildiet šīs komandas" + +#: buzz/widgets/snap_notice.py:30 +msgid "Close" +msgstr "Aizvērt" + #: buzz/widgets/menu_bar.py:38 msgid "Import File..." msgstr "Importēt failu..." @@ -168,7 +188,7 @@ msgstr "Fails" msgid "Help" msgstr "Palīdzība" -#: buzz/widgets/main_window.py:202 +#: buzz/widgets/main_window.py:216 msgid "" "Are you sure you want to delete the selected transcription(s)? This action " "cannot be undone." @@ -176,16 +196,16 @@ msgstr "" "Vai tiešām vēlaties dzēst izvēlētos transkriptus? Šī ir neatgriezeniska " "darbība." -#: buzz/widgets/main_window.py:222 +#: buzz/widgets/main_window.py:236 msgid "Select audio file" msgstr "Izvēlieties audio failu" -#: buzz/widgets/main_window.py:256 +#: buzz/widgets/main_window.py:270 #: buzz/widgets/preferences_dialog/models_preferences_widget.py:191 msgid "Error" msgstr "Kļūda" -#: buzz/widgets/main_window.py:256 +#: buzz/widgets/main_window.py:270 msgid "Unable to save OpenAI API key to keyring" msgstr "Neizdevās saglabāt OpenAI API atslēgu atslēgu saišķī" @@ -342,7 +362,7 @@ msgstr "" "Jūsu API atslēga ir derīga. Buzz izmantos to runas atpazīšanai ar Whisper " "API." -#: buzz/widgets/preferences_dialog/general_preferences_widget.py:157 +#: buzz/widgets/preferences_dialog/general_preferences_widget.py:156 msgid "Select Export Folder" msgstr "Izvēlieties mapi kurā eksportēt" diff --git a/buzz/widgets/main_window.py b/buzz/widgets/main_window.py index 9063cf0d0d..9a03614159 100644 --- a/buzz/widgets/main_window.py +++ b/buzz/widgets/main_window.py @@ -1,4 +1,6 @@ +import os import logging +import sounddevice from typing import Tuple, List, Optional from PyQt6 import QtGui @@ -32,6 +34,7 @@ from buzz.widgets.import_url_dialog import ImportURLDialog from buzz.widgets.main_window_toolbar import MainWindowToolbar from buzz.widgets.menu_bar import MenuBar +from buzz.widgets.snap_notice import SnapNotice from buzz.widgets.preferences_dialog.models.preferences import Preferences from buzz.widgets.transcriber.file_transcriber_widget import FileTranscriberWidget from buzz.widgets.transcription_task_folder_watcher import ( @@ -137,6 +140,17 @@ def __init__(self, transcription_service: TranscriptionService): self.folder_watcher.task_found.connect(self.add_task) self.folder_watcher.find_tasks() + if os.environ.get('SNAP_NAME', '') == 'buzz': + self.check_linux_permissions() + + def check_linux_permissions(self): + devices = sounddevice.query_devices() + input_devices = [device for device in devices if device['max_input_channels'] > 0] + + if len(input_devices) == 0: + snap_notice = SnapNotice(self) + snap_notice.show() + def on_preferences_changed(self, preferences: Preferences): self.preferences = preferences self.save_preferences(preferences) diff --git a/buzz/widgets/snap_notice.py b/buzz/widgets/snap_notice.py new file mode 100644 index 0000000000..53ce6141d5 --- /dev/null +++ b/buzz/widgets/snap_notice.py @@ -0,0 +1,32 @@ +from PyQt6.QtWidgets import QDialog, QVBoxLayout, QTextEdit, QLabel, QPushButton +from buzz.locale import _ + + +class SnapNotice(QDialog): + def __init__(self, parent=None): + super().__init__(parent) + + self.setWindowTitle(_("Snap permission notice")) + + self.layout = QVBoxLayout(self) + + self.notice_label = QLabel(_("No input devices found, please check that snap permissions have been granted")) + self.layout.addWidget(self.notice_label) + + self.instruction_label = QLabel(_("To enable necessary permissions run the following commands in the terminal")) + self.layout.addWidget(self.instruction_label) + + self.text_edit = QTextEdit(self) + self.text_edit.setPlainText( + "sudo snap connect buzz:audio-record\n" + "sudo snap connect buzz:password-manager-service\n" + "sudo snap connect buzz:pulseaudio\n" + "sudo snap connect buzz:removable-media" + ) + self.text_edit.setReadOnly(True) + self.text_edit.setFixedHeight(80) + self.layout.addWidget(self.text_edit) + + self.button = QPushButton(_("Close"), self) + self.button.clicked.connect(self.close) + self.layout.addWidget(self.button) \ No newline at end of file diff --git a/docs/docs/installation.md b/docs/docs/installation.md index 926e4afcc6..c7ad79f124 100644 --- a/docs/docs/installation.md +++ b/docs/docs/installation.md @@ -30,6 +30,10 @@ Download and run the `Buzz-x.y.z.exe` file. ```shell sudo apt-get install libportaudio2 sudo snap install buzz +sudo snap connect buzz:audio-record +sudo snap connect buzz:password-manager-service +sudo snap connect buzz:pulseaudio +sudo snap connect buzz:removable-media ``` [![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/buzz) diff --git a/tests/widgets/main_window_test.py b/tests/widgets/main_window_test.py index 014fa807cb..27720305b5 100644 --- a/tests/widgets/main_window_test.py +++ b/tests/widgets/main_window_test.py @@ -18,6 +18,7 @@ from buzz.db.entity.transcription import Transcription from buzz.db.service.transcription_service import TranscriptionService from buzz.widgets.main_window import MainWindow +from buzz.widgets.snap_notice import SnapNotice from buzz.widgets.transcriber.file_transcriber_widget import FileTranscriberWidget from buzz.widgets.transcription_viewer.transcription_viewer_widget import ( TranscriptionViewerWidget, @@ -284,3 +285,12 @@ def _get_status(table_widget: QTableView, row_index: int): def _get_toolbar_action(window: MainWindow, text: str): toolbar: QToolBar = window.findChild(QToolBar) return [action for action in toolbar.actions() if action.text() == text][0] + + def test_snap_notice_dialog(self, qtbot: QtBot): + snap_notice = SnapNotice() + snap_notice.show() + + qtbot.wait_until(lambda: snap_notice.isVisible(), timeout=1000) + + snap_notice.close() + assert not snap_notice.isVisible()