File speechnote.spec of Package speechnote
419
1
#
2
# spec file for package speechnote
3
#
4
# Copyright (c) 2025 SUSE LINUX GmbH, Nuernberg, Germany.
5
#
6
# All modifications and additions to the file contributed by third parties
7
# remain the property of their copyright owners, unless otherwise agreed
8
# upon. The license for this file, and modifications and additions to the
9
# file, is the same license as for the pristine package itself (unless the
10
# license for the pristine package is not an Open Source License, in which
11
# case the license is the MIT License). An "Open Source License" is a
12
# license that conforms to the Open Source Definition (Version 1.9)
13
# published by the Open Source Initiative.
14
15
# Please submit bugfixes or comments via http://bugs.opensuse.org/
16
#
17
18
%define aname dsnote
19
%define __provides_exclude ^(libRHVoice.*\\.so.*|libaprilasr\\.so.*|libbergamot_api.*\\.so.*|libclblast\\.so.*|libespeak-ng\\.so.*|libkenlm\\.so.*|libonnxruntime\\.so.*|libstt\\.so.*|libtensorflowlite\\.so.*|libtflitedelegates\\.so.*|libvosk\\.so.*|libwhisper-.*\\.so.*|mimehandler\\(.*|perl\\(.*)$
20
%define __requires_exclude ^(libRHVoice.*\\.so.*|libaprilasr\\.so.*|libbergamot_api.*\\.so.*|libclblast\\.so.*|libespeak-ng\\.so.*|libkenlm\\.so.*|libonnxruntime\\.so.*|libstt\\.so.*|libtensorflowlite\\.so.*|libtflitedelegates\\.so.*|libvosk\\.so.*|libwhisper-.*\\.so.*|libamdhip64\\.so.*|libhipblas\\.so.*|librocblas\\.so.*)$
21
22
%define pythons python312
23
%if 0%{?suse_version} < 1600
24
%define isLeap15 %nil
25
%else
26
%undefine isLeap15
27
%endif
28
%if 0%{?suse_version} == 1600
29
%define isLeap16 %nil
30
%else
31
%undefine isLeap16
32
%endif
33
34
%bcond_with mkl
35
%bcond_with download
36
%if %{defined isLeap15}
37
%bcond_with system_pybind11
38
%else
39
%bcond_without system_pybind11
40
%endif
41
42
Name: speechnote
43
Version: 4.8.1
44
Release: 0
45
Summary: App for note taking, reading and translating
46
URL: https://github.com/mkiol/dsnote
47
License: MPL-2.0
48
Group: Productivity/Office/Other
49
Source: %aname-%version.tar.gz
50
Source1: sources.tar.zst
51
Source2: pythonbasic.tar
52
Source3: CTranslate2-v4.3.1.tar.zst
53
Source4: rhvoice-846293.tar.zst
54
Source5: bergamot-ada8c3.tar.zst
55
Source6: pythonmodules1.tar.zst
56
Source7: pythonmodules2.tar.zst
57
Source8: %name.rpmlintrc
58
Source9: README.SUSE
59
BuildRequires: cmake
60
BuildRequires: gcc-c++
61
BuildRequires: cmake(Qt5LinguistTools)
62
BuildRequires: cmake(Qt5Multimedia)
63
BuildRequires: cmake(Qt5Xml)
64
BuildRequires: cmake(Qt5Sql)
65
BuildRequires: cmake(Qt5QuickControls2)
66
BuildRequires: cmake(Qt5X11Extras)
67
BuildRequires: libQt5Gui-private-headers-devel
68
BuildRequires: extra-cmake-modules
69
%if %{defined isLeap15}
70
BuildRequires: meson
71
BuildRequires: bison
72
BuildRequires: pkgconfig(libxml-2.0)
73
%else
74
BuildRequires: pkgconfig(xkbcommon-x11) >= 1.6
75
%endif
76
BuildRequires: cmake(KF5DBusAddons)
77
BuildRequires: git-core
78
BuildRequires: %{python_module devel}
79
BuildRequires: AppStream
80
BuildRequires: libXtst-devel
81
BuildRequires: libXinerama-devel
82
83
BuildRequires: libopenblas_pthreads-devel
84
BuildRequires: libarchive-devel
85
BuildRequires: fmt-devel
86
BuildRequires: xz-devel
87
%if %{with system_pybind11}
88
BuildRequires: %{python_module pybind11-devel}
89
%endif
90
BuildRequires: librubberband-devel
91
BuildRequires: libtag-devel
92
BuildRequires: libnumbertext-devel
93
BuildRequires: libtool
94
BuildRequires: ocl-icd-devel
95
%if %{defined isLeap15}
96
BuildRequires: libboost_headers1_75_0-devel
97
%else
98
%if %{defined isLeap16}
99
BuildRequires: libboost_headers1_86_0-devel
100
%else
101
BuildRequires: libboost_headers-devel
102
%endif
103
%endif
104
BuildRequires: chrpath
105
BuildRequires: dos2unix
106
BuildRequires: fdupes
107
BuildRequires: site-config
108
BuildRequires: yq
109
BuildRequires: wget
110
BuildRequires: %{python_module pip}
111
BuildRequires: %{python_module wheel}
112
BuildRequires: %{python_module setuptools}
113
%if %{with system_pybind11}
114
BuildRequires: %{python_module Cython}
115
BuildRequires: %{python_module six}
116
BuildRequires: %{python_module Markdown}
117
BuildRequires: %{python_module Pygments}
118
%endif
119
BuildRequires: zstd
120
BuildRequires: zip
121
BuildRequires: unzip
122
BuildRequires: patchelf
123
BuildRequires: onednn-devel
124
%if %{with mkl}
125
BuildRequires: intel-oneapi-mkl-devel
126
%endif
127
128
Recommends: %{name}-python-modules = %{version}
129
ExclusiveArch: x86_64
130
131
%description
132
Speech Note let you take, read and translate notes in multiple languages.
133
It uses Speech to Text, Text to Speech and Machine Translation to do so.
134
Text and voice processing take place entirely offline, locally on your
135
computer, without using a network connection.
136
137
%package python-modules
138
Summary: Extra python modules
139
Requires: %{name} = %{version}
140
Requires: libdnnl3
141
Requires: %pythons
142
Requires: %pythons-setuptools
143
%if %{with system_pybind11}
144
Requires: %pythons-six
145
Requires: %pythons-Pygments
146
%endif
147
AutoReqProv: no
148
149
%description python-modules
150
Python modules for %name
151
152
153
%prep
154
%setup -q -n %{aname}-%{version}
155
%if %{without download}
156
#do not download libsst
157
sed -i '/DOWNLOAD/d' cmake/libstt.cmake
158
%endif
159
160
mkdir build build/aux external external/pythonsrc
161
162
%if %{without download}
163
#sources
164
tar fx %SOURCE1 -C build
165
166
#rhvoice
167
tar fx %SOURCE4 -C external
168
sed -i '/GIT_REPOSITORY/d;/GIT_TAG/d;/GIT_SHALLOW/d' cmake/rhvoice.cmake
169
170
#bergamot
171
tar fx %SOURCE5 -C external
172
mv external/bergamot external/bergamotfallback
173
tar fx %SOURCE5 -C external
174
sed -i '/GIT_REPOSITORY/d;/GIT_TAG/d;/GIT_SHALLOW/d' cmake/bergamot.cmake
175
%endif
176
#endif without download
177
178
srcdownload () {
179
local n i URL DEST SHA256
180
! yq '.modules[] | explode(.) | select(.name == "'$2'" )' $3 | grep -qF 'sources:' && return
181
n=$(yq '.modules[] | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources' | grep -c -e ^-)
182
if ((n)); then
183
for ((i=0;i<n;i++)) ; do
184
case $(yq '.modules[] | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources['$i'].type') in
185
git)
186
git -C $1 clone --recursive $(yq '.modules[] | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources['$i'].url')
187
pushd $1/* >/dev/null
188
git checkout $(yq '.modules[] | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources['$i'].commit')
189
popd >/dev/null
190
;;
191
file|archive)
192
URL=$(yq '.modules[] | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources['$i'].url')
193
DEST=$(yq '.modules[] | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources['$i'].dest-filename')
194
[[ $DEST = null ]] && DEST=${URL##*/}
195
SHA256=$(yq '.modules[] | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources['$i'].sha256')
196
[[ ! -f $1/$DEST ]] && wget -q -O $1/$DEST $URL
197
[[ $(sha256sum $1/$DEST | cut -f1 -d" ") = $SHA256 ]]
198
;;&
199
archive)
200
tar fx $1/$DEST -C $1 && mv $1/$DEST $1/..
201
;;
202
shell)
203
pushd $1 >/dev/null
204
eval $(yq '.modules[] | explode(.) | select(.name == "'$2'" )' $3 | yq '.sources['$i'].commands' | grep -v '^- |' | sed 's@$@;@')
205
rm -rf tmp #fix for 1.8.0
206
popd >/dev/null
207
;;
208
patch|file) : ;;
209
*) echo "yq: unknown type" ; exit 1 ;;
210
esac
211
done
212
fi
213
}
214
215
#ctranslate2
216
%if %{with download}
217
srcdownload build/aux ctranslate2 $PWD/flatpak/net.mkiol.SpeechNote.yaml
218
%else
219
tar fx %SOURCE3 -C build/aux
220
%endif
221
222
223
#pythonmodules
224
%if %{with download}
225
for m in $(yq '.modules[].name | explode(.)' flatpak/python3-modules-x86-64.yaml) ; do
226
srcdownload external/pythonsrc $m $PWD/flatpak/python3-modules-x86-64.yaml
227
done
228
%else
229
%if %{without system_pybind11}
230
tar fx %SOURCE2 -C external/pythonsrc
231
%endif
232
tar fx %SOURCE6 -C external/pythonsrc
233
tar fx %SOURCE7 -C external/pythonsrc
234
%endif
235
236
cp %SOURCE9 .
237
238
#rpath /usr/share/dsnote/lib
239
sed -i '/-rpath/s@/lib@/share/%{aname}&@' CMakeLists.txt
240
241
242
%build
243
%if %{with system_pybind11}
244
export PKG_CONFIG_PATH=%{python_sitelib}/pybind11/share/pkgconfig
245
%endif
246
247
%cmake \
248
-DCMAKE_BUILD_TYPE=Release \
249
-DWITH_DESKTOP=ON \
250
%if %{defined isLeap15}
251
-DBUILD_XKBCOMMON=ON \
252
%endif
253
\
254
-DBUILD_WHISPERCPP_CLBLAST=ON \
255
-DBUILD_WHISPERCPP_VULKAN=ON \
256
-DBUILD_OPENBLAS=OFF \
257
-DBUILD_LIBARCHIVE=OFF \
258
-DBUILD_XZ=OFF \
259
-DBUILD_FMT=OFF \
260
-DBUILD_RUBBERBAND=OFF \
261
-DBUILD_LIBNUMBERTEXT=OFF \
262
%if %{with system_pybind11}
263
-DBUILD_PYBIND11=OFF \
264
%else
265
-DBUILD_PYBIND11=ON \
266
%endif
267
-DBUILD_FFMPEG=ON \
268
-DBUILD_TAGLIB=OFF \
269
-DBUILD_ESPEAK=ON \
270
-DCMAKE_VERBOSE_MAKEFILE=OFF \
271
-Wno-dev
272
273
%cmake_build
274
275
276
cd aux/CTranslate2*
277
%cmake \
278
-DCMAKE_BUILD_TYPE=Release \
279
-DBUILD_CLI=OFF \
280
-DCUDA_DYNAMIC_LOADING=ON \
281
-DOPENMP_RUNTIME=COMP \
282
%if %{with mkl}
283
-DWITH_MKL=ON \
284
%else
285
-DWITH_MKL=OFF \
286
%endif
287
-DWITH_DNNL=ON \
288
-DWITH_RUY=ON \
289
-DCMAKE_CXX_FLAGS=-msse4.1 \
290
-DCMAKE_INSTALL_PREFIX=%{_datadir}/%{aname}/python/extensions/cpu \
291
%{nil}
292
293
%cmake_build
294
DESTDIR=$PWD/../tmpinst make install
295
cd ../python
296
sed -i '/^ldflags/s@=.*@= ["-Wl,-rpath,%_datadir/%{aname}/python/extensions/cpu/%{_lib}"]@' setup.py
297
%if %{with system_pybind11}
298
CTRANSLATE2_ROOT=$PWD/../tmpinst/%{_datadir}/%{aname}/python/extensions/cpu python%{python_version} setup.py bdist_wheel
299
%endif
300
cd ../../..
301
302
303
%install
304
%cmake_install
305
306
FLATPAK_DEST=%buildroot%{_datadir}/%{aname}/python
307
export PYTHONPATH=$FLATPAK_DEST/extensions/cpu/%{_lib}/python%{python_version}/site-packages:$FLATPAK_DEST/lib/python%{python_version}/site-packages:$FLATPAK_DEST/%{_lib}/python%{python_version}/site-packages
308
309
YAMLSRC=$PWD/flatpak/python3-modules-x86-64.yaml
310
[[ -f $YAMLSRC ]]
311
#make python3-unidic-fix work
312
sed -i '/ln -s/{s@/app/lib/python%{python_version}/site-packages@..@;s@/app/@$FLATPAK_DEST/@}' $YAMLSRC
313
MODSRCDIR=$PWD/external/pythonsrc
314
315
%if %{without system_pybind11}
316
pushd $MODSRCDIR >/dev/null
317
for a in pygments six markdown google_api_core cython ; do
318
pip3 install --verbose --exists-action=i --no-index --find-links=file://$PWD --prefix=${FLATPAK_DEST} --no-build-isolation $a
319
done
320
popd >/dev/null
321
%endif
322
323
modules=$(yq '.modules[].name' $YAMLSRC)
324
325
for m in $modules ; do
326
[[ $m = python3-pygments ]] && continue
327
DSBUILDFLAGS=
328
BUILDMOD=$PWD/python-modules
329
mkdir $BUILDMOD
330
pushd $MODSRCDIR >/dev/null
331
modsrc=$(yq '.modules[] | explode(.) | select(.name == "'$m'" )' $YAMLSRC | yq '.sources[].url' | sed 's@.*/@@;s@%2B@+@g')
332
for a in $modsrc ; do
333
[[ -f $a ]] && ln $a $BUILDMOD
334
done
335
popd >/dev/null
336
pushd $BUILDMOD >/dev/null
337
#build
338
%if ! ( %{defined isLeap15} || %{defined isLeap16} )
339
[[ $m = python3-mycroft_mimic3_tts ]] && DSBUILDFLAGS="CFLAGS=-Wno-error=incompatible-pointer-types"
340
%endif
341
eval $(yq '.modules[] | explode(.) | select(.name == "'$m'" )' $YAMLSRC | yq '.build-commands[]' | sed "s@python @python%{python_version} @;s@^pip3 @$DSBUILDFLAGS pip3 @;s@\$@;@")
342
#cleanup
343
eval $(yq '.modules[] | explode(.) | select(.name == "'$m'" )' $YAMLSRC | yq '.cleanup[]' | sed 's@^@rm -rf $FLATPAK_DEST@;s@/lib/@/lib*/@g;s@$@;@')
344
popd >/dev/null
345
rm -r $BUILDMOD
346
done
347
348
%if %{without system_pybind11}
349
cd external/pybind11
350
pip3 wheel --verbose --exists-action=i --no-index --no-build-isolation .
351
pip3 install --verbose --exists-action=i --no-index --find-links=file://$PWD --prefix=${FLATPAK_DEST} --no-build-isolation *.whl
352
cd ../..
353
%endif
354
355
YAMLSRC=$(dirname $YAMLSRC)/net.mkiol.SpeechNote.yaml
356
cd build/aux/CTranslate2*
357
%cmake_install
358
%if %{without system_pybind11}
359
cd python
360
CTRANSLATE2_ROOT=$PWD/../tmpinst/%{_datadir}/%{aname}/python/extensions/cpu python%{python_version} setup.py bdist_wheel
361
cd ..
362
%endif
363
( export PYTHONPATH=${FLATPAK_DEST}/extensions/cpu/%{_lib}/python%{python_version}/site-packages:$FLATPAK_DEST/lib/python%{python_version}/site-packages:$FLATPAK_DEST/%{_lib}/python%{python_version}/site-packages
364
rm -rf ${FLATPAK_DEST}/%{_lib}/python%{python_version}/site-packages/ctranslate2*
365
m=ctranslate2
366
#install
367
eval $(yq '.modules[] | explode(.) | select(.name == "'$m'" )' $YAMLSRC | yq '.post-install[]' | grep -A4 ^pip3 | sed 's@/lib/@/lib*/@g;s@$@;@')
368
#cleanup
369
eval $(yq '.modules[] | explode(.) | select(.name == "'$m'" )' $YAMLSRC | yq '.cleanup[]' | sed 's@^@rm -rf $FLATPAK_DEST@;s@/lib/@/lib*/@g;s@$@;@')
370
)
371
cd ../../..
372
373
rm -r $FLATPAK_DEST/lib{,64}/python%{python_version}/site-packages/__pycache__
374
rm -r $FLATPAK_DEST/lib/python%{python_version}/site-packages/pypinyin/__pycache__
375
rm -r $FLATPAK_DEST/%{_lib}/python%{python_version}/site-packages/pandas/tests
376
rm -r $FLATPAK_DEST/extensions/cpu/%{_lib}/python%{python_version}/site-packages/torch/{test,include}
377
rm $FLATPAK_DEST/%{_lib}/python%{python_version}/site-packages/numpy/*/lib/lib*.a
378
rm -f $FLATPAK_DEST/lib/python%{python_version}/site-packages/*.{txt,md}
379
380
find $FLATPAK_DEST -name ".gitignore" -exec rm {} \;
381
find $FLATPAK_DEST -name "*.so" -exec strip --strip-unneeded {} \;
382
find $FLATPAK_DEST -name "*.so.*" -exec strip --strip-unneeded {} \;
383
find $FLATPAK_DEST/extensions/cpu/%{_lib}/python%{python_version}/site-packages/torch -type f -perm -a+x -a ! -name "*.so.*" -exec strip --strip-unneeded {} \;
384
chmod a-x $FLATPAK_DEST/lib/python%{python_version}/site-packages/tensorboard/webfiles.zip
385
rm -r $FLATPAK_DEST/share
386
387
%fdupes %buildroot%_datadir/%{aname}/python
388
mv %buildroot%{_bindir}/%{aname} %buildroot%{_bindir}/%{aname}.exe
389
#main program script
390
SHPRE=%_datadir/%{aname}/python/extensions
391
SHPOST=%{_lib}/python%{python_version}/site-packages
392
echo -e "#!/bin/bash\n" >%buildroot%{_bindir}/%{aname}
393
echo -e "export ESPEAK_DATA_PATH=%{_datadir}/%{aname}/share/espeak-ng-data" >>%buildroot%{_bindir}/%{aname}
394
echo -e "export LD_LIBRARY_PATH=\${LD_LIBRARY_PATH:+\$LD_LIBRARY_PATH:}$SHPRE/cpu/%{_lib}\nexport PYTHONPATH=\${PYTHONPATH:+\$PYTHONPATH:}$SHPRE/cpu/$SHPOST" >>%buildroot%{_bindir}/%{aname}
395
echo -e 'export PYTHONPATH=$PYTHONPATH:%_datadir/%{aname}/python/lib/python%{python_version}/site-packages:%_datadir/%{aname}/python/'$SHPOST'\nexec %{aname}.exe "$@"' >>%buildroot%{_bindir}/%{aname}
396
chmod a+x %buildroot%{_bindir}/%{aname}
397
398
ln -s %aname %buildroot%{_bindir}/%{name}
399
400
export NO_BRP_CHECK_RPATH=true
401
402
%files
403
%doc README.md README.SUSE
404
%license LICENSE
405
%{_bindir}/%{name}
406
%{_bindir}/%{aname}
407
%{_bindir}/%{aname}.exe
408
%{_datadir}/applications/%{aname}.desktop
409
%{_datadir}/dbus-1/services/net.mkiol.%{aname}.service
410
%{_datadir}/icons/hicolor/*
411
%{_datadir}/metainfo/%{aname}.metainfo.xml
412
%{_datadir}/%{aname}
413
%exclude %{_datadir}/%{aname}/python
414
415
%files python-modules
416
%{_datadir}/%{aname}/python
417
418
%changelog
419