mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-10-31 05:35:35 +00:00
code cleanup: next bunch (#1599)
Some warnings, some globals hunting. Including fixes for asserts misuse (possible fatal for async in release builds).
This commit is contained in:
@@ -54,6 +54,7 @@ if (NOT MSVC)
|
||||
"-Wmissing-prototypes"
|
||||
"-Wint-conversion"
|
||||
"-Wimplicit"
|
||||
"-Wmisleading-indentation"
|
||||
)
|
||||
endif()
|
||||
target_compile_definitions(espeak-ng PRIVATE "LIBESPEAK_NG_EXPORT=1")
|
||||
|
||||
@@ -2789,4 +2789,4 @@ static int CalculateSample(unsigned char c3, int c1) {
|
||||
c2 = c2 >> 16; // sign extend
|
||||
|
||||
return (c1 & 0xff) + c2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
|
||||
}
|
||||
c = ' ';
|
||||
} else if (rb == RULE_ENDING) {
|
||||
static const char *flag_chars = "eipvdfq tba ";
|
||||
static const char flag_chars[] = "eipvdfq tba ";
|
||||
flags = ((rule[0] & 0x7f)<< 8) + (rule[1] & 0x7f);
|
||||
suffix_char = 'S';
|
||||
if (flags & (SUFX_P >> 8))
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
#include "synthesize.h" // for STRESS_IS_PRIMARY, phoneme...
|
||||
#include "translate.h" // for Translator, utf8_in, LANGU...
|
||||
|
||||
static int LookupFlags(Translator *tr, const char *word, unsigned int **flags_out);
|
||||
static void DollarRule(char *word[], char *word_start, int consumed, int group_length, char *word_buf, Translator *tr, unsigned int *flags, int command, int *failed, int *add_points);
|
||||
static int LookupFlags(Translator *tr, const char *word, unsigned int flags_out[2]);
|
||||
static void DollarRule(char *word[], char *word_start, int consumed, int group_length, char *word_buf, Translator *tr, int command, int *failed, int *add_points);
|
||||
|
||||
typedef struct {
|
||||
int points;
|
||||
@@ -63,7 +63,7 @@ static const unsigned short diereses_list[7] = { 0xe4, 0xeb, 0xef, 0xf6, 0xfc, 0
|
||||
// convert characters to an approximate 7 bit ascii equivalent
|
||||
// used for checking for vowels (up to 0x259=schwa)
|
||||
#define N_REMOVE_ACCENT 0x25e
|
||||
static unsigned char remove_accent[N_REMOVE_ACCENT] = {
|
||||
static const unsigned char remove_accent[N_REMOVE_ACCENT] = {
|
||||
'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', // 0c0
|
||||
'd', 'n', 'o', 'o', 'o', 'o', 'o', 0, 'o', 'u', 'u', 'u', 'u', 'y', 't', 's', // 0d0
|
||||
'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', // 0e0
|
||||
@@ -396,7 +396,7 @@ void DecodePhonemes(const char *inptr, char *outptr)
|
||||
unsigned char c;
|
||||
unsigned int mnem;
|
||||
PHONEME_TAB *ph;
|
||||
static const char *stress_chars = "==,,'* ";
|
||||
static const char stress_chars[] = "==,,'* ";
|
||||
|
||||
sprintf(outptr, "* ");
|
||||
while ((phcode = *inptr++) > 0) {
|
||||
@@ -551,7 +551,7 @@ const char *GetTranslatedPhonemeString(int phoneme_mode)
|
||||
char phon_buf2[30];
|
||||
PHONEME_LIST *plist;
|
||||
|
||||
static const char *stress_chars = "==,,''";
|
||||
static const char stress_chars[] = "==,,''";
|
||||
|
||||
if (phon_out_buf == NULL) {
|
||||
phon_out_size = N_PHON_OUT;
|
||||
@@ -1480,10 +1480,9 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
int n_bytes;
|
||||
int add_points;
|
||||
int command;
|
||||
unsigned int *flags = NULL;
|
||||
|
||||
MatchRecord match;
|
||||
static MatchRecord best;
|
||||
MatchRecord best;
|
||||
|
||||
int total_consumed; // letters consumed for best match
|
||||
|
||||
@@ -1699,7 +1698,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
else
|
||||
failed = 1;
|
||||
} else if (((command & 0xf0) == 0x20) || (command == DOLLAR_LIST)) {
|
||||
DollarRule(word, word_start, consumed, group_length, word_buf, tr, flags, command, &failed, &add_points);
|
||||
DollarRule(word, word_start, consumed, group_length, word_buf, tr, command, &failed, &add_points);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -1888,7 +1887,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
pre_ptr++;
|
||||
command = *rule++;
|
||||
if ((command == DOLLAR_LIST) || ((command & 0xf0) == 0x20)) {
|
||||
DollarRule(word, word_start, consumed, group_length, word_buf, tr, flags, command, &failed, &add_points);
|
||||
DollarRule(word, word_start, consumed, group_length, word_buf, tr, command, &failed, &add_points);
|
||||
}
|
||||
break;
|
||||
case RULE_SYLLABLE:
|
||||
@@ -2842,7 +2841,7 @@ int Lookup(Translator *tr, const char *word, char *ph_out)
|
||||
return flags0;
|
||||
}
|
||||
|
||||
static int LookupFlags(Translator *tr, const char *word, unsigned int **flags_out)
|
||||
static int LookupFlags(Translator *tr, const char *word, unsigned int flags_out[2])
|
||||
{
|
||||
char buf[100];
|
||||
static unsigned int flags[2];
|
||||
@@ -2850,7 +2849,8 @@ static int LookupFlags(Translator *tr, const char *word, unsigned int **flags_ou
|
||||
|
||||
flags[0] = flags[1] = 0;
|
||||
LookupDictList(tr, &word1, buf, flags, 0, NULL);
|
||||
*flags_out = flags;
|
||||
flags_out[0] = flags[0];
|
||||
flags_out[1] = flags[1];
|
||||
return flags[0];
|
||||
}
|
||||
|
||||
@@ -2979,14 +2979,15 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
||||
return end_flags;
|
||||
}
|
||||
|
||||
static void DollarRule(char *word[], char *word_start, int consumed, int group_length, char *word_buf, Translator *tr, unsigned int *flags, int command, int *failed, int *add_points) {
|
||||
static void DollarRule(char *word[], char *word_start, int consumed, int group_length, char *word_buf, Translator *tr, int command, int *failed, int *add_points) {
|
||||
// $list or $p_alt
|
||||
// make a copy of the word up to the post-match characters
|
||||
int ix = *word - word_start + consumed + group_length + 1;
|
||||
memcpy(word_buf, word_start-1, ix);
|
||||
word_buf[ix] = ' ';
|
||||
word_buf[ix+1] = 0;
|
||||
LookupFlags(tr, &word_buf[1], &flags);
|
||||
unsigned int flags[2];
|
||||
LookupFlags(tr, &word_buf[1], flags);
|
||||
|
||||
if ((command == DOLLAR_LIST) && (flags[0] & FLAG_FOUND) && !(flags[1] & FLAG_ONLY))
|
||||
*add_points = 23;
|
||||
@@ -2994,4 +2995,4 @@ static void DollarRule(char *word[], char *word_start, int consumed, int group_l
|
||||
*add_points = 23;
|
||||
else
|
||||
*failed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,9 +83,15 @@ void event_init(void)
|
||||
pthread_mutex_init(&my_mutex, (const pthread_mutexattr_t *)NULL);
|
||||
init();
|
||||
|
||||
assert(-1 != pthread_cond_init(&my_cond_start_is_required, NULL));
|
||||
assert(-1 != pthread_cond_init(&my_cond_stop_is_required, NULL));
|
||||
assert(-1 != pthread_cond_init(&my_cond_stop_is_acknowledged, NULL));
|
||||
int a_status;
|
||||
|
||||
a_status = pthread_cond_init(&my_cond_start_is_required, NULL);
|
||||
assert(-1 != a_status);
|
||||
a_status = pthread_cond_init(&my_cond_stop_is_required, NULL);
|
||||
assert(-1 != a_status);
|
||||
a_status = pthread_cond_init(&my_cond_stop_is_acknowledged, NULL);
|
||||
assert(-1 != a_status);
|
||||
(void)a_status;
|
||||
|
||||
pthread_attr_t a_attrib;
|
||||
|
||||
@@ -222,7 +228,7 @@ espeak_ng_STATUS event_declare(espeak_EVENT *event)
|
||||
return status;
|
||||
}
|
||||
|
||||
espeak_ng_STATUS event_clear_all()
|
||||
espeak_ng_STATUS event_clear_all(void)
|
||||
{
|
||||
espeak_ng_STATUS status;
|
||||
if ((status = pthread_mutex_lock(&my_mutex)) != ENS_OK)
|
||||
@@ -352,7 +358,7 @@ static espeak_ng_STATUS push(void *the_data)
|
||||
return ENS_OK;
|
||||
}
|
||||
|
||||
static void *pop()
|
||||
static void *pop(void)
|
||||
{
|
||||
void *the_data = NULL;
|
||||
|
||||
@@ -373,7 +379,7 @@ static void *pop()
|
||||
}
|
||||
|
||||
|
||||
static void init()
|
||||
static void init(void)
|
||||
{
|
||||
while (event_delete((espeak_EVENT *)pop()))
|
||||
;
|
||||
@@ -381,7 +387,7 @@ static void init()
|
||||
node_counter = 0;
|
||||
}
|
||||
|
||||
void event_terminate()
|
||||
void event_terminate(void)
|
||||
{
|
||||
if (thread_inited) {
|
||||
my_terminate_is_required = true;
|
||||
@@ -408,7 +414,9 @@ void clock_gettime2(struct timespec *ts)
|
||||
if (!ts)
|
||||
return;
|
||||
|
||||
assert(gettimeofday(&tv, NULL) != -1);
|
||||
int a_status = gettimeofday(&tv, NULL);
|
||||
assert(a_status != -1);
|
||||
(void)a_status;
|
||||
ts->tv_sec = tv.tv_sec;
|
||||
ts->tv_nsec = tv.tv_usec*1000;
|
||||
}
|
||||
|
||||
+36
-24
@@ -71,15 +71,19 @@ enum {
|
||||
MAX_INACTIVITY_CHECK = 2
|
||||
};
|
||||
|
||||
void fifo_init()
|
||||
void fifo_init(void)
|
||||
{
|
||||
// security
|
||||
pthread_mutex_init(&my_mutex, (const pthread_mutexattr_t *)NULL);
|
||||
init(0);
|
||||
|
||||
assert(-1 != pthread_cond_init(&my_cond_command_is_running, NULL));
|
||||
assert(-1 != pthread_cond_init(&my_cond_start_is_required, NULL));
|
||||
assert(-1 != pthread_cond_init(&my_cond_stop_is_acknowledged, NULL));
|
||||
int a_status;
|
||||
a_status = pthread_cond_init(&my_cond_command_is_running, NULL);
|
||||
assert(-1 != a_status);
|
||||
a_status = pthread_cond_init(&my_cond_start_is_required, NULL);
|
||||
assert(-1 != a_status);
|
||||
a_status = pthread_cond_init(&my_cond_stop_is_acknowledged, NULL);
|
||||
assert(-1 != a_status);
|
||||
|
||||
pthread_attr_t a_attrib;
|
||||
if (pthread_attr_init(&a_attrib)
|
||||
@@ -95,7 +99,9 @@ void fifo_init()
|
||||
pthread_attr_destroy(&a_attrib);
|
||||
|
||||
// leave once the thread is actually started
|
||||
assert(-1 != pthread_mutex_lock(&my_mutex));
|
||||
a_status = pthread_mutex_lock(&my_mutex);
|
||||
assert(-1 != a_status);
|
||||
(void)a_status;
|
||||
while (my_stop_is_acknowledged == false) {
|
||||
while ((pthread_cond_wait(&my_cond_stop_is_acknowledged, &my_mutex) == -1) && errno == EINTR)
|
||||
;
|
||||
@@ -169,7 +175,7 @@ espeak_ng_STATUS fifo_add_commands(t_espeak_command *command1, t_espeak_command
|
||||
return ENS_OK;
|
||||
}
|
||||
|
||||
espeak_ng_STATUS fifo_stop()
|
||||
espeak_ng_STATUS fifo_stop(void)
|
||||
{
|
||||
if (!thread_inited) return ENS_OK;
|
||||
espeak_ng_STATUS status;
|
||||
@@ -197,7 +203,7 @@ espeak_ng_STATUS fifo_stop()
|
||||
return ENS_OK;
|
||||
}
|
||||
|
||||
int fifo_is_busy()
|
||||
int fifo_is_busy(void)
|
||||
{
|
||||
if (!thread_inited) return false;
|
||||
pthread_mutex_lock(&my_mutex);
|
||||
@@ -206,7 +212,7 @@ int fifo_is_busy()
|
||||
return running;
|
||||
}
|
||||
|
||||
static int sleep_until_start_request_or_inactivity()
|
||||
static int sleep_until_start_request_or_inactivity(void)
|
||||
{
|
||||
int a_start_is_required = false;
|
||||
|
||||
@@ -223,7 +229,6 @@ static int sleep_until_start_request_or_inactivity()
|
||||
i++;
|
||||
|
||||
struct timespec ts;
|
||||
struct timeval tv;
|
||||
|
||||
clock_gettime2(&ts);
|
||||
|
||||
@@ -233,8 +238,6 @@ static int sleep_until_start_request_or_inactivity()
|
||||
&& errno == EINTR)
|
||||
continue;
|
||||
|
||||
assert(gettimeofday(&tv, NULL) != -1);
|
||||
|
||||
if (err == 0)
|
||||
a_start_is_required = true;
|
||||
}
|
||||
@@ -242,7 +245,7 @@ static int sleep_until_start_request_or_inactivity()
|
||||
return a_start_is_required;
|
||||
}
|
||||
|
||||
static espeak_ng_STATUS close_stream()
|
||||
static espeak_ng_STATUS close_stream(void)
|
||||
{
|
||||
espeak_ng_STATUS status = pthread_mutex_lock(&my_mutex);
|
||||
if (status != ENS_OK)
|
||||
@@ -293,11 +296,16 @@ static void *say_thread(void *p)
|
||||
{
|
||||
(void)p; // unused
|
||||
|
||||
int a_status;
|
||||
|
||||
// announce that thread is started
|
||||
assert(-1 != pthread_mutex_lock(&my_mutex));
|
||||
a_status = pthread_mutex_lock(&my_mutex);
|
||||
assert(-1 != a_status);
|
||||
my_stop_is_acknowledged = true;
|
||||
assert(-1 != pthread_cond_signal(&my_cond_stop_is_acknowledged));
|
||||
assert(-1 != pthread_mutex_unlock(&my_mutex));
|
||||
a_status = pthread_cond_signal(&my_cond_stop_is_acknowledged);
|
||||
assert(-1 != a_status);
|
||||
a_status = pthread_mutex_unlock(&my_mutex);
|
||||
assert(-1 != a_status);
|
||||
|
||||
bool look_for_inactivity = false;
|
||||
|
||||
@@ -310,7 +318,7 @@ static void *say_thread(void *p)
|
||||
}
|
||||
look_for_inactivity = true;
|
||||
|
||||
int a_status = pthread_mutex_lock(&my_mutex);
|
||||
a_status = pthread_mutex_lock(&my_mutex);
|
||||
assert(!a_status);
|
||||
|
||||
if (!a_start_is_required) {
|
||||
@@ -323,11 +331,13 @@ static void *say_thread(void *p)
|
||||
|
||||
my_command_is_running = true;
|
||||
|
||||
assert(-1 != pthread_cond_broadcast(&my_cond_command_is_running));
|
||||
assert(-1 != pthread_mutex_unlock(&my_mutex));
|
||||
a_status = pthread_cond_broadcast(&my_cond_command_is_running);
|
||||
assert(-1 != a_status);
|
||||
a_status = pthread_mutex_unlock(&my_mutex);
|
||||
assert(-1 != a_status);
|
||||
|
||||
while (my_command_is_running && !my_terminate_is_required) {
|
||||
int a_status = pthread_mutex_lock(&my_mutex);
|
||||
a_status = pthread_mutex_lock(&my_mutex);
|
||||
assert(!a_status);
|
||||
t_espeak_command *a_command = (t_espeak_command *)pop();
|
||||
|
||||
@@ -352,23 +362,25 @@ static void *say_thread(void *p)
|
||||
// and waiting for my_cond_stop_is_acknowledged
|
||||
init(1);
|
||||
|
||||
assert(-1 != pthread_mutex_lock(&my_mutex));
|
||||
a_status = pthread_mutex_lock(&my_mutex);
|
||||
assert(-1 != a_status);
|
||||
my_start_is_required = false;
|
||||
|
||||
// acknowledge the stop request
|
||||
my_stop_is_acknowledged = true;
|
||||
int a_status = pthread_cond_signal(&my_cond_stop_is_acknowledged);
|
||||
a_status = pthread_cond_signal(&my_cond_stop_is_acknowledged);
|
||||
assert(a_status != -1);
|
||||
pthread_mutex_unlock(&my_mutex);
|
||||
|
||||
}
|
||||
// and wait for the next start
|
||||
}
|
||||
(void)a_status;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int fifo_is_command_enabled()
|
||||
int fifo_is_command_enabled(void)
|
||||
{
|
||||
return 0 == my_stop_is_required;
|
||||
}
|
||||
@@ -413,7 +425,7 @@ static espeak_ng_STATUS push(t_espeak_command *the_command)
|
||||
return ENS_OK;
|
||||
}
|
||||
|
||||
static t_espeak_command *pop()
|
||||
static t_espeak_command *pop(void)
|
||||
{
|
||||
t_espeak_command *the_command = NULL;
|
||||
|
||||
@@ -446,7 +458,7 @@ static void init(int process_parameters)
|
||||
node_counter = 0;
|
||||
}
|
||||
|
||||
void fifo_terminate()
|
||||
void fifo_terminate(void)
|
||||
{
|
||||
if (!thread_inited) return;
|
||||
|
||||
|
||||
@@ -770,7 +770,6 @@ static void CalcPitches_Tone(Translator *tr)
|
||||
{
|
||||
PHONEME_LIST *p;
|
||||
int ix;
|
||||
int count_stressed = 0;
|
||||
int final_stressed = 0;
|
||||
|
||||
int tone_ph;
|
||||
@@ -791,7 +790,6 @@ static void CalcPitches_Tone(Translator *tr)
|
||||
for (ix = 0; ix < n_phoneme_list; ix++, p++) {
|
||||
if ((p->type == phVOWEL) && (p->stresslevel >= 4)) {
|
||||
final_stressed = ix;
|
||||
count_stressed++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ static klatt_global_t kt_globals;
|
||||
|
||||
#define NUMBER_OF_SAMPLES 100
|
||||
|
||||
static int scale_wav_tab[] = { 45, 38, 45, 45, 55, 45 }; // scale output from different voicing sources
|
||||
static const int scale_wav_tab[] = { 45, 38, 45, 45, 55, 45 }; // scale output from different voicing sources
|
||||
|
||||
// For testing, this can be overwritten in KlattInit()
|
||||
static const short natural_samples2[256] = {
|
||||
@@ -547,7 +547,7 @@ static void frame_init(klatt_frame_ptr frame)
|
||||
to Kopen.
|
||||
*/
|
||||
|
||||
static double impulsive_source()
|
||||
static double impulsive_source(void)
|
||||
{
|
||||
static const double doublet[] = { 0.0, 13000000.0, -13000000.0 };
|
||||
static double vwave;
|
||||
@@ -567,7 +567,7 @@ static double impulsive_source()
|
||||
spectral zero around 800 Hz, magic constants a,b reset pitch synchronously.
|
||||
*/
|
||||
|
||||
static double natural_source()
|
||||
static double natural_source(void)
|
||||
{
|
||||
double lgtemp;
|
||||
static double vwave;
|
||||
@@ -1068,7 +1068,7 @@ static void SetSynth_Klatt(int length, frame_t *fr1, frame_t *fr2, voice_t *wvoi
|
||||
}
|
||||
}
|
||||
|
||||
void KlattInit()
|
||||
void KlattInit(void)
|
||||
{
|
||||
|
||||
static const short formant_hz[10] = { 280, 688, 1064, 2806, 3260, 3700, 6500, 7000, 8000, 280 };
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
static int CheckTranslator(Translator *tr, const MNEM_TAB *keyword_tab, int key);
|
||||
static int LookupTune(const char *name);
|
||||
|
||||
extern const MNEM_TAB langopts_tab[];
|
||||
|
||||
void LoadLanguageOptions(Translator *translator, int key, char *keyValue ) {
|
||||
if (CheckTranslator(translator, langopts_tab, key) != 0) {
|
||||
return;
|
||||
@@ -232,4 +230,4 @@ int CheckTranslator(Translator *tr, const MNEM_TAB *keyword_tab, int key)
|
||||
|
||||
fprintf(stderr, "Cannot set %s: language not set, or is invalid.\n", LookupMnemName(keyword_tab, key));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_b
|
||||
|
||||
|
||||
// this list must be in ascending order
|
||||
static unsigned short derived_letters[] = {
|
||||
static const unsigned short derived_letters[] = {
|
||||
0x00aa, 'a'+L_SUP,
|
||||
0x00b2, '2'+L_SUP,
|
||||
0x00b3, '3'+L_SUP,
|
||||
@@ -763,14 +763,13 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
|
||||
int value;
|
||||
int subtract;
|
||||
int repeat = 0;
|
||||
int n_digits = 0;
|
||||
char *word_start;
|
||||
int num_control = 0;
|
||||
unsigned int flags[2];
|
||||
char ph_roman[30];
|
||||
char number_chars[N_WORD_BYTES];
|
||||
|
||||
static const char *roman_numbers = "ixcmvld";
|
||||
static const char roman_numbers[] = "ixcmvld";
|
||||
static const int roman_values[] = { 1, 10, 100, 1000, 5, 50, 500 };
|
||||
|
||||
acc = 0;
|
||||
@@ -817,7 +816,6 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
|
||||
else
|
||||
acc += prev;
|
||||
prev = value;
|
||||
n_digits++;
|
||||
}
|
||||
|
||||
if (IsDigit09(word[0]))
|
||||
|
||||
@@ -590,4 +590,4 @@ if (ph->type == phVOWEL) {
|
||||
// re-interpret the changed phoneme
|
||||
// But it doesn't obey a second ChangePhoneme()
|
||||
InterpretPhoneme(tr, 0x100, plist3, phdata, worddata);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ static void mixWaveFile(WGEN_DATA *wdata, unsigned int maxNumSamples, sample* sa
|
||||
}
|
||||
}
|
||||
|
||||
static bool isKlattFrameFollowing() {
|
||||
static bool isKlattFrameFollowing(void) {
|
||||
// eSpeak implements its command queue with a circular buffer.
|
||||
// Thus to walk it, we start from the head, walking to the tail, which may wrap around to the beginning of the buffer as it is circular.
|
||||
for(int i=(wcmdq_head+1)%N_WCMDQ;i!=wcmdq_tail;i=(i+1)%N_WCMDQ) {
|
||||
@@ -93,17 +93,17 @@ static void fillSpeechPlayerFrame(WGEN_DATA *wdata, voice_t *wvoice, frame_t * e
|
||||
spFrame->endVoicePitch=spFrame->voicePitch;
|
||||
}
|
||||
|
||||
void KlattInitSP() {
|
||||
void KlattInitSP(void) {
|
||||
speechPlayerHandle=speechPlayer_initialize(22050);
|
||||
}
|
||||
|
||||
void KlattFiniSP() {
|
||||
void KlattFiniSP(void) {
|
||||
if (speechPlayerHandle)
|
||||
speechPlayer_terminate(speechPlayerHandle);
|
||||
speechPlayerHandle = NULL;
|
||||
}
|
||||
|
||||
void KlattResetSP() {
|
||||
void KlattResetSP(void) {
|
||||
KlattFiniSP();
|
||||
KlattInitSP();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "synthesize.h"
|
||||
#include "translate.h"
|
||||
|
||||
static void SetSpeedFactors(voice_t *voice, int x, int *speed1, int *speed2, int *speed3);
|
||||
static void SetSpeedFactors(voice_t *voice, int x, int speeds[3]);
|
||||
static void SetSpeedMods(SPEED_FACTORS *speed, int voiceSpeedF1, int wpm, int x);
|
||||
static void SetSpeedMultiplier(int *x, int *wpm);
|
||||
|
||||
@@ -46,7 +46,7 @@ extern int saved_parameters[];
|
||||
|
||||
// convert from words-per-minute to internal speed factor
|
||||
// Use this to calibrate speed for wpm 80-450 (espeakRATE_MINIMUM - espeakRATE_MAXIMUM)
|
||||
static unsigned char speed_lookup[] = {
|
||||
static const unsigned char speed_lookup[] = {
|
||||
255, 255, 255, 255, 255, // 80
|
||||
253, 249, 245, 242, 238, // 85
|
||||
235, 232, 228, 225, 222, // 90
|
||||
@@ -106,7 +106,7 @@ static unsigned char speed_lookup[] = {
|
||||
};
|
||||
|
||||
// speed_factor1 adjustments for speeds 350 to 374: pauses
|
||||
static unsigned char pause_factor_350[] = {
|
||||
static const unsigned char pause_factor_350[] = {
|
||||
22, 22, 22, 22, 22, 22, 22, 21, 21, 21, // 350
|
||||
21, 20, 20, 19, 19, 18, 17, 16, 15, 15, // 360
|
||||
15, 15, 15, 15, 15 // 370
|
||||
@@ -114,7 +114,7 @@ static unsigned char pause_factor_350[] = {
|
||||
|
||||
// wav_factor adjustments for speeds 350 to 450
|
||||
// Use this to calibrate speed for wpm 350-450
|
||||
static unsigned char wav_factor_350[] = {
|
||||
static const unsigned char wav_factor_350[] = {
|
||||
120, 121, 120, 119, 119, // 350
|
||||
118, 118, 117, 116, 116, // 355
|
||||
115, 114, 113, 112, 112, // 360
|
||||
@@ -138,9 +138,7 @@ static unsigned char wav_factor_350[] = {
|
||||
45 // 450
|
||||
};
|
||||
|
||||
static int speed1 = 130;
|
||||
static int speed2 = 121;
|
||||
static int speed3 = 118;
|
||||
static int len_speeds[3] = { 130, 121, 118 };
|
||||
|
||||
void SetSpeed(int control)
|
||||
{
|
||||
@@ -174,9 +172,9 @@ void SetSpeed(int control)
|
||||
// The eSpeak output will be speeded up by at least x2
|
||||
x = 73;
|
||||
if (control & 1) {
|
||||
speed1 = (x * voice->speedf1)/256;
|
||||
speed2 = (x * voice->speedf2)/256;
|
||||
speed3 = (x * voice->speedf3)/256;
|
||||
len_speeds[0] = (x * voice->speedf1)/256;
|
||||
len_speeds[1] = (x * voice->speedf2)/256;
|
||||
len_speeds[2] = (x * voice->speedf3)/256;
|
||||
}
|
||||
if (control & 2) {
|
||||
double sonic;
|
||||
@@ -201,7 +199,7 @@ void SetSpeed(int control)
|
||||
SetSpeedMultiplier(&x, &wpm);
|
||||
|
||||
if (control & 1) {
|
||||
SetSpeedFactors(voice, x, &speed1, &speed2, &speed3);
|
||||
SetSpeedFactors(voice, x, len_speeds);
|
||||
}
|
||||
|
||||
if (control & 2) {
|
||||
@@ -229,16 +227,16 @@ static void SetSpeedMultiplier(int *x, int *wpm) {
|
||||
*x = 6;
|
||||
}
|
||||
|
||||
static void SetSpeedFactors(voice_t *voice, int x, int *speed1, int *speed2, int *speed3) {
|
||||
static void SetSpeedFactors(voice_t *voice, int x, int speeds[3]) {
|
||||
// set speed factors for different syllable positions within a word
|
||||
// these are used in CalcLengths()
|
||||
*speed1 = (x * voice->speedf1)/256;
|
||||
*speed2 = (x * voice->speedf2)/256;
|
||||
*speed3 = (x * voice->speedf3)/256;
|
||||
speeds[0] = (x * voice->speedf1)/256;
|
||||
speeds[1] = (x * voice->speedf2)/256;
|
||||
speeds[2] = (x * voice->speedf3)/256;
|
||||
|
||||
if (x <= 7) {
|
||||
*speed1 = x;
|
||||
*speed2 = *speed3 = x - 1;
|
||||
speeds[0] = x;
|
||||
speeds[1] = speeds[2] = x - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,7 +521,7 @@ void CalcLengths(Translator *tr)
|
||||
p->length = prev->length;
|
||||
|
||||
if (p->type == phLIQUID)
|
||||
p->length = speed1;
|
||||
p->length = len_speeds[0];
|
||||
|
||||
if (next->type == phVSTOP)
|
||||
p->length = (p->length * 160)/100;
|
||||
@@ -615,11 +613,11 @@ void CalcLengths(Translator *tr)
|
||||
}
|
||||
|
||||
if (more_syllables == 0)
|
||||
length_mod *= speed1;
|
||||
length_mod *= len_speeds[0];
|
||||
else if (more_syllables == 1)
|
||||
length_mod *= speed2;
|
||||
length_mod *= len_speeds[1];
|
||||
else
|
||||
length_mod *= speed3;
|
||||
length_mod *= len_speeds[2];
|
||||
|
||||
length_mod = length_mod / 128;
|
||||
|
||||
@@ -654,9 +652,9 @@ void CalcLengths(Translator *tr)
|
||||
length_mod = length_mod * (256 + (280 - len)/3)/256;
|
||||
}
|
||||
|
||||
if (length_mod > tr->langopts.max_lengthmod*speed1) {
|
||||
if (length_mod > tr->langopts.max_lengthmod*len_speeds[0]) {
|
||||
// limit the vowel length adjustment for some languages
|
||||
length_mod = (tr->langopts.max_lengthmod*speed1);
|
||||
length_mod = (tr->langopts.max_lengthmod*len_speeds[0]);
|
||||
}
|
||||
|
||||
length_mod = length_mod / 128;
|
||||
|
||||
@@ -36,13 +36,11 @@
|
||||
#include "synthesize.h" // for KLATT_AV, KLATT_Kopen, N_KLATTP2
|
||||
#include "voice.h" // for N_PEAKS
|
||||
|
||||
static int frame_width;
|
||||
|
||||
static int default_freq[N_PEAKS] =
|
||||
static const int default_freq[N_PEAKS] =
|
||||
{ 200, 500, 1200, 3000, 3500, 4000, 6900, 7800, 9000 };
|
||||
static int default_width[N_PEAKS] =
|
||||
static const int default_width[N_PEAKS] =
|
||||
{ 750, 500, 550, 550, 600, 700, 700, 700, 700 };
|
||||
static int default_klt_bw[N_PEAKS] =
|
||||
static const int default_klt_bw[N_PEAKS] =
|
||||
{ 89, 90, 140, 260, 260, 260, 500, 500, 500 };
|
||||
|
||||
static double read_double(FILE *stream)
|
||||
@@ -87,7 +85,7 @@ float polint(float xa[], float ya[], int n, float x)
|
||||
return y;
|
||||
}
|
||||
|
||||
static SpectFrame *SpectFrameCreate()
|
||||
static SpectFrame *SpectFrameCreate(void)
|
||||
{
|
||||
int ix;
|
||||
SpectFrame *frame;
|
||||
@@ -230,7 +228,7 @@ double GetFrameRms(SpectFrame *frame, int seq_amplitude)
|
||||
}
|
||||
|
||||
#pragma GCC visibility push(default)
|
||||
SpectSeq *SpectSeqCreate()
|
||||
SpectSeq *SpectSeqCreate(void)
|
||||
{
|
||||
SpectSeq *spect = malloc(sizeof(SpectSeq));
|
||||
if (!spect)
|
||||
@@ -377,9 +375,6 @@ espeak_ng_STATUS LoadSpectSeq(SpectSeq *spect, const char *filename)
|
||||
}
|
||||
spect->max_x = 9000; // disable auto-xscaling
|
||||
|
||||
frame_width = (int)((FRAME_WIDTH*spect->max_x)/MAX_DISPLAY_FREQ);
|
||||
if (frame_width > FRAME_WIDTH) frame_width = FRAME_WIDTH;
|
||||
|
||||
// start times from zero
|
||||
time_offset = spect->frames[0]->time;
|
||||
for (ix = 0; ix < spect->numframes; ix++)
|
||||
|
||||
@@ -80,7 +80,7 @@ static void *my_user_data = NULL;
|
||||
static espeak_ng_OUTPUT_MODE my_mode = ENOUTPUT_MODE_SYNCHRONOUS;
|
||||
static int out_samplerate = 0;
|
||||
static int voice_samplerate = 22050;
|
||||
static int min_buffer_length = 60; // minimum buffer length in ms
|
||||
static const int min_buffer_length = 60; // minimum buffer length in ms
|
||||
static espeak_ng_STATUS err = ENS_OK;
|
||||
|
||||
static t_espeak_callback *synth_callback = NULL;
|
||||
@@ -428,7 +428,6 @@ static espeak_ng_STATUS Synthesize(unsigned int unique_identifier, const void *t
|
||||
// Fill the buffer with output sound
|
||||
int length;
|
||||
int finished = 0;
|
||||
int count_buffers = 0;
|
||||
|
||||
if ((outbuf == NULL) || (event_list == NULL))
|
||||
return ENS_NOT_INITIALIZED;
|
||||
@@ -467,7 +466,6 @@ static espeak_ng_STATUS Synthesize(unsigned int unique_identifier, const void *t
|
||||
event_list[event_list_ix].unique_identifier = unique_identifier;
|
||||
event_list[event_list_ix].user_data = my_user_data;
|
||||
|
||||
count_buffers++;
|
||||
if ((my_mode & ENOUTPUT_MODE_SPEAK_AUDIO) == ENOUTPUT_MODE_SPEAK_AUDIO) {
|
||||
finished = create_events((short *)outbuf, length, event_list);
|
||||
if (finished < 0)
|
||||
@@ -661,7 +659,7 @@ espeak_ng_Synthesize(const void *text, size_t size,
|
||||
{
|
||||
(void)size; // unused in non-async modes
|
||||
|
||||
static unsigned int temp_identifier;
|
||||
unsigned int temp_identifier;
|
||||
|
||||
if (unique_identifier == NULL)
|
||||
unique_identifier = &temp_identifier;
|
||||
@@ -710,7 +708,7 @@ espeak_ng_SynthesizeMark(const void *text,
|
||||
{
|
||||
(void)size; // unused in non-async modes
|
||||
|
||||
static unsigned int temp_identifier;
|
||||
unsigned int temp_identifier;
|
||||
|
||||
if (unique_identifier == NULL)
|
||||
unique_identifier = &temp_identifier;
|
||||
|
||||
@@ -85,7 +85,7 @@ const char *WordToString(char buf[5], unsigned int word)
|
||||
return buf;
|
||||
}
|
||||
|
||||
void SynthesizeInit()
|
||||
void SynthesizeInit(void)
|
||||
{
|
||||
last_pitch_cmd = 0;
|
||||
last_amp_cmd = 0;
|
||||
@@ -376,7 +376,7 @@ int DoSample3(PHONEME_DATA *phdata, int length_mod, int amp)
|
||||
return len;
|
||||
}
|
||||
|
||||
static frame_t *AllocFrame()
|
||||
static frame_t *AllocFrame(void)
|
||||
{
|
||||
// Allocate a temporary spectrum frame for the wavegen queue. Use a pool which is big
|
||||
// enough to use a round-robin without checks.
|
||||
@@ -1190,9 +1190,9 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, bool resume)
|
||||
if (WcmdqFree() <= free_min)
|
||||
return 1; // wait
|
||||
|
||||
PHONEME_LIST *prev;
|
||||
PHONEME_LIST *next;
|
||||
PHONEME_LIST *next2;
|
||||
PHONEME_LIST *prev;
|
||||
PHONEME_LIST *next;
|
||||
PHONEME_LIST *next2;
|
||||
|
||||
prev = &phoneme_list[ix-1];
|
||||
next = &phoneme_list[ix+1];
|
||||
|
||||
@@ -1342,7 +1342,7 @@ Translator *SelectTranslator(const char *name)
|
||||
case L('s', 'k'): // Slovak
|
||||
case L('c', 's'): // Czech
|
||||
{
|
||||
static const char *sk_voiced = "bdgjlmnrvwzaeiouy";
|
||||
static const char sk_voiced[] = "bdgjlmnrvwzaeiouy";
|
||||
|
||||
SetupTranslator(tr, stress_lengths_sk, stress_amps_sk);
|
||||
tr->encoding = ESPEAKNG_ENCODING_ISO_8859_2;
|
||||
|
||||
@@ -231,7 +231,7 @@ static int CountSyllables(unsigned char *phonemes)
|
||||
return count;
|
||||
}
|
||||
|
||||
static void Word_EmbeddedCmd()
|
||||
static void Word_EmbeddedCmd(void)
|
||||
{
|
||||
// Process embedded commands for emphasis, sayas, and break
|
||||
int embedded_cmd;
|
||||
|
||||
@@ -64,7 +64,7 @@ static const MNEM_TAB genders[] = {
|
||||
int tone_points[12] = { 600, 170, 1200, 135, 2000, 110, 3000, 110, -1, 0 };
|
||||
|
||||
// limit the rate of change for each formant number
|
||||
static int formant_rate_22050[9] = { 240, 170, 170, 170, 170, 170, 170, 170, 170 }; // values for 22kHz sample rate
|
||||
static const int formant_rate_22050[9] = { 240, 170, 170, 170, 170, 170, 170, 170, 170 }; // values for 22kHz sample rate
|
||||
int formant_rate[9]; // values adjusted for actual sample rate
|
||||
|
||||
#define DEFAULT_LANGUAGE_PRIORITY 5
|
||||
@@ -1338,7 +1338,7 @@ ESPEAK_NG_API espeak_ng_STATUS espeak_ng_SetVoiceByProperties(espeak_VOICE *voic
|
||||
|
||||
#pragma GCC visibility pop
|
||||
|
||||
void FreeVoiceList()
|
||||
void FreeVoiceList(void)
|
||||
{
|
||||
int ix;
|
||||
for (ix = 0; ix < n_voices_list; ix++) {
|
||||
@@ -1423,7 +1423,6 @@ static int AddToVoicesList(const char *fname, int len_path_voices, int is_langua
|
||||
|
||||
if (voice_data != NULL)
|
||||
voices_list[n_voices_list++] = voice_data;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+11
-11
@@ -119,7 +119,7 @@ int wcmdq_tail = 0;
|
||||
|
||||
// pitch,speed,
|
||||
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 const int embedded_max[N_EMBEDDED_VALUES] = { 0, 0x7fff, 750, 300, 99, 99, 99, 0, 750, 0, 0, 0, 0, 4, 0 };
|
||||
|
||||
#if USE_LIBSONIC
|
||||
static sonicStream sonicSpeedupStream = NULL;
|
||||
@@ -130,7 +130,7 @@ static double sonicSpeed = 1.0;
|
||||
// 2nd index=modulation_type
|
||||
// value: bits 0-3 amplitude (16ths), bits 4-7 every n cycles
|
||||
#define N_ROUGHNESS 8
|
||||
static unsigned char modulation_tab[N_ROUGHNESS][8] = {
|
||||
static const unsigned char modulation_tab[N_ROUGHNESS][8] = {
|
||||
{ 0, 0x00, 0x00, 0x00, 0, 0x46, 0xf2, 0x29 },
|
||||
{ 0, 0x2f, 0x00, 0x2f, 0, 0x45, 0xf2, 0x29 },
|
||||
{ 0, 0x2f, 0x00, 0x2e, 0, 0x45, 0xf2, 0x28 },
|
||||
@@ -234,7 +234,7 @@ static const unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1] = {
|
||||
242, 246, 249, 252, 254, 255
|
||||
};
|
||||
|
||||
void WcmdqStop()
|
||||
void WcmdqStop(void)
|
||||
{
|
||||
wcmdq_head = 0;
|
||||
wcmdq_tail = 0;
|
||||
@@ -252,7 +252,7 @@ void WcmdqStop()
|
||||
#endif
|
||||
}
|
||||
|
||||
int WcmdqFree()
|
||||
int WcmdqFree(void)
|
||||
{
|
||||
int i;
|
||||
i = wcmdq_head - wcmdq_tail;
|
||||
@@ -260,18 +260,18 @@ int WcmdqFree()
|
||||
return i;
|
||||
}
|
||||
|
||||
int WcmdqUsed()
|
||||
int WcmdqUsed(void)
|
||||
{
|
||||
return N_WCMDQ - WcmdqFree();
|
||||
}
|
||||
|
||||
void WcmdqInc()
|
||||
void WcmdqInc(void)
|
||||
{
|
||||
wcmdq_tail++;
|
||||
if (wcmdq_tail >= N_WCMDQ) wcmdq_tail = 0;
|
||||
}
|
||||
|
||||
static void WcmdqIncHead()
|
||||
static void WcmdqIncHead(void)
|
||||
{
|
||||
MAKE_MEM_UNDEFINED(&wcmdq[wcmdq_head], sizeof(wcmdq[wcmdq_head]));
|
||||
wcmdq_head++;
|
||||
@@ -534,7 +534,7 @@ int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control)
|
||||
return hmax; // highest harmonic number
|
||||
}
|
||||
|
||||
static void AdvanceParameters()
|
||||
static void AdvanceParameters(void)
|
||||
{
|
||||
// Called every 64 samples to increment the formant freq, height, and widths
|
||||
if (wvoice == NULL)
|
||||
@@ -643,7 +643,7 @@ void InitBreath(void)
|
||||
setresonator(&rbreath[ix], 2000, 200, 1);
|
||||
}
|
||||
|
||||
static void SetBreath()
|
||||
static void SetBreath(void)
|
||||
{
|
||||
int pk;
|
||||
|
||||
@@ -1001,7 +1001,7 @@ static int SetWithRange0(int value, int max)
|
||||
return value;
|
||||
}
|
||||
|
||||
static void SetPitchFormants()
|
||||
static void SetPitchFormants(void)
|
||||
{
|
||||
if (wvoice == NULL)
|
||||
return;
|
||||
@@ -1253,7 +1253,7 @@ void Write4Bytes(FILE *f, int value)
|
||||
}
|
||||
}
|
||||
|
||||
static int WavegenFill2()
|
||||
static int WavegenFill2(void)
|
||||
{
|
||||
// Pick up next wavegen commands from the queue
|
||||
// return: 0 output buffer has been filled
|
||||
|
||||
Reference in New Issue
Block a user