Skip to content

Commit e143b97

Browse files
committed
new command line options and dbus api
1 parent 7099a58 commit e143b97

29 files changed

+586
-266
lines changed

CMakeLists.txt

+39-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ set(info_dbus_speech_service "net.mkiol.Speech")
100100
set(info_dbus_speech_interface "net.mkiol.Speech")
101101
set(info_dbus_app_service "net.mkiol.dsnote")
102102
set(info_dbus_app_path "/net/mkiol/dsnote")
103+
set(info_dbus_app_interface "net.mkiol.dsnote")
103104
set(info_dbus_app_id ${id})
104105
set(info_id ${id})
105106
set(info_binary_id ${id})
@@ -112,12 +113,14 @@ if(WITH_SFOS)
112113
set(info_dbus_speech_interface "org.mkiol.Speech")
113114
set(info_dbus_app_service "org.mkiol.dsnote")
114115
set(info_dbus_app_path "/org/mkiol/dsnote")
116+
set(info_dbus_app_interface "org.mkiol.dsnote")
115117
set(info_binary_id "harbour-dsnote")
116118
set(info_app_icon_id "harbour-dsnote")
117119
endif()
118120
if(WITH_FLATPAK)
119121
set(info_dbus_app_service "net.mkiol.SpeechNote")
120122
set(info_dbus_app_path "/net/mkiol/SpeechNote")
123+
set(info_dbus_app_interface "net.mkiol.SpeechNote")
121124
set(info_dbus_app_id "SpeechNote")
122125
set(info_app_icon_id "net.mkiol.SpeechNote")
123126
endif()
@@ -256,6 +259,8 @@ set(dsnote_lib_sources
256259
${sources_dir}/dbus_speech_inf.h
257260
${sources_dir}/dbus_application_adaptor.cpp
258261
${sources_dir}/dbus_application_adaptor.h
262+
${sources_dir}/dbus_application_inf.cpp
263+
${sources_dir}/dbus_application_inf.h
259264
${sources_dir}/dbus_notifications_inf.cpp
260265
${sources_dir}/dbus_notifications_inf.h
261266
${sources_dir}/dirmodel.cpp
@@ -359,6 +364,7 @@ set(dsnote_lib_sources
359364
${sources_dir}/whisperspeech_engine.cpp
360365
${sources_dir}/audio_device_manager.cpp
361366
${sources_dir}/audio_device_manager.hpp
367+
${sources_dir}/cmd_options.hpp
362368
)
363369

364370
if(WITH_DESKTOP)
@@ -375,7 +381,40 @@ endif()
375381

376382
configure_file(config.h.in config.h)
377383

384+
set(dbus_dsnote_interface_file "${PROJECT_BINARY_DIR}/${info_dbus_app_interface}.xml")
385+
configure_file(${dbus_dir}/dsnote.xml.in ${dbus_dsnote_interface_file})
386+
find_package(Qt5 COMPONENTS DBus REQUIRED)
387+
388+
unset(qdbusxml2cpp_bin CACHE)
389+
find_program(qdbusxml2cpp_bin qdbusxml2cpp)
390+
if(${qdbusxml2cpp_bin} MATCHES "-NOTFOUND$")
391+
find_program(qdbusxml2cpp_bin qdbusxml2cpp-qt5)
392+
if(${qdbusxml2cpp_bin} MATCHES "-NOTFOUND$")
393+
message(FATAL_ERROR "qdbusxml2cpp not found but it is required")
394+
endif()
395+
endif()
396+
add_custom_command(
397+
OUTPUT dbus_dsnote_adaptor.h dbus_dsnote_adaptor.cpp
398+
COMMAND ${qdbusxml2cpp_bin} ${info_dbus_app_interface}.xml -m -a dbus_dsnote_adaptor -c DsnoteAdaptor
399+
DEPENDS ${info_dbus_app_interface}.xml
400+
COMMENT "generate dbus app adaptor sources"
401+
)
402+
qt5_generate_moc("${PROJECT_BINARY_DIR}/dbus_dsnote_adaptor.h" dbus_dsnote_adaptor.moc)
403+
macro_add_file_dependencies(dbus_dsnote_adaptor.cpp dbus_dsnote_adaptor.moc)
404+
add_custom_command(
405+
OUTPUT dbus_dsnote_inf.h dbus_dsnote_inf.cpp
406+
COMMAND ${qdbusxml2cpp_bin} ${info_dbus_app_interface}.xml -m -p dbus_dsnote_inf -c DsnoteDbusInterface
407+
DEPENDS ${info_dbus_app_interface}.xml
408+
COMMENT "generate dbus app inf sources"
409+
)
410+
qt5_generate_moc("${PROJECT_BINARY_DIR}/dbus_dsnote_inf.h" dbus_dsnote_inf.moc)
411+
macro_add_file_dependencies(dbus_dsnote_inf.cpp dbus_dsnote_inf.moc)
412+
list(APPEND dsnote_lib_sources
413+
dbus_dsnote_adaptor.cpp dbus_dsnote_adaptor.h
414+
dbus_dsnote_inf.cpp dbus_dsnote_inf.h)
415+
378416
add_library(dsnote_lib STATIC ${dsnote_lib_sources})
417+
set_property(TARGET dsnote_lib PROPERTY AUTOMOC ON)
379418

380419
# resources
381420

@@ -515,8 +554,6 @@ if(WITH_DESKTOP)
515554
list(APPEND deps_libs ${qhotkey_path})
516555
endif()
517556
endif()
518-
519-
include(${cmake_path}/kdbusservice.cmake)
520557
endif()
521558

522559
if(BUILD_PYTHON_MODULE)

cmake/install_desktop.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ else()
1313
install(FILES "${PROJECT_BINARY_DIR}/dbus_app.service" DESTINATION share/dbus-1/services RENAME ${info_binary_id}.service)
1414
endif()
1515

16-
install(FILES "${desktop_dir}/${info_binary_id}.svg" DESTINATION share/icons/hicolor/scalable/apps)
16+
install(FILES "${desktop_dir}/icons/${info_binary_id}.svg" DESTINATION share/icons/hicolor/scalable/apps)
1717
install(FILES "${desktop_dir}/icons/16x16/${info_binary_id}.png" DESTINATION share/icons/hicolor/16x16/apps)
1818
install(FILES "${desktop_dir}/icons/32x32/${info_binary_id}.png" DESTINATION share/icons/hicolor/32x32/apps)
1919
install(FILES "${desktop_dir}/icons/48x48/${info_binary_id}.png" DESTINATION share/icons/hicolor/48x48/apps)

cmake/kdbusservice.cmake

-10
This file was deleted.

config.h.in

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define APP_DBUS_APP_SERVICE "@info_dbus_app_service@"
2929
#define APP_DBUS_APP_PATH "@info_dbus_app_path@"
3030
#define APP_DBUS_APP_ID "@info_dbus_app_id@"
31+
#define APP_DBUS_APP_INTERFACE "@info_dbus_app_interface@"
3132
#define APP_TRANSLATORS_STR "@info_translators_str@"
3233
#define APP_LIBS_STR "@info_libs_str@"
3334
#define APP_CONF_VERSION "@info_conf_version@"

dbus/dsnote.xml.in

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
2+
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
3+
<node>
4+
<interface name="@info_dbus_app_interface@">
5+
<!-- Currently active STT model ID -->
6+
<property name="ActiveSttModelId" type="s" access="read" />
7+
<signal name="ActiveSttModelIdPropertyChanged">
8+
<arg name="activeSttModelId" type="s" direction="out" />
9+
</signal>
10+
11+
<!-- Currently active TTS model ID -->
12+
<property name="ActiveTtsModelId" type="s" access="read" />
13+
<signal name="ActiveTtsModelIdPropertyChanged">
14+
<arg name="activeTtsModelId" type="s" direction="out" />
15+
</signal>
16+
17+
<!-- State of the application. Supported states are:
18+
Unknown = 0,
19+
NotConfigured = 1,
20+
Busy = 2,
21+
Idle = 3,
22+
ListeningManual = 4,
23+
ListeningAuto = 5,
24+
TranscribingFile = 6,
25+
ListeningSingleSentence = 7,
26+
PlayingSpeech = 8,
27+
WritingSpeechToFile = 9,
28+
Translating = 10,
29+
RepairingText = 11,
30+
Importing = 20,
31+
Exporting = 21
32+
-->
33+
<property name="State" type="i" access="read" />
34+
<signal name="StatePropertyChanged">
35+
<arg name="state" type="i" direction="out" />
36+
</signal>
37+
38+
<!-- State of the current task. Supported states are:
39+
Idle = 0,
40+
SpeechDetected = 1,
41+
Processing = 2,
42+
Initializing = 3,
43+
SpeechPlaying = 4,
44+
SpeechPaused = 5,
45+
Cancelling = 6
46+
-->
47+
<property name="TaskState" type="i" access="read" />
48+
<signal name="TaskStatePropertyChanged">
49+
<arg name="state" type="i" direction="out" />
50+
</signal>
51+
52+
<!-- Invokes an action. Supported actions are:
53+
start-listening,
54+
start-listening-translate,
55+
start-listening-active-window,
56+
start-listening-translate-active-window,
57+
start-listening-clipboard,
58+
start-listening-translate-clipboard,
59+
stop-listening,
60+
start-reading,
61+
start-reading-clipboard,
62+
start-reading-text,
63+
pause-resume-reading,
64+
cancel,
65+
switch-to-next-stt-model,
66+
switch-to-prev-stt-model,
67+
switch-to-next-tts-model,
68+
switch-to-prev-tts-model,
69+
set-stt-model,
70+
set-tts-model
71+
-->
72+
<method name="InvokeAction">
73+
<arg name="action_name" type="s" direction="in" />
74+
<!-- optional argument (e.g. model-id, text to read) -->
75+
<arg name="argument" type="s" direction="in" />
76+
</method>
77+
78+
<!-- Returns available STT model IDs -->
79+
<method name="GetSttModelIds">
80+
<arg name="models" type="as" direction="out" />
81+
</method>
82+
83+
<!-- Returns available TTS model IDs -->
84+
<method name="GetTtsModelIds">
85+
<arg name="models" type="as" direction="out" />
86+
</method>
87+
</interface>
88+
</node>
89+

desktop/dsnote.metainfo.xml.in

+4-1
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,12 @@
103103
<p>General:</p>
104104
<ul>
105105
<li>Rules for text transformations that can be applied after Speech to Text or before Text to Speech.
106-
With Rules, you can easily and flexibly correct errors in decoded text or correct mispronounced words.
106+
With Rules, you can easily and flexibly correct errors in decoded text or correct mispronounced words.</li>
107107
<li>New modes for inserting text at the cursor position or replacing the current note.
108108
To insert text at the cursor position rather than at the end of the note,
109109
change 'Text appending mode' option to 'Add at the cursor position' in the settings.
110110
When the 'Replace an existing note' option is set, whenever new text is added, it will replace the existing note.</li>
111+
<li>DBus API for integration with external applications</li>
111112
</ul>
112113
<p>User Interface:</p>
113114
<ul>
@@ -116,6 +117,8 @@
116117
When using the system tray icon, statuses such as processing, listening, etc. are presented with an animated tray icon.</li>
117118
<li>Models grouped by type in model browser.
118119
To improve usability, instead of a list containing models of all types, models are grouped by type in separate tabs.</li>
120+
<li>Command line options for printing available or active model IDs.</li>
121+
<li>Command line option to print the current status of the application.</li>
119122
</ul>
120123
<p>Speech to Text:</p>
121124
<ul>

desktop/qml/ChangelogPage.qml

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ DialogPage {
2727
To insert text at the cursor position rather than at the end of the note,
2828
change <i>Text appending mode</i> option to <i>Add at the cursor position</i> in the settings.
2929
When the <i>Replace an existing note</i> option is set, whenever new text is added, it will replace the existing note.</li>
30+
<li>DBus API for integration with external applications</li>
3031
</ul>
3132
<p>" + qsTr("User Interface") + ":</p>
3233
<ul>
@@ -36,6 +37,13 @@ DialogPage {
3637
<li>Models grouped by type in model browser.
3738
To improve usability, instead of a list containing models of all types, models are grouped by type in separate tabs.</li>
3839
<li>New <i>General</i> and <i>Advanced</i> tabs have been added to <i>Settings</i>.</li>
40+
<li>Command line options for printing available or active model IDs.
41+
Use <i>--print-available-models</i> or <i>--print-active-models</i> to list all available model IDs or the currently active model IDs.</li>
42+
<li>Command line option to print the current status of the application.
43+
Use <i>--print-state</i> to see the current state.
44+
This option can be useful when integrating with external programs or widgets on the desktop.
45+
To see all available command line options, run the command: <i>" + (_settings.is_flatpak() ? "flatpak run net.mkiol.SpeechNote" : "dsnote") + " --help</i></li>
46+
</li>
3947
</ul>
4048
<p>" + qsTr("Speech to Text") + ":</p>
4149
<ul>

desktop/qml/main.qml

+5-13
Original file line numberDiff line numberDiff line change
@@ -490,21 +490,13 @@ ApplicationWindow {
490490
onStt_configuredChanged: showWelcome()
491491
onTts_configuredChanged: showWelcome()
492492
Component.onCompleted: {
493+
// register app in dbus server
494+
_app_server.setDsnoteApp(app)
495+
493496
if (_start_in_tray) show_tray()
494-
if (_files_to_open.length > 0) {
495-
appWin.show()
496-
497-
if (app.note.length > 0 && _settings.file_import_action === Settings.FileImportActionAsk) {
498-
var list_of_files = _files_to_open
499-
addTextDialog.addHandler = function(){app.import_files(list_of_files, false)}
500-
addTextDialog.replaceHandler = function(){app.import_files(list_of_files, true)}
501-
addTextDialog.open()
502-
} else {
503-
app.import_files(_files_to_open, _settings.file_import_action === Settings.FileImportActionReplace)
504-
}
505-
}
506-
app.execute_action_name(_requested_action, _requested_extra)
497+
507498
app.set_app_window(appWin);
499+
508500
showWelcome()
509501
}
510502

flatpak/net.mkiol.SpeechNote-tiny.yaml

-37
Original file line numberDiff line numberDiff line change
@@ -571,43 +571,6 @@ modules:
571571
- type: patch
572572
path: ../patches/whispercpp.patch
573573

574-
# - name: shaderc
575-
# only-arches:
576-
# - x86_64
577-
# buildsystem: cmake-ninja
578-
# builddir: true
579-
# config-opts:
580-
# - -DCMAKE_BUILD_TYPE=Release
581-
# - -DSHADERC_SKIP_COPYRIGHT_CHECK=ON
582-
# - -DSHADERC_SKIP_EXAMPLES=ON
583-
# - -DSHADERC_SKIP_TESTS=ON
584-
# - -DSPIRV_SKIP_EXECUTABLES=ON
585-
# - -DENABLE_GLSLANG_BINARIES=OFF
586-
# cleanup:
587-
# - /bin
588-
# - /include
589-
# - /lib
590-
# sources:
591-
# - type: git
592-
# url: https://github.com/google/shaderc.git
593-
# tag: v2024.1
594-
# commit: 47a9387ef5b3600d30d84c71ec77a59dc7db46fa
595-
# - type: git
596-
# url: https://github.com/KhronosGroup/SPIRV-Tools.git
597-
# tag: v2024.3
598-
# commit: 0cfe9e7219148716dfd30b37f4d21753f098707a
599-
# dest: third_party/spirv-tools
600-
# - type: git
601-
# url: https://github.com/KhronosGroup/SPIRV-Headers.git
602-
# tag: vulkan-sdk-1.3.290.0
603-
# commit: 2acb319af38d43be3ea76bfabf3998e5281d8d12
604-
# dest: third_party/spirv-headers
605-
# - type: git
606-
# url: https://github.com/KhronosGroup/glslang.git
607-
# tag: 14.3.0
608-
# commit: fa9c3deb49e035a8abcabe366f26aac010f6cbfb
609-
# dest: third_party/glslang
610-
611574
- name: whispercpp-vulkan
612575
buildsystem: cmake-ninja
613576
config-opts:

0 commit comments

Comments
 (0)