Skip to content

Commit 238fd87

Browse files
committed
Refactored snap build to use gnome extension
1 parent 7638177 commit 238fd87

File tree

8 files changed

+199
-167
lines changed

8 files changed

+199
-167
lines changed

Buzz.spec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ datas += copy_metadata("pyyaml")
2828
datas += collect_data_files("transformers", include_py_files=True)
2929

3030
datas += collect_data_files("whisper")
31-
datas += [("demucs", "demucs")]
31+
datas += collect_data_files("demucs", include_py_files=True)
32+
datas += collect_data_files("whisper_diarization", include_py_files=True)
3233
datas += [("buzz/assets/*", "assets")]
3334
datas += [("buzz/locale", "locale")]
3435
datas += [("buzz/schema.sql", ".")]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ ifeq ($(OS), Windows_NT)
237237
done
238238
else
239239
for dir in buzz/locale/*/ ; do \
240-
python msgfmt.py -o $$dir/LC_MESSAGES/buzz.mo $$dir/LC_MESSAGES/buzz.po; \
240+
python3 msgfmt.py -o $$dir/LC_MESSAGES/buzz.mo $$dir/LC_MESSAGES/buzz.po; \
241241
done
242242
endif
243243

buzz/widgets/transcription_viewer/speaker_identification_widget.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ def load_preferences(self):
373373
return preferences
374374

375375
def on_identify_button_clicked(self):
376+
self.step_1_button.setEnabled(False)
377+
376378
self.thread = QThread()
377379
self.worker = IdentificationWorker(
378380
self.transcription,
@@ -520,6 +522,8 @@ def on_save_button_clicked(self):
520522

521523
self.transcription_service.update_transcription_as_completed(new_transcript_id, segments)
522524

525+
# TODO - See if we can get rows in the transcription viewer to be of variable height
526+
# If text is longer they should expand
523527
if self.transcriptions_updated_signal:
524528
self.transcriptions_updated_signal.emit(new_transcript_id)
525529

poetry.lock

Lines changed: 115 additions & 103 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ include = [
2626
{ path = "buzz/whisper_cpp.py", format = ["sdist", "wheel"] },
2727
{ path = "buzz/locale/*/LC_MESSAGES/buzz.mo", format = ["sdist", "wheel"] },
2828
{ path = "buzz/dll_backup/*", format = ["sdist", "wheel"] },
29+
{ path = "demucs/*", format = ["sdist", "wheel"] },
30+
{ path = "whisper_diarization/*", format = ["sdist", "wheel"] },
2931
]
3032

3133
[[tool.poetry.source]]
@@ -82,6 +84,7 @@ posthog = "^3.23.0"
8284
deepmultilingualpunctuation = {git = "https://github.com/oliverguhr/deepmultilingualpunctuation.git"}
8385
ctc-forced-aligner = {git = "https://github.com/MahmoudAshraf97/ctc-forced-aligner.git"}
8486
nemo-toolkit = {extras = ["asr"], version = "^2.2.1"}
87+
multidict = "6.4.3"
8588

8689
[tool.poetry.group.dev.dependencies]
8790
autopep8 = "^1.7.0"

share/applications/buzz.desktop

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[Desktop Entry]
2+
3+
Type=Application
4+
5+
Encoding=UTF-8
6+
7+
Name=Buzz
8+
9+
Comment=Buzz transcribes and translates audio offline on your personal computer.
10+
11+
Path=/opt/buzz
12+
13+
Exec=/opt/buzz/Buzz
14+
15+
Icon=buzz
16+
17+
Terminal=false

snap/snapcraft.yaml

Lines changed: 53 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Development notes:
2-
# - To build the snap run `snapcraft clean` and `snapcraft`
2+
# - To build the snap run `snapcraft clean` and `snapcraft --debug --verbosity verbose`
33
# - To install local snap `snap install ./buzz_*.snap --dangerous`
4+
# - To check for issues `snapcraft lint buzz_*.snap`
45
name: buzz
56
base: core22
67
version: git
@@ -22,43 +23,6 @@ architectures:
2223
- build-on: amd64
2324

2425
parts:
25-
desktop-qt5:
26-
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
27-
source-subdir: qt
28-
plugin: make
29-
make-parameters: [ "FLAVOR=qt5" ]
30-
build-packages:
31-
- build-essential
32-
- qtbase5-dev
33-
- dpkg-dev
34-
stage-packages:
35-
- libxkbcommon0
36-
- fonts-ubuntu
37-
- dmz-cursor-theme
38-
- light-themes
39-
- adwaita-icon-theme
40-
- gnome-themes-standard
41-
- shared-mime-info
42-
- libqt5gui5
43-
- libgdk-pixbuf2.0-0
44-
- libqt5svg5 # for loading icon themes which are svg
45-
- libglib2.0-0
46-
- xdg-user-dirs
47-
override-prime: |
48-
craftctl default
49-
glib-compile-schemas usr/share/glib-2.0/schemas
50-
51-
platform-modules:
52-
plugin: nil
53-
stage-packages:
54-
- appmenu-gtk3-module
55-
- libcanberra-gtk3-module
56-
57-
qt5-gtk-platform:
58-
plugin: nil
59-
stage-packages:
60-
- qt5-gtk-platformtheme
61-
6226
alsa-pulseaudio:
6327
plugin: dump
6428
source: .
@@ -81,19 +45,30 @@ parts:
8145
8246
buzz:
8347
plugin: python
48+
python-packages:
49+
- numpy==1.26.4 # version from .lock file so sox can install
50+
- typing-extensions==4.12.2 # version from .lock file so sox can install
8451
source: .
8552
build-packages:
8653
- portaudio19-dev
54+
- build-essential
55+
- git
56+
- sox
8757
stage-packages:
58+
# Theme support and platform modules
59+
- qt5-gtk-platformtheme
60+
- qt6-gtk-platformtheme
61+
- appmenu-gtk3-module
62+
- appmenu-gtk-module-common
63+
- libcanberra-gtk3-module
8864
# Audio
8965
- ffmpeg
9066
- libportaudio2
9167
- libpulse0
92-
- libasound2
9368
- libasound2-plugins
9469
- libasound2-plugins-extra
9570
- libyaml-dev
96-
- libegl1-mesa
71+
- libegl1
9772
- gstreamer1.0-plugins-good
9873
- gstreamer1.0-plugins-base-apps
9974
- gstreamer1.0-pulseaudio
@@ -114,45 +89,62 @@ parts:
11489
- libxcb-cursor0
11590
# GPU
11691
- libglu1-mesa
117-
override-build: |
92+
override-build: |
93+
# Run default build commands
11894
craftctl default
119-
pip install poetry
120-
make translation_mo
121-
pip install .
95+
96+
# Update ctranslate to ensure it has no execstack issues
12297
pip uninstall -y ctranslate2
123-
pip install https://github.com/raivisdejus/CTranslate2-no-execstack/releases/download/v4.2.1/ctranslate2-4.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
98+
pip install ctranslate2==4.6.0
12499
125100
# Clean caches to reclaim space on CI
126101
apt-get autoremove -y
127102
apt-get clean
128103
pip cache purge
129-
echo "yes" | poetry cache clear --all .
130104
131-
# Build
132-
python3 build.py
133105
mkdir $CRAFT_PART_INSTALL/buzz
134106
cp $CRAFT_PART_BUILD/buzz/whisper_cpp.py $CRAFT_PART_INSTALL/buzz/
135107
cp $CRAFT_PART_BUILD/buzz/libwhisper.so $CRAFT_PART_INSTALL/buzz/
136-
after: [ desktop-qt5 ]
108+
109+
mkdir -p $SNAPCRAFT_PRIME/bin
110+
cp $CRAFT_PART_BUILD/flatpak/run-buzz.sh $SNAPCRAFT_PRIME/bin/run-buzz.sh
111+
chmod +x $SNAPCRAFT_PRIME/bin/run-buzz.sh
112+
113+
mkdir -p $SNAPCRAFT_PRIME/usr/share/applications/
114+
cp buzz.desktop $SNAPCRAFT_PRIME/usr/share/applications/buzz.desktop
137115
138-
desktop-file:
139-
plugin: dump
140-
source: .
141-
organize:
142-
buzz.desktop: usr/share/applications/buzz.desktop
116+
# This part removes all the files in this snap which already exist in
117+
# connected content and base snaps. Since these files will be available
118+
# at runtime from the content and base snaps, they do not need to be
119+
# included in this snap itself.
120+
#
121+
# More info: https://forum.snapcraft.io/t/reducing-the-size-of-desktop-snaps/17280#heading--cleanup-part
122+
cleanup:
123+
after: # Make this part run last; list all your other parts here
124+
- buzz
125+
- alsa-pulseaudio
126+
plugin: nil
127+
build-snaps: # List all content-snaps and base snaps you're using here
128+
- core22
129+
- gnome-42-2204-sdk
130+
override-prime: |
131+
set -eux
132+
for snap in core22 gnome-42-2204-sdk; do # List all content-snaps and base snaps you're using here
133+
cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$CRAFT_PRIME/{}" \;
134+
done
143135
144136
apps:
145137
buzz:
146-
command: bin/desktop-launch python3 -m buzz
138+
extensions: [gnome]
139+
command: bin/run-buzz.sh
147140
desktop: usr/share/applications/buzz.desktop
148141
environment:
149142
PATH: $SNAP/usr/bin:$SNAP/bin:$PATH
150-
LD_LIBRARY_PATH: $SNAP/lib/python3.10/site-packages/nvidia/cudnn/lib:$SNAP/lib/python3.10/site-packages/PyQt6:$SNAP/lib/python3.10/site-packages/PyQt6/Qt6/lib:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/lapack:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/blas:$SNAP:$LD_LIBRARY_PATH
151-
PYTHONPATH: $SNAP/lib/python3.10/site-packages/PyQt6:$SNAP/lib/python3.10/site-packages/PyQt6/Qt6/lib:$SNAP/usr/lib/python3/dist-packages:$SNAP/usr/lib/python3.10/site-packages:$SNAP/usr/local/lib/python3.10/dist-packages:$SNAP/usr/lib/python3.10/dist-packages:$PYTHONPATH
152-
# Fallback to XWayland if running in a Wayland session.
153-
DISABLE_WAYLAND: 1
154-
# Use GTK3 cursor theme, icon theme and open/save file dialogs.
155-
QT_QPA_PLATFORMTHEME: gtk3
143+
LD_LIBRARY_PATH: $SNAP/lib/python3.10/site-packages/nvidia/cudnn/lib:$SNAP/lib/python3.10/site-packages/PyQt6:$SNAP/lib/python3.10/site-packages/PyQt6/Qt6/lib:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/lapack:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/blas:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/pulseaudio:$SNAP:$LD_LIBRARY_PATH
144+
PYTHONPATH: $SNAP/lib/python3.10/site-packages/PyQt6:$SNAP/lib/python3.10/site-packages/PyQt6/Qt6/lib:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/pulseaudio:$SNAP/usr/lib/python3/dist-packages:$SNAP/usr/lib/python3.10/site-packages:$SNAP/usr/local/lib/python3.10/dist-packages:$SNAP/usr/lib/python3.10/dist-packages:$PYTHONPATH
145+
QT_QPA_PLATFORMTHEME: 'gnome'
146+
GTK_USE_PORTAL: '1'
147+
GDK_DEBUG: 'portals'
156148
QT_MEDIA_BACKEND: gstreamer
157149
ALSA_CONFIG_PATH: $SNAP/etc/asound.conf
158150
XDG_CONFIG_DIRS: $SNAP/etc/xdg:$XDG_CONFIG_DIRS

tests/gui_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
from .mock_qt import MockNetworkAccessManager, MockNetworkReply
3434

3535
if platform.system() == "Linux":
36-
multiprocessing.set_start_method("spawn")
36+
try:
37+
multiprocessing.set_start_method("spawn", force=True)
38+
except RuntimeError:
39+
pass
3740

3841

3942
@pytest.fixture(scope="module", autouse=True)

0 commit comments

Comments
 (0)