Browse Source

Merge remote-tracking branch 'jaacoppi/includes'

master
Reece H. Dunn 7 years ago
parent
commit
c73530f7dd

+ 4
- 0
src/libespeak-ng/compiledata.c View File

@@ -35,6 +35,10 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#include "readclause.h"
#include "synthdata.h"
#include "wavegen.h"

#include "error.h"
#include "phoneme.h"
#include "voice.h"

+ 4
- 2
src/libespeak-ng/compiledict.c View File

@@ -33,6 +33,10 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#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;


+ 50
- 0
src/libespeak-ng/compiledict.h View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected]
* 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: <http://www.gnu.org/licenses/>.
*/

#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


+ 2
- 0
src/libespeak-ng/compilembrola.c View File

@@ -28,6 +28,8 @@
#include <espeak-ng/espeak_ng.h>
#include <espeak-ng/speak_lib.h>

#include "mbrola.h"

#include "error.h"
#include "phoneme.h"
#include "speech.h"

+ 6
- 1
src/libespeak-ng/dictionary.c View File

@@ -31,6 +31,11 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#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

+ 57
- 0
src/libespeak-ng/dictionary.h View File

@@ -0,0 +1,57 @@
/*
* Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected]
* 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: <http://www.gnu.org/licenses/>.
*/

#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


+ 2
- 0
src/libespeak-ng/espeak_api.c View File

@@ -27,6 +27,8 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#include "compiledict.h"

#include "phoneme.h"
#include "voice.h"
#include "synthesize.h"

+ 3
- 0
src/libespeak-ng/intonation.c View File

@@ -28,6 +28,9 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#include "intonation.h"
#include "synthdata.h"

#include "phoneme.h"
#include "voice.h"
#include "synthesize.h"

+ 38
- 0
src/libespeak-ng/intonation.h View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected]
* 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: <http://www.gnu.org/licenses/>.
*/

#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


+ 66
- 0
src/libespeak-ng/mbrola.h View File

@@ -0,0 +1,66 @@
/*
* Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected]
* 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: <http://www.gnu.org/licenses/>.
*/

// declarations for compilembrola.c and synth_mbrola.c

#ifndef ESPEAK_NG_MBROLA_H
#define ESPEAK_NG_MBROLA_H

#include <stdbool.h>

#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


+ 5
- 0
src/libespeak-ng/numbers.c View File

@@ -31,6 +31,11 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#include "dictionary.h"
#include "numbers.h"
#include "readclause.h"
#include "synthdata.h"

#include "phoneme.h"
#include "voice.h"
#include "synthesize.h"

+ 43
- 0
src/libespeak-ng/numbers.h View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected]
* 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: <http://www.gnu.org/licenses/>.
*/

#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


+ 0
- 5
src/libespeak-ng/phoneme.h View File

@@ -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);


+ 3
- 0
src/libespeak-ng/phonemelist.c View File

@@ -29,6 +29,9 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#include "phonemelist.h"
#include "synthdata.h"

#include "phoneme.h"
#include "voice.h"
#include "synthesize.h"

+ 38
- 0
src/libespeak-ng/phonemelist.h View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected]
* 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: <http://www.gnu.org/licenses/>.
*/

#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


+ 4
- 0
src/libespeak-ng/readclause.c View File

@@ -36,6 +36,10 @@
#include <espeak-ng/encoding.h>
#include <ucd/ucd.h>

#include "dictionary.h"
#include "readclause.h"
#include "synthdata.h"

#include "error.h"
#include "speech.h"
#include "phoneme.h"

+ 61
- 0
src/libespeak-ng/readclause.h View File

@@ -0,0 +1,61 @@
/*
* Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected]
* 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: <http://www.gnu.org/licenses/>.
*/
#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


+ 5
- 0
src/libespeak-ng/setlengths.c View File

@@ -28,6 +28,11 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#include "readclause.h"
#include "setlengths.h"
#include "synthdata.h"
#include "wavegen.h"

#include "phoneme.h"
#include "voice.h"
#include "synthesize.h"

+ 38
- 0
src/libespeak-ng/setlengths.h View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected]
* 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: <http://www.gnu.org/licenses/>.
*/

#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


+ 3
- 0
src/libespeak-ng/spect.h View File

@@ -21,6 +21,9 @@
#define ESPEAK_NG_SPECT_H

#include <espeak-ng/espeak_ng.h>

#include "wavegen.h"

#include "synthesize.h"
#include "speech.h"


+ 6
- 0
src/libespeak-ng/speech.c View File

@@ -48,6 +48,12 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#include "dictionary.h"
#include "mbrola.h"
#include "readclause.h"
#include "synthdata.h"
#include "wavegen.h"

#include "speech.h"
#include "phoneme.h"
#include "voice.h"

+ 2
- 0
src/libespeak-ng/speech.h View File

@@ -22,6 +22,8 @@

#include <espeak-ng/espeak_ng.h>

#include "mbrola.h"

#ifdef __cplusplus
extern "C"
{

+ 2
- 0
src/libespeak-ng/ssml.c View File

@@ -39,6 +39,8 @@
#include <espeak-ng/encoding.h>
#include <ucd/ucd.h>

#include "readclause.h"

#include "error.h"
#include "speech.h"
#include "phoneme.h"

+ 0
- 5
src/libespeak-ng/ssml.h View File

@@ -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,

+ 11
- 1
src/libespeak-ng/synth_mbrola.c View File

@@ -32,15 +32,25 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#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)

+ 3
- 0
src/libespeak-ng/synthdata.c View File

@@ -31,6 +31,9 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#include "readclause.h"
#include "synthdata.h"

#include "error.h"
#include "speech.h"
#include "phoneme.h"

+ 63
- 0
src/libespeak-ng/synthdata.h View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected]
* 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: <http://www.gnu.org/licenses/>.
*/

#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


+ 7
- 3
src/libespeak-ng/synthesize.c View File

@@ -32,6 +32,13 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#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;

+ 0
- 61
src/libespeak-ng/synthesize.h View File

@@ -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
}

+ 6
- 0
src/libespeak-ng/translate.c View File

@@ -32,6 +32,12 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#include "dictionary.h"
#include "numbers.h"
#include "phonemelist.h"
#include "readclause.h"
#include "synthdata.h"

#include "speech.h"
#include "phoneme.h"
#include "voice.h"

+ 0
- 50
src/libespeak-ng/translate.h View File

@@ -25,8 +25,6 @@
#include <espeak-ng/espeak_ng.h>
#include <espeak-ng/encoding.h>

#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


+ 5
- 0
src/libespeak-ng/voices.c View File

@@ -38,6 +38,11 @@
#include <espeak-ng/speak_lib.h>
#include <espeak-ng/encoding.h>

#include "dictionary.h"
#include "readclause.h"
#include "synthdata.h"
#include "wavegen.h"

#include "speech.h"
#include "phoneme.h"
#include "voice.h"

+ 4
- 1
src/libespeak-ng/wavegen.c View File

@@ -32,6 +32,8 @@
#include <espeak-ng/espeak_ng.h>
#include <espeak-ng/speak_lib.h>

#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;

+ 76
- 0
src/libespeak-ng/wavegen.h View File

@@ -0,0 +1,76 @@
/*
* Copyright (C) 2005 to 2015 by Jonathan Duddington
* email: [email protected]
* 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: <http://www.gnu.org/licenses/>.
*/

#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


+ 1
- 0
tests/readclause.c View File

@@ -29,6 +29,7 @@
#include <espeak-ng/espeak_ng.h>
#include <espeak-ng/encoding.h>

#include "readclause.h"
#include "speech.h"
#include "phoneme.h"
#include "voice.h"

Loading…
Cancel
Save