From 231a1d09448fdab3b2e81d8fbb8ce523e4b53cff Mon Sep 17 00:00:00 2001 From: Juho Hiltunen Date: Sat, 10 Mar 2018 10:13:20 +0200 Subject: [PATCH] headers: add new file dictionary.h with declarations of functions in dictionary.c --- src/libespeak-ng/compiledict.c | 1 + src/libespeak-ng/dictionary.c | 5 +-- src/libespeak-ng/dictionary.h | 56 +++++++++++++++++++++++++++++++++ src/libespeak-ng/numbers.c | 3 +- src/libespeak-ng/phoneme.h | 3 -- src/libespeak-ng/readclause.c | 1 + src/libespeak-ng/speech.c | 1 + src/libespeak-ng/synth_mbrola.c | 1 + src/libespeak-ng/synthesize.c | 1 + src/libespeak-ng/synthesize.h | 1 - src/libespeak-ng/translate.c | 5 +-- src/libespeak-ng/translate.h | 17 ---------- src/libespeak-ng/voices.c | 1 + 13 files changed, 70 insertions(+), 26 deletions(-) create mode 100644 src/libespeak-ng/dictionary.h diff --git a/src/libespeak-ng/compiledict.c b/src/libespeak-ng/compiledict.c index 7e5857c4..76499f6a 100644 --- a/src/libespeak-ng/compiledict.c +++ b/src/libespeak-ng/compiledict.c @@ -33,6 +33,7 @@ #include #include +#include "dictionary.h" #include "readclause.h" #include "error.h" diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index ae0157d9..f6bdf182 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -31,9 +31,10 @@ #include #include +#include "dictionary.h" +#include "numbers.h" #include "readclause.h" #include "synthdata.h" -#include "numbers.h" #include "speech.h" #include "phoneme.h" @@ -98,7 +99,7 @@ void strncpy0(char *to, const char *from, int size) } #pragma GCC visibility pop -int Reverse4Bytes(int word) +static int Reverse4Bytes(int word) { // reverse the order of bytes from little-endian to big-endian #ifdef ARCH_BIG diff --git a/src/libespeak-ng/dictionary.h b/src/libespeak-ng/dictionary.h new file mode 100644 index 00000000..cd08f1de --- /dev/null +++ b/src/libespeak-ng/dictionary.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2005 to 2015 by Jonathan Duddington + * email: jonsd@users.sourceforge.net + * Copyright (C) 2015-2018 Reece H. Dunn + * Copyright (C) 2018 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: . + */ + +#ifndef ESPEAK_NG_DICTIONARY_H +#define ESPEAK_NG_DICTIONARY_H + +#include "synthesize.h" +#include "translate.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +void strncpy0(char *to, const char *from, int size); +int LoadDictionary(Translator *tr, const char *name, int no_error); +int HashDictionary(const char *string); +const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme); +void DecodePhonemes(const char *inptr, char *outptr); +char *WritePhMnemonic(char *phon_out, PHONEME_TAB *ph, PHONEME_LIST *plist, int use_ipa, int *flags); +const char *GetTranslatedPhonemeString(int phoneme_mode); +int IsVowel(Translator *tr, int letter); +int Unpronouncable(Translator *tr, char *word, int posn); +void ChangeWordStress(Translator *tr, char *word, int new_stress); +void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int control); +void AppendPhonemes(Translator *tr, char *string, int size, const char *ph); +int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, char *end_phonemes, int word_flags, unsigned int *dict_flags); +int TransposeAlphabet(Translator *tr, char *text); +int Lookup(Translator *tr, const char *word, char *ph_out); +int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *flags, int end_flags, WORD_TAB *wtab); +int LookupFlags(Translator *tr, const char *word, unsigned int **flags_out); +int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/libespeak-ng/numbers.c b/src/libespeak-ng/numbers.c index 851f6165..c05efd90 100644 --- a/src/libespeak-ng/numbers.c +++ b/src/libespeak-ng/numbers.c @@ -31,8 +31,9 @@ #include #include -#include "readclause.h" +#include "dictionary.h" #include "numbers.h" +#include "readclause.h" #include "phoneme.h" #include "voice.h" diff --git a/src/libespeak-ng/phoneme.h b/src/libespeak-ng/phoneme.h index fd070763..b617b368 100644 --- a/src/libespeak-ng/phoneme.h +++ b/src/libespeak-ng/phoneme.h @@ -285,9 +285,6 @@ typedef struct { int LookupPhonemeString(const char *string); int PhonemeCode(unsigned int mnem); -const char *EncodePhonemes(const char *p, char *outptr, int *bad_phoneme); -void DecodePhonemes(const char *inptr, char *outptr); - extern const char *WordToString(unsigned int word); extern PHONEME_TAB_LIST phoneme_tab_list[N_PHONEME_TABS]; diff --git a/src/libespeak-ng/readclause.c b/src/libespeak-ng/readclause.c index 2a9cb1b1..b2f2876a 100644 --- a/src/libespeak-ng/readclause.c +++ b/src/libespeak-ng/readclause.c @@ -36,6 +36,7 @@ #include #include +#include "dictionary.h" #include "readclause.h" #include "error.h" diff --git a/src/libespeak-ng/speech.c b/src/libespeak-ng/speech.c index 0dfe3bdd..4186f65a 100644 --- a/src/libespeak-ng/speech.c +++ b/src/libespeak-ng/speech.c @@ -48,6 +48,7 @@ #include #include +#include "dictionary.h" #include "readclause.h" #include "speech.h" diff --git a/src/libespeak-ng/synth_mbrola.c b/src/libespeak-ng/synth_mbrola.c index 0b226ad0..4bab2160 100644 --- a/src/libespeak-ng/synth_mbrola.c +++ b/src/libespeak-ng/synth_mbrola.c @@ -32,6 +32,7 @@ #include #include +#include "dictionary.h" #include "readclause.h" #include "synthdata.h" diff --git a/src/libespeak-ng/synthesize.c b/src/libespeak-ng/synthesize.c index f12895e0..01755b36 100644 --- a/src/libespeak-ng/synthesize.c +++ b/src/libespeak-ng/synthesize.c @@ -32,6 +32,7 @@ #include #include +#include "dictionary.h" #include "intonation.h" #include "setlengths.h" #include "synthdata.h" diff --git a/src/libespeak-ng/synthesize.h b/src/libespeak-ng/synthesize.h index 5299174b..7ad2a625 100644 --- a/src/libespeak-ng/synthesize.h +++ b/src/libespeak-ng/synthesize.h @@ -513,7 +513,6 @@ int SelectPhonemeTableName(const char *name); int FormantTransition2(frameref_t *seq, int *n_frames, unsigned int data1, unsigned int data2, PHONEME_TAB *other_ph, int which); void Write4Bytes(FILE *f, int value); -int Reverse4Bytes(int word); #if HAVE_SONIC_H void DoSonicSpeed(int value); diff --git a/src/libespeak-ng/translate.c b/src/libespeak-ng/translate.c index c5a7278c..77abf6e5 100644 --- a/src/libespeak-ng/translate.c +++ b/src/libespeak-ng/translate.c @@ -32,9 +32,10 @@ #include #include -#include "readclause.h" -#include "phonemelist.h" +#include "dictionary.h" #include "numbers.h" +#include "phonemelist.h" +#include "readclause.h" #include "speech.h" #include "phoneme.h" diff --git a/src/libespeak-ng/translate.h b/src/libespeak-ng/translate.h index 2a272720..daa38f9a 100644 --- a/src/libespeak-ng/translate.h +++ b/src/libespeak-ng/translate.h @@ -689,7 +689,6 @@ extern int (*phoneme_callback)(const char *); extern void SetLengthMods(Translator *tr, int value); void LoadConfig(void); -int TransposeAlphabet(Translator *tr, char *text); #define LEADING_2_BITS 0xC0 // 0b11000000 #define UTF8_TAIL_BITS 0x80 // 0b10000000 @@ -709,39 +708,23 @@ void InitText2(void); int IsDigit(unsigned int c); int IsDigit09(unsigned int c); int IsAlpha(unsigned int c); -int IsVowel(Translator *tr, int c); int isspace2(unsigned int c); -const char *GetTranslatedPhonemeString(int phoneme_mode); ALPHABET *AlphabetFromChar(int c); Translator *SelectTranslator(const char *name); int SetTranslator2(const char *name); void DeleteTranslator(Translator *tr); void ProcessLanguageOptions(LANGUAGE_OPTIONS *langopts); -int Lookup(Translator *tr, const char *word, char *ph_out); -int LookupFlags(Translator *tr, const char *word, unsigned int **flags_out); - -void ChangeWordStress(Translator *tr, char *word, int new_stress); - -int LoadDictionary(Translator *tr, const char *name, int no_error); -int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *flags, int end_flags, WORD_TAB *wtab); -int HashDictionary(const char *string); void print_dictionary_flags(unsigned int *flags, char *buf, int buf_len); char *DecodeRule(const char *group_chars, int group_length, char *rule, int control); void ApplySpecialAttribute2(Translator *tr, char *phonemes, int dict_flags); -void AppendPhonemes(Translator *tr, char *string, int size, const char *ph); -int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy); -int Unpronouncable(Translator *tr, char *word, int posn); -void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int prev_stress); -int TranslateRules(Translator *tr, char *p, char *phonemes, int size, char *end_phonemes, int end_flags, unsigned int *dict_flags); int TranslateWord(Translator *tr, char *word1, WORD_TAB *wtab, char *word_out); void TranslateClause(Translator *tr, int *tone, char **voice_change); void SetVoiceStack(espeak_VOICE *v, const char *variant_name); -char *WritePhMnemonic(char *phon_out, PHONEME_TAB *ph, PHONEME_LIST *plist, int use_ipa, int *flags); extern FILE *f_trans; // for logging diff --git a/src/libespeak-ng/voices.c b/src/libespeak-ng/voices.c index db5f131e..9c3ceee9 100644 --- a/src/libespeak-ng/voices.c +++ b/src/libespeak-ng/voices.c @@ -38,6 +38,7 @@ #include #include +#include "dictionary.h" #include "readclause.h" #include "speech.h"