diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index 250b78b3..e149eec4 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -35,6 +35,10 @@ #include #include +#include "readclause.h" +#include "synthdata.h" +#include "wavegen.h" + #include "error.h" #include "phoneme.h" #include "voice.h" diff --git a/src/libespeak-ng/compiledict.c b/src/libespeak-ng/compiledict.c index 2a472f49..34e8b5ec 100644 --- a/src/libespeak-ng/compiledict.c +++ b/src/libespeak-ng/compiledict.c @@ -33,6 +33,10 @@ #include #include +#include "compiledict.h" +#include "dictionary.h" +#include "readclause.h" + #include "error.h" #include "speech.h" #include "phoneme.h" @@ -40,8 +44,6 @@ #include "synthesize.h" #include "translate.h" -extern void Write4Bytes(FILE *f, int value); - static FILE *f_log = NULL; extern char *dir_dictionary; diff --git a/src/libespeak-ng/compiledict.h b/src/libespeak-ng/compiledict.h new file mode 100644 index 00000000..949db679 --- /dev/null +++ b/src/libespeak-ng/compiledict.h @@ -0,0 +1,50 @@ +/* + * 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_COMPILEDICT_H +#define ESPEAK_NG_COMPILEDICT_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +char *DecodeRule(const char *group_chars, + int group_length, + char *rule, + int control); + +ESPEAK_NG_API espeak_ng_STATUS espeak_ng_CompileDictionary(const char *dsource, + const char *dict_name, + FILE *log, + int flags, + espeak_ng_ERROR_CONTEXT *context); + + +void print_dictionary_flags(unsigned int *flags, + char *buf, + int buf_len); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/libespeak-ng/compilembrola.c b/src/libespeak-ng/compilembrola.c index 2f96ba47..4c40f84e 100644 --- a/src/libespeak-ng/compilembrola.c +++ b/src/libespeak-ng/compilembrola.c @@ -28,6 +28,8 @@ #include #include +#include "mbrola.h" + #include "error.h" #include "phoneme.h" #include "speech.h" diff --git a/src/libespeak-ng/dictionary.c b/src/libespeak-ng/dictionary.c index 5ab68fe4..f6bdf182 100644 --- a/src/libespeak-ng/dictionary.c +++ b/src/libespeak-ng/dictionary.c @@ -31,6 +31,11 @@ #include #include +#include "dictionary.h" +#include "numbers.h" +#include "readclause.h" +#include "synthdata.h" + #include "speech.h" #include "phoneme.h" #include "voice.h" @@ -94,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..e010b6e8 --- /dev/null +++ b/src/libespeak-ng/dictionary.h @@ -0,0 +1,57 @@ +/* + * 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 "compiledict.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/espeak_api.c b/src/libespeak-ng/espeak_api.c index 7e282325..0a5f6fd7 100644 --- a/src/libespeak-ng/espeak_api.c +++ b/src/libespeak-ng/espeak_api.c @@ -27,6 +27,8 @@ #include #include +#include "compiledict.h" + #include "phoneme.h" #include "voice.h" #include "synthesize.h" diff --git a/src/libespeak-ng/intonation.c b/src/libespeak-ng/intonation.c index 0cd19bc2..074516a0 100644 --- a/src/libespeak-ng/intonation.c +++ b/src/libespeak-ng/intonation.c @@ -28,6 +28,9 @@ #include #include +#include "intonation.h" +#include "synthdata.h" + #include "phoneme.h" #include "voice.h" #include "synthesize.h" diff --git a/src/libespeak-ng/intonation.h b/src/libespeak-ng/intonation.h new file mode 100644 index 00000000..98f4bbf7 --- /dev/null +++ b/src/libespeak-ng/intonation.h @@ -0,0 +1,38 @@ +/* + * 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_INTONATION_H +#define ESPEAK_NG_INTONATION_H + +#include "translate.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +void CalcPitches(Translator *tr, int clause_type); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/libespeak-ng/mbrola.h b/src/libespeak-ng/mbrola.h new file mode 100644 index 00000000..ce898d9e --- /dev/null +++ b/src/libespeak-ng/mbrola.h @@ -0,0 +1,66 @@ +/* + * 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: . + */ + +// declarations for compilembrola.c and synth_mbrola.c + +#ifndef ESPEAK_NG_MBROLA_H +#define ESPEAK_NG_MBROLA_H + +#include + +#include "synthesize.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct { + int name; + unsigned int next_phoneme; + int mbr_name; + int mbr_name2; + int percent; // percentage length of first component + int control; +} MBROLA_TAB; + +extern int mbrola_delay; +extern char mbrola_name[20]; + +espeak_ng_STATUS LoadMbrolaTable(const char *mbrola_voice, + const char *phtrans, + int *srate); + +int MbrolaGenerate(PHONEME_LIST *phoneme_list, + int *n_ph, bool resume); + +int MbrolaFill(int length, + bool resume, + int amplitude); + +void MbrolaReset(void); +int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, bool resume, FILE *f_mbrola); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/libespeak-ng/numbers.c b/src/libespeak-ng/numbers.c index 8c9ad205..24843d9f 100644 --- a/src/libespeak-ng/numbers.c +++ b/src/libespeak-ng/numbers.c @@ -31,6 +31,11 @@ #include #include +#include "dictionary.h" +#include "numbers.h" +#include "readclause.h" +#include "synthdata.h" + #include "phoneme.h" #include "voice.h" #include "synthesize.h" diff --git a/src/libespeak-ng/numbers.h b/src/libespeak-ng/numbers.h new file mode 100644 index 00000000..822ab272 --- /dev/null +++ b/src/libespeak-ng/numbers.h @@ -0,0 +1,43 @@ +/* + * 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_NUMBERS_H +#define ESPEAK_NG_NUMBERS_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf); +void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf1, int control); +int IsSuperscript(int letter); +void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars); +int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab); +int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *flags, WORD_TAB *wtab, int control); +int TranslateLetter(Translator *tr, char *word, char *phonemes, int control); + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/libespeak-ng/phoneme.h b/src/libespeak-ng/phoneme.h index fd070763..82a3311e 100644 --- a/src/libespeak-ng/phoneme.h +++ b/src/libespeak-ng/phoneme.h @@ -282,11 +282,6 @@ typedef struct { #define PH(c1, c2) (c2<<8)+c1 // combine two characters into an integer for phoneme name #define PH3(c1, c2, c3) (c3<<16)+(c2<<8)+c1 #define PhonemeCode2(c1, c2) PhonemeCode((c2<<8)+c1) -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); diff --git a/src/libespeak-ng/phonemelist.c b/src/libespeak-ng/phonemelist.c index 60ced1d1..c3af9ea6 100644 --- a/src/libespeak-ng/phonemelist.c +++ b/src/libespeak-ng/phonemelist.c @@ -29,6 +29,9 @@ #include #include +#include "phonemelist.h" +#include "synthdata.h" + #include "phoneme.h" #include "voice.h" #include "synthesize.h" diff --git a/src/libespeak-ng/phonemelist.h b/src/libespeak-ng/phonemelist.h new file mode 100644 index 00000000..049b0568 --- /dev/null +++ b/src/libespeak-ng/phonemelist.h @@ -0,0 +1,38 @@ +/* + * 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_PHONEMELIST_H +#define ESPEAK_NG_PHONEMELIST_H + +#include "translate.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef __cplusplus +} +#endif + +void MakePhonemeList(Translator *tr, int post_pause, bool start_sentence); + +#endif + diff --git a/src/libespeak-ng/readclause.c b/src/libespeak-ng/readclause.c index 42cfe54e..52362de4 100644 --- a/src/libespeak-ng/readclause.c +++ b/src/libespeak-ng/readclause.c @@ -36,6 +36,10 @@ #include #include +#include "dictionary.h" +#include "readclause.h" +#include "synthdata.h" + #include "error.h" #include "speech.h" #include "phoneme.h" diff --git a/src/libespeak-ng/readclause.h b/src/libespeak-ng/readclause.h new file mode 100644 index 00000000..3a1bb37e --- /dev/null +++ b/src/libespeak-ng/readclause.h @@ -0,0 +1,61 @@ +/* + * 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_READCLAUSE_H +#define ESPEAK_NG_READCLAUSE_H + +#include "translate.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct { + int type; + int parameter[N_SPEECH_PARAM]; +} PARAM_STACK; + +extern PARAM_STACK param_stack[]; +extern const int param_defaults[N_SPEECH_PARAM]; + + int clause_type_from_codepoint(uint32_t c); +int towlower2(unsigned int c); // Supports Turkish I +int Eof(void); +const char *WordToString2(unsigned int word); +int Read4Bytes(FILE *f); +int LoadSoundFile2(const char *fname); +int AddNameData(const char *name, + int wide); +int ReadClause(Translator *tr, + char *buf, + short *charix, + int *charix_top, + int n_buf, + int *tone_type, + char *voice_change); + + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/libespeak-ng/setlengths.c b/src/libespeak-ng/setlengths.c index 831e2f51..3149e947 100644 --- a/src/libespeak-ng/setlengths.c +++ b/src/libespeak-ng/setlengths.c @@ -28,6 +28,11 @@ #include #include +#include "readclause.h" +#include "setlengths.h" +#include "synthdata.h" +#include "wavegen.h" + #include "phoneme.h" #include "voice.h" #include "synthesize.h" diff --git a/src/libespeak-ng/setlengths.h b/src/libespeak-ng/setlengths.h new file mode 100644 index 00000000..7835c68f --- /dev/null +++ b/src/libespeak-ng/setlengths.h @@ -0,0 +1,38 @@ +/* + * 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_SETLENGTHS_H +#define ESPEAK_NG_SETLENGTHS_H + +#include "translate.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +void CalcLengths(Translator *tr); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/libespeak-ng/spect.h b/src/libespeak-ng/spect.h index d04b206b..64ca61a8 100644 --- a/src/libespeak-ng/spect.h +++ b/src/libespeak-ng/spect.h @@ -21,6 +21,9 @@ #define ESPEAK_NG_SPECT_H #include + +#include "wavegen.h" + #include "synthesize.h" #include "speech.h" diff --git a/src/libespeak-ng/speech.c b/src/libespeak-ng/speech.c index 7dc58e65..27fc6d81 100644 --- a/src/libespeak-ng/speech.c +++ b/src/libespeak-ng/speech.c @@ -48,6 +48,12 @@ #include #include +#include "dictionary.h" +#include "mbrola.h" +#include "readclause.h" +#include "synthdata.h" +#include "wavegen.h" + #include "speech.h" #include "phoneme.h" #include "voice.h" diff --git a/src/libespeak-ng/speech.h b/src/libespeak-ng/speech.h index fd3d3e75..681f77fb 100644 --- a/src/libespeak-ng/speech.h +++ b/src/libespeak-ng/speech.h @@ -22,6 +22,8 @@ #include +#include "mbrola.h" + #ifdef __cplusplus extern "C" { diff --git a/src/libespeak-ng/ssml.c b/src/libespeak-ng/ssml.c index 6c566596..6af0eb15 100644 --- a/src/libespeak-ng/ssml.c +++ b/src/libespeak-ng/ssml.c @@ -39,6 +39,8 @@ #include #include +#include "readclause.h" + #include "error.h" #include "speech.h" #include "phoneme.h" diff --git a/src/libespeak-ng/ssml.h b/src/libespeak-ng/ssml.h index f47f213c..29cd1530 100644 --- a/src/libespeak-ng/ssml.h +++ b/src/libespeak-ng/ssml.h @@ -62,11 +62,6 @@ typedef struct { #define HTML_NOSPACE 16 // don't insert a space for this element, so it doesn't break a word #define SSML_CLOSE 0x20 // for a closing tag, OR this with the tag type -int LoadSoundFile2(const char *fname); - -int AddNameData(const char *name, - int wide); - int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, diff --git a/src/libespeak-ng/synth_mbrola.c b/src/libespeak-ng/synth_mbrola.c index b3473f8e..203c95b5 100644 --- a/src/libespeak-ng/synth_mbrola.c +++ b/src/libespeak-ng/synth_mbrola.c @@ -32,15 +32,25 @@ #include #include +#include "dictionary.h" +#include "mbrola.h" +#include "readclause.h" +#include "synthdata.h" +#include "wavegen.h" + + #include "speech.h" #include "phoneme.h" #include "voice.h" #include "synthesize.h" #include "translate.h" +// included here so tests can find these even without OPT_MBROLA set +int mbrola_delay; +char mbrola_name[20]; + #ifdef INCLUDE_MBROLA -extern int Read4Bytes(FILE *f); extern unsigned char *outbuf; #if defined(_WIN32) || defined(_WIN64) diff --git a/src/libespeak-ng/synthdata.c b/src/libespeak-ng/synthdata.c index 81ce99d4..25fde001 100644 --- a/src/libespeak-ng/synthdata.c +++ b/src/libespeak-ng/synthdata.c @@ -31,6 +31,9 @@ #include #include +#include "readclause.h" +#include "synthdata.h" + #include "error.h" #include "speech.h" #include "phoneme.h" diff --git a/src/libespeak-ng/synthdata.h b/src/libespeak-ng/synthdata.h new file mode 100644 index 00000000..a199c96f --- /dev/null +++ b/src/libespeak-ng/synthdata.h @@ -0,0 +1,63 @@ +/* + * 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_SYNTHDATA_H +#define ESPEAK_NG_SYNTHDATA_H + +#include "synthesize.h" +#include "translate.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +void InterpretPhoneme(Translator *tr, + int control, + PHONEME_LIST *plist, + PHONEME_DATA *phdata, + WORD_PH_DATA *worddata); + +void InterpretPhoneme2(int phcode, + PHONEME_DATA *phdata); + +void FreePhData(void); +unsigned char *GetEnvelope(int index); +espeak_ng_STATUS LoadPhData(int *srate, espeak_ng_ERROR_CONTEXT *context); +void LoadConfig(void); +int LookupPhonemeString(const char *string); +int LookupPhonemeTable(const char *name); +frameref_t *LookupSpect(PHONEME_TAB *this_ph, + int which, + FMT_PARAMS *fmt_params, + int *n_frames, + PHONEME_LIST *plist); + +int NumInstnWords(unsigned short *prog); +int PhonemeCode(unsigned int mnem); +void SelectPhonemeTable(int number); +int SelectPhonemeTableName(const char *name); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/libespeak-ng/synthesize.c b/src/libespeak-ng/synthesize.c index 194d5343..49f7cab6 100644 --- a/src/libespeak-ng/synthesize.c +++ b/src/libespeak-ng/synthesize.c @@ -32,6 +32,13 @@ #include #include +#include "dictionary.h" +#include "intonation.h" +#include "mbrola.h" +#include "setlengths.h" +#include "synthdata.h" +#include "wavegen.h" + #include "phoneme.h" #include "voice.h" #include "synthesize.h" @@ -44,9 +51,6 @@ static void SmoothSpect(void); int n_phoneme_list = 0; PHONEME_LIST phoneme_list[N_PHONEME_LIST+1]; -int mbrola_delay; -char mbrola_name[20]; - SPEED_FACTORS speed; static int last_pitch_cmd; diff --git a/src/libespeak-ng/synthesize.h b/src/libespeak-ng/synthesize.h index d5b3a50b..65c72729 100644 --- a/src/libespeak-ng/synthesize.h +++ b/src/libespeak-ng/synthesize.h @@ -35,7 +35,6 @@ extern "C" #define N_PHONEME_LIST 1000 // enough for source[N_TR_SOURCE] full of text, else it will truncate -#define MAX_HARMONIC 400 // 400 * 50Hz = 20 kHz, more than enough #define N_SEQ_FRAMES 25 // max frames in a spectrum sequence (real max is ablut 8) #define STEPSIZE 64 // 2.9mS at 22 kHz sample rate @@ -129,22 +128,6 @@ typedef struct { // 44 bytes unsigned char klattp[5]; // AV, FNZ, Tilt, Aspr, Skew } frame_t2; // without the extra Klatt parameters -// formant data used by wavegen -typedef struct { - int freq; // Hz<<16 - int height; // height<<15 - int left; // Hz<<16 - int right; // Hz<<16 - double freq1; // floating point versions of the above - double height1; - double left1; - double right1; - double freq_inc; // increment by this every 64 samples - double height_inc; - double left_inc; - double right_inc; -} wavegen_peaks_t; - typedef struct { unsigned char *pitch_env; int pitch; // pitch Hz*256 @@ -355,15 +338,6 @@ typedef struct { char *filename; } SOUND_ICON; -typedef struct { - int name; - unsigned int next_phoneme; - int mbr_name; - int mbr_name2; - int percent; // percentage length of first component - int control; -} MBROLA_TAB; - typedef struct { int pause_factor; int clause_pause_factor; @@ -462,17 +436,7 @@ extern intptr_t wcmdq[N_WCMDQ][4]; extern int wcmdq_head; extern int wcmdq_tail; -// from Wavegen file -int WcmdqFree(void); -void WcmdqStop(void); -int WcmdqUsed(void); -void WcmdqInc(void); -void WavegenInit(int rate, int wavemult_fact); -int WavegenFill(void); void MarkerEvent(int type, unsigned int char_position, int value, int value2, unsigned char *out_ptr); -int GetAmplitude(void); -void SetPitch2(voice_t *voice, int pitch1, int pitch2, int *pitch_base, int *pitch_range); -int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control); extern unsigned char *wavefile_data; extern int samplerate; @@ -491,30 +455,15 @@ extern int echo_tail; extern int echo_amp; extern short echo_buf[N_ECHO_BUF]; -extern int mbrola_delay; -extern char mbrola_name[20]; - -// from synthdata file -unsigned int LookupSound(PHONEME_TAB *ph1, PHONEME_TAB *ph2, int which, int *match_level, int control); -frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, int *n_frames, PHONEME_LIST *plist); -void FreePhData(void); - -unsigned char *LookupEnvelope(int ix); -espeak_ng_STATUS LoadPhData(int *srate, espeak_ng_ERROR_CONTEXT *context); - void SynthesizeInit(void); int Generate(PHONEME_LIST *phoneme_list, int *n_ph, bool resume); void MakeWave2(PHONEME_LIST *p, int n_ph); int SpeakNextClause(int control); void SetSpeed(int control); void SetEmbedded(int control, int value); -void SelectPhonemeTable(int number); -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 Read4Bytes(FILE *f); -int Reverse4Bytes(int word); #if HAVE_SONIC_H void DoSonicSpeed(int value); @@ -545,23 +494,13 @@ extern double sonicSpeed; extern int n_soundicon_tab; extern SOUND_ICON soundicon_tab[N_SOUNDICON_TAB]; -espeak_ng_STATUS LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int *srate); espeak_ng_STATUS SetParameter(int parameter, int value, int relative); -int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, bool resume, FILE *f_mbrola); -int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, bool resume); -int MbrolaFill(int length, bool resume, int amplitude); -void MbrolaReset(void); void DoEmbedded(int *embix, int sourceix); void DoMarker(int type, int char_posn, int length, int value); void DoPhonemeMarker(int type, int char_posn, int length, char *name); int DoSample3(PHONEME_DATA *phdata, int length_mod, int amp); int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_LIST *plist, int modulation); int PauseLength(int pause, int control); -int LookupPhonemeTable(const char *name); -unsigned char *GetEnvelope(int index); -int NumInstnWords(unsigned short *prog); - -void InitBreath(void); #ifdef __cplusplus } diff --git a/src/libespeak-ng/translate.c b/src/libespeak-ng/translate.c index 3ab9d939..ff0b0305 100644 --- a/src/libespeak-ng/translate.c +++ b/src/libespeak-ng/translate.c @@ -32,6 +32,12 @@ #include #include +#include "dictionary.h" +#include "numbers.h" +#include "phonemelist.h" +#include "readclause.h" +#include "synthdata.h" + #include "speech.h" #include "phoneme.h" #include "voice.h" diff --git a/src/libespeak-ng/translate.h b/src/libespeak-ng/translate.h index e5e2b2cb..c71c8d4a 100644 --- a/src/libespeak-ng/translate.h +++ b/src/libespeak-ng/translate.h @@ -25,8 +25,6 @@ #include #include -#include "synthesize.h" - #ifdef __cplusplus extern "C" { @@ -246,8 +244,6 @@ extern "C" #define CLAUSE_COLON (30 | CLAUSE_INTONATION_FULL_STOP | CLAUSE_TYPE_CLAUSE) #define CLAUSE_SEMICOLON (30 | CLAUSE_INTONATION_COMMA | CLAUSE_TYPE_CLAUSE) -int clause_type_from_codepoint(uint32_t c); - //@} #define SAYAS_CHARS 0x12 @@ -277,14 +273,6 @@ typedef struct { unsigned char length; } WORD_TAB; -typedef struct { - int type; - int parameter[N_SPEECH_PARAM]; -} PARAM_STACK; - -extern PARAM_STACK param_stack[]; -extern const int param_defaults[N_SPEECH_PARAM]; - typedef struct { const char *name; int offset; @@ -698,9 +686,6 @@ extern int (*uri_callback)(int, const char *, const char *); 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 @@ -711,7 +696,6 @@ int utf8_nbytes(const char *buf); int lookupwchar(const unsigned short *list, int c); int lookupwchar2(const unsigned short *list, int c); -int Eof(void); char *strchr_w(const char *s, int c); int IsBracket(int c); void InitNamedata(void); @@ -720,56 +704,22 @@ 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 IsSuperscript(int letter); int isspace2(unsigned int c); -int towlower2(unsigned int c); // Supports Turkish I -const char *GetTranslatedPhonemeString(int phoneme_mode); -const char *WordToString2(unsigned int word); 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); - -int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *flags, WORD_TAB *wtab, int control); -int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab); - -void ChangeWordStress(Translator *tr, char *word, int new_stress); -void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars); -int TranslateLetter(Translator *tr, char *letter, char *phonemes, int control); -void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf, int control); -void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf); - -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 MakePhonemeList(Translator *tr, int post_pause, bool new_sentence); void ApplySpecialAttribute2(Translator *tr, char *phonemes, int dict_flags); -void AppendPhonemes(Translator *tr, char *string, int size, const char *ph); -void CalcLengths(Translator *tr); -void CalcPitches(Translator *tr, int clause_tone); - -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); -int ReadClause(Translator *tr, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type, char *voice_change); void SetVoiceStack(espeak_VOICE *v, const char *variant_name); -void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_DATA *phdata, WORD_PH_DATA *worddata); -void InterpretPhoneme2(int phcode, PHONEME_DATA *phdata); -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 78cef626..3d4b27a6 100644 --- a/src/libespeak-ng/voices.c +++ b/src/libespeak-ng/voices.c @@ -38,6 +38,11 @@ #include #include +#include "dictionary.h" +#include "readclause.h" +#include "synthdata.h" +#include "wavegen.h" + #include "speech.h" #include "phoneme.h" #include "voice.h" diff --git a/src/libespeak-ng/wavegen.c b/src/libespeak-ng/wavegen.c index ab833cf8..f584ad04 100644 --- a/src/libespeak-ng/wavegen.c +++ b/src/libespeak-ng/wavegen.c @@ -32,6 +32,8 @@ #include #include +#include "wavegen.h" + #include "synthesize.h" #include "speech.h" #include "phoneme.h" @@ -80,6 +82,7 @@ static RESONATOR rbreath[N_PEAKS]; static int harm_sqrt_n = 0; #define N_LOWHARM 30 +#define MAX_HARMONIC 400 // 400 * 50Hz = 20 kHz, more than enough static int harm_inc[N_LOWHARM]; // only for these harmonics do we interpolate amplitude between steps static int *harmspect; static int hswitch = 0; @@ -1393,7 +1396,7 @@ static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text #endif // Call WavegenFill2, and then speed up the output samples. -int WavegenFill() +int WavegenFill(void) { int finished; unsigned char *p_start; diff --git a/src/libespeak-ng/wavegen.h b/src/libespeak-ng/wavegen.h new file mode 100644 index 00000000..75d2a836 --- /dev/null +++ b/src/libespeak-ng/wavegen.h @@ -0,0 +1,76 @@ +/* + * 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_WAVEGEN_H +#define ESPEAK_NG_WAVEGEN_H + +#include "voice.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct { + int freq; // Hz<<16 + int height; // height<<15 + int left; // Hz<<16 + int right; // Hz<<16 + double freq1; // floating point versions of the above + double height1; + double left1; + double right1; + double freq_inc; // increment by this every 64 samples + double height_inc; + double left_inc; + double right_inc; +} wavegen_peaks_t; + + +int GetAmplitude(void); +void InitBreath(void); +int PeaksToHarmspect(wavegen_peaks_t *peaks, + int pitch, + int *htab, + int control); + +void SetPitch2(voice_t *voice, + int pitch1, + int pitch2, + int *pitch_base, + int *pitch_range); + +void WavegenInit(int rate, + int wavemult_fact); + + +int WavegenFill(void); +void WavegenSetVoice(voice_t *v); +int WcmdqFree(void); +void WcmdqStop(void); +int WcmdqUsed(void); +void WcmdqInc(void); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/tests/readclause.c b/tests/readclause.c index 673f28d1..ae232194 100644 --- a/tests/readclause.c +++ b/tests/readclause.c @@ -29,6 +29,7 @@ #include #include +#include "readclause.h" #include "speech.h" #include "phoneme.h" #include "voice.h"