diff --git a/Makefile.am b/Makefile.am
index 462220d5..73f66f3a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -165,6 +165,7 @@ src_libespeak_ng_la_SOURCES = \
src/libespeak-ng/espeak_api.c \
src/libespeak-ng/ieee80.c \
src/libespeak-ng/intonation.c \
+ src/libespeak-ng/langopts.c \
src/libespeak-ng/mnemonics.c \
src/libespeak-ng/numbers.c \
src/libespeak-ng/readclause.c \
@@ -195,6 +196,7 @@ noinst_HEADERS = \
src/libespeak-ng/ieee80.h \
src/libespeak-ng/intonation.h \
src/libespeak-ng/klatt.h \
+ src/libespeak-ng/langopts.h \
src/libespeak-ng/mbrola.h \
src/libespeak-ng/mbrowrap.h \
src/libespeak-ng/mnemonics.h \
diff --git a/android/jni/Android.mk b/android/jni/Android.mk
index c88f52f7..209641d1 100644
--- a/android/jni/Android.mk
+++ b/android/jni/Android.mk
@@ -30,6 +30,7 @@ ESPEAK_SOURCES := \
src/libespeak-ng/ieee80.c \
src/libespeak-ng/intonation.c \
src/libespeak-ng/klatt.c \
+ src/libespeak-ng/langopts.c \
src/libespeak-ng/mnemonics.c \
src/libespeak-ng/numbers.c \
src/libespeak-ng/phoneme.c \
diff --git a/src/libespeak-ng/langopts.c b/src/libespeak-ng/langopts.c
new file mode 100644
index 00000000..6b4dc6e6
--- /dev/null
+++ b/src/libespeak-ng/langopts.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2005 to 2015 by Jonathan Duddington
+ * email: jonsd@users.sourceforge.net
+ * Copyright (C) 2015-2017 Reece H. Dunn
+ * Copyright (C) 2022 Juho Hiltunen
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see: .
+ */
+
+#include "config.h"
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include "langopts.h"
+#include "mnemonics.h" // for MNEM_TAB
+#include "translate.h" // for Translator
+#include "voice.h" // for CheckTranslator()
+
+enum {
+ V_NAME = 1,
+ V_LANGUAGE,
+ V_GENDER,
+ V_PHONEMES,
+ V_DICTIONARY,
+ V_VARIANTS,
+
+ V_MAINTAINER,
+ V_STATUS,
+
+ // these affect voice quality, are independent of language
+ V_FORMANT,
+ V_PITCH,
+ V_ECHO,
+ V_FLUTTER,
+ V_ROUGHNESS,
+ V_CLARITY,
+ V_TONE,
+ V_VOICING,
+ V_BREATH,
+ V_BREATHW,
+
+ // these override defaults set by the translator
+ V_LOWERCASE_SENTENCE,
+ V_WORDGAP,
+ V_INTONATION,
+ V_TUNES,
+ V_STRESSLENGTH,
+ V_STRESSAMP,
+ V_STRESSADD,
+ V_DICTRULES,
+ V_STRESSRULE,
+ V_STRESSOPT,
+ V_NUMBERS,
+
+ V_MBROLA,
+ V_KLATT,
+ V_FAST,
+ V_SPEED,
+ V_DICTMIN,
+
+ // these need a phoneme table to have been specified
+ V_REPLACE,
+ V_CONSONANTS
+};
+
+static const MNEM_TAB langopts_tab[] = {
+ { "maintainer", V_MAINTAINER },
+ { "status", V_STATUS },
+ { "lowercaseSentence", V_LOWERCASE_SENTENCE },
+
+ { NULL, 0 }
+};
+
+extern int CheckTranslator(Translator *tr, const MNEM_TAB *keyword_tab, int key);
+
+void LoadLanguageOptions(Translator *translator, int key ) {
+ switch (key)
+ {
+ case V_LOWERCASE_SENTENCE: {
+ if (CheckTranslator(translator, langopts_tab, key) != 0)
+ break;
+
+ translator->langopts.lowercase_sentence = true;
+ break;
+ }
+
+ break;
+ case V_MAINTAINER:
+ case V_STATUS:
+ break;
+ }
+}
diff --git a/src/libespeak-ng/voice.h b/src/libespeak-ng/voice.h
index 04f1e9e4..610e77ed 100644
--- a/src/libespeak-ng/voice.h
+++ b/src/libespeak-ng/voice.h
@@ -22,6 +22,9 @@
#include
+#include "mnemonics.h"
+#include "translate.h"
+
#ifdef __cplusplus
extern "C"
{
@@ -81,6 +84,7 @@ extern espeak_VOICE current_voice_selected;
extern voice_t *voice;
extern int tone_points[12];
+int CheckTranslator(Translator *tr, const MNEM_TAB *keyword_tab, int key);
const char *SelectVoice(espeak_VOICE *voice_select, int *found);
espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name);
voice_t *LoadVoice(const char *voice_name, int control);
diff --git a/src/libespeak-ng/voices.c b/src/libespeak-ng/voices.c
index fd2ad538..570fac0a 100644
--- a/src/libespeak-ng/voices.c
+++ b/src/libespeak-ng/voices.c
@@ -41,6 +41,7 @@
#include "voice.h" // for voice_t, DoVoiceChange, N_PEAKS
#include "common.h" // for GetFileLength, strncpy0
#include "dictionary.h" // for LoadDictionary
+#include "langopts.h" // for LoadLanguageOptions
#include "mnemonics.h" // for LookupMnemName, MNEM_TAB
#include "phoneme.h" // for REPLACE_PHONEMES, n_replace_pho...
#include "speech.h" // for PATHSEP
@@ -50,6 +51,8 @@
#include "translate.h" // for LANGUAGE_OPTIONS, DeleteTranslator
#include "wavegen.h" // for InitBreath
+
+
static const MNEM_TAB genders[] = {
{ "male", ENGENDER_MALE },
{ "female", ENGENDER_FEMALE },
@@ -501,7 +504,7 @@ static void ReadNumbers(char *p, int *flags, int maxValue, const MNEM_TAB *keyw
}
}
-static int CheckTranslator(Translator *tr, const MNEM_TAB *keyword_tab, int key)
+int CheckTranslator(Translator *tr, const MNEM_TAB *keyword_tab, int key)
{
// Return 0 if translator is set.
// Return 1 and print an error message for specified key if not
@@ -629,6 +632,7 @@ voice_t *LoadVoice(const char *vname, int control)
key = LookupMnem(keyword_tab, buf);
+ LoadLanguageOptions(translator, key);
switch (key)
{
case V_LANGUAGE:
@@ -693,14 +697,6 @@ voice_t *LoadVoice(const char *vname, int control)
case V_FORMANT:
VoiceFormant(p);
break;
- case V_LOWERCASE_SENTENCE: {
- if (CheckTranslator(translator, keyword_tab, key) != 0)
- break;
-
- translator->langopts.lowercase_sentence = true;
- break;
- }
-
case V_PITCH:
// default is pitch 82 118
if (sscanf(p, "%d %d", &pitch1, &pitch2) == 2) {
diff --git a/src/windows/libespeak-ng.vcxproj b/src/windows/libespeak-ng.vcxproj
index 8812d016..1ea3935d 100644
--- a/src/windows/libespeak-ng.vcxproj
+++ b/src/windows/libespeak-ng.vcxproj
@@ -177,6 +177,7 @@
+
@@ -210,6 +211,7 @@
+
@@ -232,4 +234,4 @@
-
\ No newline at end of file
+
diff --git a/src/windows/libespeak-ng.vcxproj.filters b/src/windows/libespeak-ng.vcxproj.filters
index 74b04244..b60291ae 100644
--- a/src/windows/libespeak-ng.vcxproj.filters
+++ b/src/windows/libespeak-ng.vcxproj.filters
@@ -90,6 +90,9 @@
Source Files
+
+ Source Files
+
Source Files
@@ -197,6 +200,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -227,4 +233,4 @@
Source Files
-
\ No newline at end of file
+