The switch case in LoadVoice() currently mixes voice and language options. This change will start separating them into two functions. CheckTranslator will be moved to langopts.c. In the future there should be no need to use it in voices.c. There will be other temporary solutions also.master
@@ -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 \ |
@@ -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 \ |
@@ -0,0 +1,110 @@ | |||
/* | |||
* Copyright (C) 2005 to 2015 by Jonathan Duddington | |||
* email: [email protected] | |||
* 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: <http://www.gnu.org/licenses/>. | |||
*/ | |||
#include "config.h" | |||
#include <errno.h> | |||
#include <stdint.h> | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
#include <espeak-ng/espeak_ng.h> | |||
#include <espeak-ng/speak_lib.h> | |||
#include <espeak-ng/encoding.h> | |||
#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; | |||
} | |||
} |
@@ -22,6 +22,9 @@ | |||
#include <espeak-ng/espeak_ng.h> | |||
#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); |
@@ -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) { |
@@ -177,6 +177,7 @@ | |||
<ClCompile Include="..\libespeak-ng\ieee80.c" /> | |||
<ClCompile Include="..\libespeak-ng\intonation.c" /> | |||
<ClCompile Include="..\libespeak-ng\klatt.c" /> | |||
<ClCompile Include="..\libespeak-ng\langopts.c" /> | |||
<ClCompile Include="..\libespeak-ng\mbrowrap.c" /> | |||
<ClCompile Include="..\libespeak-ng\mnemonics.c" /> | |||
<ClCompile Include="..\libespeak-ng\numbers.c" /> | |||
@@ -210,6 +211,7 @@ | |||
<ClInclude Include="..\libespeak-ng\common.h" /> | |||
<ClInclude Include="..\libespeak-ng\error.h" /> | |||
<ClInclude Include="..\libespeak-ng\klatt.h" /> | |||
<ClInclude Include="..\libespeak-ng\langopts.h" /> | |||
<ClInclude Include="..\libespeak-ng\mbrowrap.h" /> | |||
<ClInclude Include="..\libespeak-ng\phoneme.h" /> | |||
<ClInclude Include="..\libespeak-ng\sintab.h" /> | |||
@@ -232,4 +234,4 @@ | |||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | |||
<ImportGroup Label="ExtensionTargets"> | |||
</ImportGroup> | |||
</Project> | |||
</Project> |
@@ -90,6 +90,9 @@ | |||
<ClCompile Include="..\libespeak-ng\klatt.c"> | |||
<Filter>Source Files</Filter> | |||
</ClCompile> | |||
<ClCompile Include="..\libespeak-ng\langopts.c"> | |||
<Filter>Source Files</Filter> | |||
</ClCompile> | |||
<ClCompile Include="..\libespeak-ng\mbrowrap.c"> | |||
<Filter>Source Files</Filter> | |||
</ClCompile> | |||
@@ -197,6 +200,9 @@ | |||
<ClInclude Include="..\libespeak-ng\klatt.h"> | |||
<Filter>Header Files</Filter> | |||
</ClInclude> | |||
<ClInclude Include="..\libespeak-ng\langopts.h"> | |||
<Filter>Header Files</Filter> | |||
</ClInclude> | |||
<ClInclude Include="..\libespeak-ng\mbrowrap.h"> | |||
<Filter>Header Files</Filter> | |||
</ClInclude> | |||
@@ -227,4 +233,4 @@ | |||
<Filter>Source Files</Filter> | |||
</None> | |||
</ItemGroup> | |||
</Project> | |||
</Project> |