Contribute to #68 Reduce number of externs and static-returnsmaster
int duplicate_references; | int duplicate_references; | ||||
int count_frames; | int count_frames; | ||||
int error_count; | int error_count; | ||||
int resample_count; | |||||
int then_count; | int then_count; | ||||
bool after_if; | bool after_if; | ||||
sr2 = Read4Bytes(f); | sr2 = Read4Bytes(f); | ||||
fseek(f, 40, SEEK_SET); | fseek(f, 40, SEEK_SET); | ||||
if ((sr1 != samplerate_native) || (sr2 != sr1*2)) { | |||||
if (sr1 != samplerate_native) | |||||
error(ctx, "Can't resample (%d to %d): %s", sr1, samplerate_native, fname); | |||||
if ((sr1 != samplerate) || (sr2 != sr1*2)) { | |||||
if (sr1 != samplerate) | |||||
error(ctx, "Can't resample (%d to %d): %s", sr1, samplerate, fname); | |||||
else | else | ||||
error(ctx, "WAV file is not mono: %s", fname); | error(ctx, "WAV file is not mono: %s", fname); | ||||
return 0; | return 0; | ||||
static void EndPhonemeTable(CompileContext *ctx) | static void EndPhonemeTable(CompileContext *ctx) | ||||
{ | { | ||||
int ix; | int ix; | ||||
char buf[5]; | |||||
if (ctx->n_phoneme_tabs == 0) | if (ctx->n_phoneme_tabs == 0) | ||||
return; | return; | ||||
for (ix = 0; ix < ctx->n_phcodes; ix++) { | for (ix = 0; ix < ctx->n_phcodes; ix++) { | ||||
if (ctx->phoneme_tab2[ix].type == phINVALID) { | if (ctx->phoneme_tab2[ix].type == phINVALID) { | ||||
error(ctx, "Phoneme [%s] not declared, referenced at line %d", | error(ctx, "Phoneme [%s] not declared, referenced at line %d", | ||||
WordToString(ctx->phoneme_tab2[ix].mnemonic), (int)(ctx->phoneme_tab2[ix].program)); | |||||
WordToString(buf, ctx->phoneme_tab2[ix].mnemonic), (int)(ctx->phoneme_tab2[ix].program)); | |||||
ctx->error_count++; | ctx->error_count++; | ||||
ctx->phoneme_tab2[ix].type = 0; // prevent the error message repeating | ctx->phoneme_tab2[ix].type = 0; // prevent the error message repeating | ||||
} | } | ||||
sprintf(phdst, "%s", path_home); | sprintf(phdst, "%s", path_home); | ||||
} | } | ||||
samplerate_native = samplerate = rate; | |||||
samplerate = rate; | |||||
LoadPhData(NULL, NULL); | LoadPhData(NULL, NULL); | ||||
if (LoadVoice("", 8/*compiling phonemes*/) == NULL) { | if (LoadVoice("", 8/*compiling phonemes*/) == NULL) { | ||||
clean_context(ctx); | clean_context(ctx); | ||||
WavegenSetVoice(voice); | WavegenSetVoice(voice); | ||||
ctx->error_count = 0; | ctx->error_count = 0; | ||||
ctx->resample_count = 0; | |||||
ctx->f_errors = log; | ctx->f_errors = log; | ||||
strncpy0(ctx->current_fname, "phonemes", sizeof(ctx->current_fname)); | strncpy0(ctx->current_fname, "phonemes", sizeof(ctx->current_fname)); | ||||
// write a word so that further data doesn't start at displ=0 | // write a word so that further data doesn't start at displ=0 | ||||
Write4Bytes(ctx->f_phdata, version_phdata); | Write4Bytes(ctx->f_phdata, version_phdata); | ||||
Write4Bytes(ctx->f_phdata, samplerate_native); | |||||
Write4Bytes(ctx->f_phdata, samplerate); | |||||
Write4Bytes(ctx->f_phindex, version_phdata); | Write4Bytes(ctx->f_phindex, version_phdata); | ||||
memset(ctx->ref_hash_tab, 0, sizeof(ctx->ref_hash_tab)); | memset(ctx->ref_hash_tab, 0, sizeof(ctx->ref_hash_tab)); | ||||
WavegenFini(); | WavegenFini(); | ||||
if (ctx->resample_count > 0) { | |||||
fprintf(ctx->f_errors, "\n%d WAV files resampled to %d Hz\n", ctx->resample_count, samplerate_native); | |||||
fprintf(log, "Compiled phonemes: %d errors, %d files resampled to %d Hz.\n", ctx->error_count, ctx->resample_count, samplerate_native); | |||||
} else | |||||
fprintf(log, "Compiled phonemes: %d errors.\n", ctx->error_count); | |||||
fprintf(log, "Compiled phonemes: %d errors.\n", ctx->error_count); | |||||
if (ctx->f_errors != stderr && ctx->f_errors != stdout) | if (ctx->f_errors != stderr && ctx->f_errors != stdout) | ||||
fclose(ctx->f_errors); | fclose(ctx->f_errors); |
int ix; | int ix; | ||||
unsigned int digit_count = 0; | unsigned int digit_count = 0; | ||||
char *p; | char *p; | ||||
char word_buf[5]; | |||||
const ALPHABET *alphabet; | const ALPHABET *alphabet; | ||||
int dict_flags0 = 0; | int dict_flags0 = 0; | ||||
MatchRecord match1 = { 0 }; | MatchRecord match1 = { 0 }; | ||||
if (((alphabet = AlphabetFromChar(letter)) != NULL) && (alphabet->offset != tr->letter_bits_offset)) { | if (((alphabet = AlphabetFromChar(letter)) != NULL) && (alphabet->offset != tr->letter_bits_offset)) { | ||||
if (tr->langopts.alt_alphabet == alphabet->offset) { | if (tr->langopts.alt_alphabet == alphabet->offset) { | ||||
sprintf(phonemes, "%c%s", phonSWITCH, WordToString2(tr->langopts.alt_alphabet_lang)); | |||||
sprintf(phonemes, "%c%s", phonSWITCH, WordToString2(word_buf, tr->langopts.alt_alphabet_lang)); | |||||
return 0; | return 0; | ||||
} | } | ||||
if (alphabet->flags & AL_WORDS) { | if (alphabet->flags & AL_WORDS) { | ||||
// switch to the nominated language for this alphabet | // switch to the nominated language for this alphabet | ||||
sprintf(phonemes, "%c%s", phonSWITCH, WordToString2(alphabet->language)); | |||||
sprintf(phonemes, "%c%s", phonSWITCH, WordToString2(word_buf, alphabet->language)); | |||||
return 0; | return 0; | ||||
} | } | ||||
} | } |
// Several phoneme tables may be loaded into memory. phoneme_tab points to | // Several phoneme tables may be loaded into memory. phoneme_tab points to | ||||
// one for the current voice | // one for the current voice | ||||
extern int n_phoneme_tab; | extern int n_phoneme_tab; | ||||
extern int current_phoneme_table; | |||||
extern PHONEME_TAB *phoneme_tab[N_PHONEME_TAB]; | extern PHONEME_TAB *phoneme_tab[N_PHONEME_TAB]; | ||||
typedef struct { | typedef struct { |
#include "ssml.h" // for SSML_STACK, ProcessSsmlTag, N_PARAM... | #include "ssml.h" // for SSML_STACK, ProcessSsmlTag, N_PARAM... | ||||
#include "synthdata.h" // for SelectPhonemeTable | #include "synthdata.h" // for SelectPhonemeTable | ||||
#include "translate.h" // for Translator, utf8_out, CLAUSE_OPTION... | #include "translate.h" // for Translator, utf8_out, CLAUSE_OPTION... | ||||
#include "voice.h" // for voice, voice_t, current_voice_selected | |||||
#include "voice.h" // for voice, voice_t, espeak_GetCurrentVoice | |||||
#define N_XML_BUF 500 | #define N_XML_BUF 500 | ||||
ungot_char = c; | ungot_char = c; | ||||
} | } | ||||
const char *WordToString2(unsigned int word) | |||||
const char *WordToString2(char buf[5], unsigned int word) | |||||
{ | { | ||||
// Convert a language mnemonic word into a string | // Convert a language mnemonic word into a string | ||||
int ix; | int ix; | ||||
static char buf[5]; | |||||
char *p; | char *p; | ||||
MAKE_MEM_UNDEFINED(&buf, sizeof(buf)); | |||||
p = buf; | p = buf; | ||||
for (ix = 3; ix >= 0; ix--) { | for (ix = 3; ix >= 0; ix--) { | ||||
if ((*p = word >> (ix*8)) != 0) | if ((*p = word >> (ix*8)) != 0) | ||||
return NULL; | return NULL; | ||||
} | } | ||||
static const char *LookupCharName(Translator *tr, int c, bool only) | |||||
static const char *LookupCharName(char buf[60], Translator *tr, int c, bool only) | |||||
{ | { | ||||
// Find the phoneme string (in ascii) to speak the name of character c | // Find the phoneme string (in ascii) to speak the name of character c | ||||
// Used for punctuation characters and symbols | // Used for punctuation characters and symbols | ||||
char phonemes[60]; | char phonemes[60]; | ||||
const char *lang_name = NULL; | const char *lang_name = NULL; | ||||
char *string; | char *string; | ||||
static char buf[60]; | |||||
MAKE_MEM_UNDEFINED(&buf, sizeof(buf)); | |||||
buf[0] = 0; | buf[0] = 0; | ||||
flags[0] = 0; | flags[0] = 0; | ||||
int bufix1; | int bufix1; | ||||
char buf[200]; | char buf[200]; | ||||
char ph_buf[30]; | char ph_buf[30]; | ||||
char cn_buf[60]; | |||||
c2 = *c2_ptr; | c2 = *c2_ptr; | ||||
buf[0] = 0; | buf[0] = 0; | ||||
punctname = ph_buf; // use word for 'period' instead of 'dot' | punctname = ph_buf; // use word for 'period' instead of 'dot' | ||||
} | } | ||||
if (punctname == NULL) | if (punctname == NULL) | ||||
punctname = LookupCharName(tr, c1, false); | |||||
punctname = LookupCharName(cn_buf, tr, c1, false); | |||||
if (punctname == NULL) | if (punctname == NULL) | ||||
return -1; | return -1; | ||||
if (variant_name[0] == '!' && variant_name[1] == 'v' && variant_name[2] == PATHSEP) | if (variant_name[0] == '!' && variant_name[1] == 'v' && variant_name[2] == PATHSEP) | ||||
variant_name += 3; // strip variant directory name, !v plus PATHSEP | variant_name += 3; // strip variant directory name, !v plus PATHSEP | ||||
strncpy0(base_voice_variant_name, variant_name, sizeof(base_voice_variant_name)); | strncpy0(base_voice_variant_name, variant_name, sizeof(base_voice_variant_name)); | ||||
memcpy(&base_voice, ¤t_voice_selected, sizeof(base_voice)); | |||||
memcpy(&base_voice, espeak_GetCurrentVoice(), sizeof(base_voice)); | |||||
} | } | ||||
static void RemoveChar(char *p) | static void RemoveChar(char *p) | ||||
char *p2; | char *p2; | ||||
p2 = &buf[ix]; | p2 = &buf[ix]; | ||||
sprintf(p2, "%s", LookupCharName(tr, c1, true)); | |||||
char cn_buf[60]; | |||||
sprintf(p2, "%s", LookupCharName(cn_buf, tr, c1, true)); | |||||
if (p2[0] != 0) { | if (p2[0] != 0) { | ||||
ix += strlen(p2); | ix += strlen(p2); | ||||
announced_punctuation = c1; | announced_punctuation = c1; | ||||
} else { | } else { | ||||
SetWordStress(tr2, phonemes, flags, -1, 0); | SetWordStress(tr2, phonemes, flags, -1, 0); | ||||
DecodePhonemes(phonemes, phonemes2); | DecodePhonemes(phonemes, phonemes2); | ||||
sprintf(buf, "[\002_^_%s %s _^_%s]]", ESPEAKNG_DEFAULT_VOICE, phonemes2, WordToString2(tr->translator_name)); | |||||
char wbuf[5]; | |||||
sprintf(buf, "[\002_^_%s %s _^_%s]]", ESPEAKNG_DEFAULT_VOICE, phonemes2, WordToString2(wbuf, tr->translator_name)); | |||||
} | } | ||||
} | |||||
} |
int clause_type_from_codepoint(uint32_t c); | int clause_type_from_codepoint(uint32_t c); | ||||
int Eof(void); | int Eof(void); | ||||
const char *WordToString2(unsigned int word); | |||||
const char *WordToString2(char buf[5], unsigned int word); | |||||
int AddNameData(const char *name, | int AddNameData(const char *name, | ||||
int wide); | int wide); | ||||
int ReadClause(Translator *tr, | int ReadClause(Translator *tr, |
static espeak_ng_STATUS err = ENS_OK; | static espeak_ng_STATUS err = ENS_OK; | ||||
static t_espeak_callback *synth_callback = NULL; | static t_espeak_callback *synth_callback = NULL; | ||||
int (*uri_callback)(int, const char *, const char *) = NULL; | |||||
int (*phoneme_callback)(const char *) = NULL; | |||||
char path_home[N_PATH_HOME]; // this is the espeak-ng-data directory | char path_home[N_PATH_HOME]; // this is the espeak-ng-data directory | ||||
extern int saved_parameters[N_SPEECH_PARAM]; // Parameters saved on synthesis start | extern int saved_parameters[N_SPEECH_PARAM]; // Parameters saved on synthesis start | ||||
WavegenInit(srate, 0); | WavegenInit(srate, 0); | ||||
LoadConfig(); | LoadConfig(); | ||||
memset(¤t_voice_selected, 0, sizeof(current_voice_selected)); | |||||
espeak_VOICE *current_voice_selected = espeak_GetCurrentVoice(); | |||||
memset(current_voice_selected, 0, sizeof(espeak_VOICE)); | |||||
SetVoiceStack(NULL, ""); | SetVoiceStack(NULL, ""); | ||||
SynthesizeInit(); | SynthesizeInit(); | ||||
InitNamedata(); | InitNamedata(); | ||||
#endif | #endif | ||||
} | } | ||||
ESPEAK_API void espeak_SetUriCallback(int (*UriCallback)(int, const char *, const char *)) | |||||
{ | |||||
uri_callback = UriCallback; | |||||
} | |||||
ESPEAK_API void espeak_SetPhonemeCallback(int (*PhonemeCallback)(const char *)) | |||||
{ | |||||
phoneme_callback = PhonemeCallback; | |||||
} | |||||
ESPEAK_NG_API espeak_ng_STATUS | ESPEAK_NG_API espeak_ng_STATUS | ||||
espeak_ng_Synthesize(const void *text, size_t size, | espeak_ng_Synthesize(const void *text, size_t size, | ||||
unsigned int position, | unsigned int position, |
{ NULL, 0 } | { NULL, 0 } | ||||
}; | }; | ||||
static int (*uri_callback)(int, const char *, const char *) = NULL; | |||||
static int attrcmp(const wchar_t *string1, const char *string2) | static int attrcmp(const wchar_t *string1, const char *string2) | ||||
{ | { | ||||
int ix; | int ix; | ||||
return 0; | return 0; | ||||
} | } | ||||
#pragma GCC visibility push(default) | |||||
ESPEAK_API void espeak_SetUriCallback(int (*UriCallback)(int, const char *, const char *)) | |||||
{ | |||||
uri_callback = UriCallback; | |||||
} | |||||
#pragma GCC visibility pop | |||||
static const MNEM_TAB xml_entity_mnemonics[] = { | static const MNEM_TAB xml_entity_mnemonics[] = { | ||||
{ "gt", '>' }, | { "gt", '>' }, | ||||
{ "lt", 0xe000 + '<' }, // private usage area, to avoid confusion with XML tag | { "lt", 0xe000 + '<' }, // private usage area, to avoid confusion with XML tag |
mbr_name_prefix = 0; | mbr_name_prefix = 0; | ||||
if (mbrola_voice == NULL) { | if (mbrola_voice == NULL) { | ||||
samplerate = samplerate_native; | |||||
samplerate = samplerate; | |||||
SetParameter(espeakVOICETYPE, 0, 0); | SetParameter(espeakVOICETYPE, 0, 0); | ||||
return ENS_OK; | return ENS_OK; | ||||
} | } | ||||
const char *final_pitch; | const char *final_pitch; | ||||
char *ptr; | char *ptr; | ||||
char mbr_buf[120]; | char mbr_buf[120]; | ||||
char phbuf[5]; | |||||
static int phix; | static int phix; | ||||
static int embedded_ix; | static int embedded_ix; | ||||
DoPhonemeMarker(espeakEVENT_PHONEME, (p->sourceix & 0x7ff) + clause_start_char, 0, phoneme_name); | DoPhonemeMarker(espeakEVENT_PHONEME, (p->sourceix & 0x7ff) + clause_start_char, 0, phoneme_name); | ||||
} | } | ||||
ptr += sprintf(ptr, "%s\t", WordToString(name)); | |||||
ptr += sprintf(ptr, "%s\t", WordToString(phbuf, name)); | |||||
if (name2 == '_') { | if (name2 == '_') { | ||||
// add a pause after this phoneme | // add a pause after this phoneme | ||||
ptr += sprintf(ptr, "%d\t%s", len1, pitch); | ptr += sprintf(ptr, "%d\t%s", len1, pitch); | ||||
pitch = WritePitch(p->env, p->pitch1, p->pitch2, -len_percent, 0); | pitch = WritePitch(p->env, p->pitch1, p->pitch2, -len_percent, 0); | ||||
ptr += sprintf(ptr, "%s\t%d\t%s", WordToString(name2), len-len1, pitch); | |||||
ptr += sprintf(ptr, "%s\t%d\t%s", WordToString(phbuf, name2), len-len1, pitch); | |||||
} | } | ||||
done = true; | done = true; | ||||
break; | break; | ||||
if (!done) { | if (!done) { | ||||
if (name2 != 0) { | if (name2 != 0) { | ||||
len1 = (len * len_percent)/100; | len1 = (len * len_percent)/100; | ||||
ptr += sprintf(ptr, "%d\n%s\t", len1, WordToString(name2)); | |||||
ptr += sprintf(ptr, "%d\n%s\t", len1, WordToString(phbuf, name2)); | |||||
len -= len1; | len -= len1; | ||||
} | } | ||||
ptr += sprintf(ptr, "%d%s\n", len, final_pitch); | ptr += sprintf(ptr, "%d%s\n", len, final_pitch); |
// copy the current phoneme table into here | // copy the current phoneme table into here | ||||
int n_phoneme_tab; | int n_phoneme_tab; | ||||
int current_phoneme_table; | |||||
static int current_phoneme_table; | |||||
PHONEME_TAB *phoneme_tab[N_PHONEME_TAB]; | PHONEME_TAB *phoneme_tab[N_PHONEME_TAB]; | ||||
static unsigned short *phoneme_index = NULL; | static unsigned short *phoneme_index = NULL; | ||||
phoneme_index = NULL; | phoneme_index = NULL; | ||||
phondata_ptr = NULL; | phondata_ptr = NULL; | ||||
tunes = NULL; | tunes = NULL; | ||||
current_phoneme_table = -1; | |||||
} | } | ||||
int PhonemeCode(unsigned int mnem) | int PhonemeCode(unsigned int mnem) | ||||
void SelectPhonemeTable(int number) | void SelectPhonemeTable(int number) | ||||
{ | { | ||||
if (current_phoneme_table == number) return; | |||||
n_phoneme_tab = 0; | n_phoneme_tab = 0; | ||||
MAKE_MEM_UNDEFINED(&phoneme_tab, sizeof(phoneme_tab)); | MAKE_MEM_UNDEFINED(&phoneme_tab, sizeof(phoneme_tab)); | ||||
SetUpPhonemeTable(number); // recursively for included phoneme tables | SetUpPhonemeTable(number); // recursively for included phoneme tables | ||||
static void InvalidInstn(PHONEME_TAB *ph, int instn) | static void InvalidInstn(PHONEME_TAB *ph, int instn) | ||||
{ | { | ||||
fprintf(stderr, "Invalid instruction %.4x for phoneme '%s'\n", instn, WordToString(ph->mnemonic)); | |||||
char buf[5]; | |||||
fprintf(stderr, "Invalid instruction %.4x for phoneme '%s'\n", instn, WordToString(buf, ph->mnemonic)); | |||||
} | } | ||||
static bool StressCondition(Translator *tr, PHONEME_LIST *plist, int condition, int control) | static bool StressCondition(Translator *tr, PHONEME_LIST *plist, int condition, int control) |
static voice_t *new_voice = NULL; | static voice_t *new_voice = NULL; | ||||
static int (*phoneme_callback)(const char *) = NULL; | |||||
#define RMS_GLOTTAL1 35 // vowel before glottal stop | #define RMS_GLOTTAL1 35 // vowel before glottal stop | ||||
#define RMS_START 28 // 28 | #define RMS_START 28 // 28 | ||||
#define VOWEL_FRONT_LENGTH 50 | #define VOWEL_FRONT_LENGTH 50 | ||||
const char *WordToString(unsigned int word) | |||||
const char *WordToString(char buf[5], unsigned int word) | |||||
{ | { | ||||
// Convert a phoneme mnemonic word into a string | // Convert a phoneme mnemonic word into a string | ||||
int ix; | int ix; | ||||
static char buf[5]; | |||||
MAKE_MEM_UNDEFINED(&buf, sizeof(buf)); | |||||
for (ix = 0; ix < 4; ix++) | for (ix = 0; ix < 4; ix++) | ||||
buf[ix] = word >> (ix*8); | buf[ix] = word >> (ix*8); | ||||
return 0; | return 0; | ||||
} | } | ||||
if (current_phoneme_table != voice->phoneme_tab_ix) | |||||
SelectPhonemeTable(voice->phoneme_tab_ix); | |||||
SelectPhonemeTable(voice->phoneme_tab_ix); | |||||
// read the next clause from the input text file, translate it, and generate | // read the next clause from the input text file, translate it, and generate | ||||
// entries in the wavegen command queue | // entries in the wavegen command queue | ||||
return 1; | return 1; | ||||
} | } | ||||
#pragma GCC visibility push(default) | |||||
ESPEAK_API void espeak_SetPhonemeCallback(int (*PhonemeCallback)(const char *)) | |||||
{ | |||||
phoneme_callback = PhonemeCallback; | |||||
} | |||||
#pragma GCC visibility pop |
#define N_EMBEDDED_VALUES 15 | #define N_EMBEDDED_VALUES 15 | ||||
extern int embedded_value[N_EMBEDDED_VALUES]; | extern int embedded_value[N_EMBEDDED_VALUES]; | ||||
extern int embedded_default[N_EMBEDDED_VALUES]; | |||||
extern const int embedded_default[N_EMBEDDED_VALUES]; | |||||
#define N_KLATTP 10 // this affects the phoneme data file format | #define N_KLATTP 10 // this affects the phoneme data file format | ||||
#define N_KLATTP2 14 // used in vowel files, with extra parameters for future extensions | #define N_KLATTP2 14 // used in vowel files, with extra parameters for future extensions | ||||
extern unsigned char *wavefile_data; | extern unsigned char *wavefile_data; | ||||
extern int samplerate; | extern int samplerate; | ||||
extern int samplerate_native; | |||||
#define N_ECHO_BUF 5500 // max of 250mS at 22050 Hz | #define N_ECHO_BUF 5500 // max of 250mS at 22050 Hz | ||||
extern int echo_head; | extern int echo_head; | ||||
int DoSample3(PHONEME_DATA *phdata, int length_mod, int amp); | 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 DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_LIST *plist, int modulation); | ||||
int PauseLength(int pause, int control); | int PauseLength(int pause, int control); | ||||
const char *WordToString(unsigned int word); | |||||
const char *WordToString(char buf[5], unsigned int word); | |||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
} | } |
{ | { | ||||
static const unsigned char stress_amps_be[8] = { 12, 10, 8, 8, 0, 0, 16, 17 }; | static const unsigned char stress_amps_be[8] = { 12, 10, 8, 8, 0, 0, 16, 17 }; | ||||
static const short stress_lengths_be[8] = { 160, 140, 200, 140, 0, 0, 240, 160 }; | static const short stress_lengths_be[8] = { 160, 140, 200, 140, 0, 0, 240, 160 }; | ||||
static wchar_t vowels_be[] = { // offset by 0x420 -- а е ё о у ы э ю я і | |||||
static const wchar_t vowels_be[] = { // offset by 0x420 -- а е ё о у ы э ю я і | |||||
0x10, 0x15, 0x31, 0x1e, 0x23, 0x2b, 0x2d, 0x2e, 0x2f, 0x36, 0 | 0x10, 0x15, 0x31, 0x1e, 0x23, 0x2b, 0x2d, 0x2e, 0x2f, 0x36, 0 | ||||
}; | }; | ||||
static const unsigned char consonants_be[] = { // б в г д ж з й к л м н п р с т ф х ц ч ш ў | static const unsigned char consonants_be[] = { // б в г д ж з й к л м н п р с т ф х ц ч ш ў |
extern espeak_ng_TEXT_DECODER *p_decoder; | extern espeak_ng_TEXT_DECODER *p_decoder; | ||||
extern int dictionary_skipwords; | extern int dictionary_skipwords; | ||||
extern int (*uri_callback)(int, const char *, const char *); | |||||
extern int (*phoneme_callback)(const char *); | |||||
#define LEADING_2_BITS 0xC0 // 0b11000000 | #define LEADING_2_BITS 0xC0 // 0b11000000 | ||||
#define UTF8_TAIL_BITS 0x80 // 0b10000000 | #define UTF8_TAIL_BITS 0x80 // 0b10000000 | ||||
char hangul_buf[12]; | char hangul_buf[12]; | ||||
// speak in the language for this alphabet (or English) | // speak in the language for this alphabet (or English) | ||||
ph_buf[2] = SetTranslator3(WordToString2(language)); | |||||
char word_buf[5]; | |||||
ph_buf[2] = SetTranslator3(WordToString2(word_buf, language)); | |||||
if (translator3 != NULL) { | if (translator3 != NULL) { | ||||
int code; | int code; |
} voice_t; | } voice_t; | ||||
extern espeak_VOICE current_voice_selected; | |||||
extern voice_t *voice; | extern voice_t *voice; | ||||
extern int tone_points[12]; | extern int tone_points[12]; | ||||
static int n_voices_list = 0; | static int n_voices_list = 0; | ||||
static espeak_VOICE *voices_list[N_VOICES_LIST]; | static espeak_VOICE *voices_list[N_VOICES_LIST]; | ||||
espeak_VOICE current_voice_selected; | |||||
static espeak_VOICE current_voice_selected; | |||||
#define N_VOICE_VARIANTS 12 | #define N_VOICE_VARIANTS 12 | ||||
static const char variants_either[N_VOICE_VARIANTS] = { 1, 2, 12, 3, 13, 4, 14, 5, 11, 0 }; | static const char variants_either[N_VOICE_VARIANTS] = { 1, 2, 12, 3, 13, 4, 14, 5, 11, 0 }; | ||||
voice->voicing = 64; | voice->voicing = 64; | ||||
voice->consonant_amp = 90; // change from 100 to 90 for v.1.47 | voice->consonant_amp = 90; // change from 100 to 90 for v.1.47 | ||||
voice->consonant_ampv = 100; | voice->consonant_ampv = 100; | ||||
voice->samplerate = samplerate_native; | |||||
voice->samplerate = samplerate; | |||||
memset(voice->klattv, 0, sizeof(voice->klattv)); | memset(voice->klattv, 0, sizeof(voice->klattv)); | ||||
speed.fast_settings = espeakRATE_MAXIMUM; | speed.fast_settings = espeakRATE_MAXIMUM; | ||||
if ((voice_select2.languages == NULL) || (voice_select2.languages[0] == 0)) { | if ((voice_select2.languages == NULL) || (voice_select2.languages[0] == 0)) { | ||||
// no language is specified. Get language from the named voice | // no language is specified. Get language from the named voice | ||||
static char buf[60]; | |||||
MAKE_MEM_UNDEFINED(&buf, sizeof(buf)); | |||||
char buf[60]; | |||||
if (voice_select2.name == NULL) { | if (voice_select2.name == NULL) { | ||||
if ((voice_select2.name = voice_select2.identifier) == NULL) | if ((voice_select2.name = voice_select2.identifier) == NULL) |
static int PHASE_INC_FACTOR; | static int PHASE_INC_FACTOR; | ||||
int samplerate = 0; // this is set by Wavegeninit() | int samplerate = 0; // this is set by Wavegeninit() | ||||
int samplerate_native = 0; | |||||
static wavegen_peaks_t peaks[N_PEAKS]; | static wavegen_peaks_t peaks[N_PEAKS]; | ||||
static int peak_harmonic[N_PEAKS]; | static int peak_harmonic[N_PEAKS]; | ||||
int wcmdq_tail = 0; | int wcmdq_tail = 0; | ||||
// pitch,speed, | // pitch,speed, | ||||
int embedded_default[N_EMBEDDED_VALUES] = { 0, 50, espeakRATE_NORMAL, 100, 50, 0, 0, 0, espeakRATE_NORMAL, 0, 0, 0, 0, 0, 0 }; | |||||
const int embedded_default[N_EMBEDDED_VALUES] = { 0, 50, espeakRATE_NORMAL, 100, 50, 0, 0, 0, espeakRATE_NORMAL, 0, 0, 0, 0, 0, 0 }; | |||||
static int embedded_max[N_EMBEDDED_VALUES] = { 0, 0x7fff, 750, 300, 99, 99, 99, 0, 750, 0, 0, 0, 0, 4, 0 }; | static int embedded_max[N_EMBEDDED_VALUES] = { 0, 0x7fff, 750, 300, 99, 99, 99, 0, 750, 0, 0, 0, 0, 4, 0 }; | ||||
#if HAVE_SONIC_H | #if HAVE_SONIC_H | ||||
wavemult_fact = 60; // default | wavemult_fact = 60; // default | ||||
wvoice = NULL; | wvoice = NULL; | ||||
samplerate = samplerate_native = rate; | |||||
samplerate = rate; | |||||
PHASE_INC_FACTOR = 0x8000000 / samplerate; // assumes pitch is Hz*32 | PHASE_INC_FACTOR = 0x8000000 / samplerate; // assumes pitch is Hz*32 | ||||
Flutter_inc = (64 * samplerate)/rate; | Flutter_inc = (64 * samplerate)/rate; | ||||
samplecount = 0; | samplecount = 0; |