File parlatype-asr.patch of Package parlatype
From 9c07002d60d8e6a38889af4c7d704b555e22620f Mon Sep 17 00:00:00 2001
From: Gabor Karsay <gabor.karsay@gmx.at>
Date: Wed, 3 Nov 2021 19:54:59 +0100
Subject: [PATCH] Adapt to builds without ASR
Builds with pocketsphinx=false and deepspeech=false should not install
ASR files.
Install less help screenshots: ASR help pages were already skipped and
help screenshots not shown, so don't install them in the first place.
Don't show the ASR tab in the Preferenes dialog because it gives the
wrong impression that ASR is available.
Fix #88
---
data/meson.build | 12 +++++++-----
help/meson.build | 12 +++++++-----
meson.build | 2 ++
src/pt-preferences.c | 7 ++++---
4 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/data/meson.build b/data/meson.build
index 86d345b..12e3c6c 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,9 +1,11 @@
subdir('icons')
-install_subdir(
- 'asr',
- install_dir: join_paths(datadir, meson.project_name())
-)
+if with_asr
+ install_subdir(
+ 'asr',
+ install_dir: join_paths(datadir, meson.project_name())
+ )
+endif
desktop_file = app_id + '.desktop'
i18n.merge_file(
@@ -57,4 +59,4 @@ configure_file(
install_dir: join_paths(datadir, 'dbus-1', 'services')
)
-meson.add_install_script('meson_post_install.py')
\ No newline at end of file
+meson.add_install_script('meson_post_install.py')
diff --git a/help/meson.build b/help/meson.build
index 197bd2c..c5ee62a 100644
--- a/help/meson.build
+++ b/help/meson.build
@@ -1,8 +1,4 @@
media = [
- 'figures/asr-setup-initial.png',
- 'figures/asr-setup-downloadable.png',
- 'figures/asr-setup-details.png',
- 'figures/asr-switch-to-asr.png',
'figures/parlatype-icon.png',
'figures/parlatype-prefs-asr.png',
'figures/parlatype-prefs-controls.png',
@@ -31,7 +27,13 @@ sources = [
'timestamps.page',
]
-if with_pocketsphinx or with_deepspeech
+if with_asr
+ media += [
+ 'figures/asr-setup-initial.png',
+ 'figures/asr-setup-downloadable.png',
+ 'figures/asr-setup-details.png',
+ 'figures/asr-switch-to-asr.png',
+ ]
sources += [
'asr.page',
'asr-setup.page',
diff --git a/meson.build b/meson.build
index 24f1a08..1a0c4b1 100644
--- a/meson.build
+++ b/meson.build
@@ -18,6 +18,7 @@ endif
with_pocketsphinx = get_option('pocketsphinx')
with_deepspeech = get_option('deepspeech')
+with_asr = with_pocketsphinx or with_deepspeech
prefix = get_option('prefix')
bindir = join_paths(prefix, get_option('bindir'))
@@ -36,6 +37,7 @@ conf.set_quoted('PACKAGE_NAME', meson.project_name())
conf.set_quoted('PACKAGE_URL', 'https://www.parlatype.org')
conf.set_quoted('APP_ID', app_id)
conf.set_quoted('ASR_DIR', join_paths(datadir, meson.project_name(), 'asr'))
+conf.set('HAVE_ASR', with_asr)
conf_input = configure_file(output: 'config.h.in', configuration: conf)
conf_inc = include_directories('.', 'libparlatype/src')
diff --git a/src/pt-preferences.c b/src/pt-preferences.c
index f4bc399..f7b7402 100644
--- a/src/pt-preferences.c
+++ b/src/pt-preferences.c
@@ -179,9 +179,6 @@ setup_non_wayland_env (PtPreferencesDialog *dlg)
static void
pt_preferences_dialog_init (PtPreferencesDialog *dlg)
{
- GtkWidget *asr_page;
- GtkWidget *asr_label;
-
dlg->priv = pt_preferences_dialog_get_instance_private (dlg);
dlg->priv->editor = g_settings_new (APP_ID);
dlg->priv->player = pt_player_new ();
@@ -301,10 +298,14 @@ pt_preferences_dialog_init (PtPreferencesDialog *dlg)
g_free (delimiter);
g_free (sep);
+#ifdef HAVE_ASR
+ GtkWidget *asr_page;
+ GtkWidget *asr_label;
asr_page = pt_prefs_asr_new (dlg->priv->editor, dlg->priv->player);
asr_label = gtk_label_new (_("Speech recognition"));
gtk_notebook_insert_page (GTK_NOTEBOOK (dlg->priv->notebook),
asr_page, asr_label, 3);
+#endif
}
static void