mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-12-04 23:56:14 +00:00
Merge branch 'duplicates'
This commit is contained in:
@@ -47,6 +47,8 @@
|
|||||||
#include "voice.h" // for LoadVoice, voice
|
#include "voice.h" // for LoadVoice, voice
|
||||||
#include "wavegen.h" // for WavegenInit, WavegenSetVoice
|
#include "wavegen.h" // for WavegenInit, WavegenSetVoice
|
||||||
|
|
||||||
|
static int CalculateSample(unsigned char c3, int c1);
|
||||||
|
|
||||||
#define N_ITEM_STRING 256
|
#define N_ITEM_STRING 256
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -1088,8 +1090,6 @@ static int LoadWavefile(CompileContext *ctx, FILE *f, const char *fname)
|
|||||||
{
|
{
|
||||||
int displ;
|
int displ;
|
||||||
unsigned char c1;
|
unsigned char c1;
|
||||||
unsigned char c3;
|
|
||||||
int c2;
|
|
||||||
int sample;
|
int sample;
|
||||||
int sample2;
|
int sample2;
|
||||||
float x;
|
float x;
|
||||||
@@ -1125,12 +1125,8 @@ static int LoadWavefile(CompileContext *ctx, FILE *f, const char *fname)
|
|||||||
|
|
||||||
if ((c = fgetc(f)) == EOF)
|
if ((c = fgetc(f)) == EOF)
|
||||||
break;
|
break;
|
||||||
c3 = (unsigned char)c;
|
|
||||||
|
|
||||||
c2 = c3 << 24;
|
sample = CalculateSample((unsigned char) c, c1);
|
||||||
c2 = c2 >> 16; // sign extend
|
|
||||||
|
|
||||||
sample = (c1 & 0xff) + c2;
|
|
||||||
|
|
||||||
if (sample > max)
|
if (sample > max)
|
||||||
max = sample;
|
max = sample;
|
||||||
@@ -1150,11 +1146,9 @@ static int LoadWavefile(CompileContext *ctx, FILE *f, const char *fname)
|
|||||||
|
|
||||||
while (!feof(f)) {
|
while (!feof(f)) {
|
||||||
c1 = fgetc(f);
|
c1 = fgetc(f);
|
||||||
c3 = fgetc(f);
|
unsigned char c3 = fgetc(f);
|
||||||
c2 = c3 << 24;
|
|
||||||
c2 = c2 >> 16; // sign extend
|
|
||||||
|
|
||||||
sample = (c1 & 0xff) + c2;
|
sample = CalculateSample(c3, c1);
|
||||||
|
|
||||||
if (feof(f)) break;
|
if (feof(f)) break;
|
||||||
|
|
||||||
@@ -2807,3 +2801,10 @@ espeak_ng_CompileIntonationPath(const char *source_path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#pragma GCC visibility pop
|
#pragma GCC visibility pop
|
||||||
|
|
||||||
|
static int CalculateSample(unsigned char c3, int c1) {
|
||||||
|
int c2 = c3 << 24;
|
||||||
|
c2 = c2 >> 16; // sign extend
|
||||||
|
|
||||||
|
return (c1 & 0xff) + c2;
|
||||||
|
}
|
||||||
@@ -44,6 +44,7 @@
|
|||||||
#include "translate.h" // for Translator, utf8_in, LANGU...
|
#include "translate.h" // for Translator, utf8_in, LANGU...
|
||||||
|
|
||||||
static int LookupFlags(Translator *tr, const char *word, unsigned int **flags_out);
|
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);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int points;
|
int points;
|
||||||
@@ -1471,8 +1472,6 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
|||||||
|
|
||||||
char *rule_start; // start of current match template
|
char *rule_start; // start of current match template
|
||||||
char *p;
|
char *p;
|
||||||
int ix;
|
|
||||||
|
|
||||||
int match_type; // left, right, or consume
|
int match_type; // left, right, or consume
|
||||||
int syllable_count;
|
int syllable_count;
|
||||||
int vowel;
|
int vowel;
|
||||||
@@ -1481,7 +1480,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
|||||||
int n_bytes;
|
int n_bytes;
|
||||||
int add_points;
|
int add_points;
|
||||||
int command;
|
int command;
|
||||||
unsigned int *flags;
|
unsigned int *flags = NULL;
|
||||||
|
|
||||||
MatchRecord match;
|
MatchRecord match;
|
||||||
static MatchRecord best;
|
static MatchRecord best;
|
||||||
@@ -1700,21 +1699,9 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
|||||||
else
|
else
|
||||||
failed = 1;
|
failed = 1;
|
||||||
} else if (((command & 0xf0) == 0x20) || (command == DOLLAR_LIST)) {
|
} else if (((command & 0xf0) == 0x20) || (command == DOLLAR_LIST)) {
|
||||||
// $list or $p_alt
|
DollarRule(word, word_start, consumed, group_length, word_buf, tr, flags, command, &failed, &add_points);
|
||||||
// make a copy of the word up to the post-match characters
|
|
||||||
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);
|
|
||||||
|
|
||||||
if ((command == DOLLAR_LIST) && (flags[0] & FLAG_FOUND) && !(flags[1] & FLAG_ONLY))
|
|
||||||
add_points = 23;
|
|
||||||
else if (flags[0] & (1 << (BITNUM_FLAG_ALT + (command & 0xf))))
|
|
||||||
add_points = 23;
|
|
||||||
else
|
|
||||||
failed = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case '-':
|
case '-':
|
||||||
if ((letter == '-') || ((letter == ' ') && (word_flags & FLAG_HYPHEN_AFTER)))
|
if ((letter == '-') || ((letter == ' ') && (word_flags & FLAG_HYPHEN_AFTER)))
|
||||||
@@ -1901,20 +1888,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
|||||||
pre_ptr++;
|
pre_ptr++;
|
||||||
command = *rule++;
|
command = *rule++;
|
||||||
if ((command == DOLLAR_LIST) || ((command & 0xf0) == 0x20)) {
|
if ((command == DOLLAR_LIST) || ((command & 0xf0) == 0x20)) {
|
||||||
// $list or $p_alt
|
DollarRule(word, word_start, consumed, group_length, word_buf, tr, flags, command, &failed, &add_points);
|
||||||
// make a copy of the word up to the current character
|
|
||||||
ix = *word - word_start + 1;
|
|
||||||
memcpy(word_buf, word_start-1, ix);
|
|
||||||
word_buf[ix] = ' ';
|
|
||||||
word_buf[ix+1] = 0;
|
|
||||||
LookupFlags(tr, &word_buf[1], &flags);
|
|
||||||
|
|
||||||
if ((command == DOLLAR_LIST) && (flags[0] & FLAG_FOUND) && !(flags[1] & FLAG_ONLY))
|
|
||||||
add_points = 23;
|
|
||||||
else if (flags[0] & (1 << (BITNUM_FLAG_ALT + (command & 0xf))))
|
|
||||||
add_points = 23;
|
|
||||||
else
|
|
||||||
failed = 1;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RULE_SYLLABLE:
|
case RULE_SYLLABLE:
|
||||||
@@ -3004,3 +2978,20 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
|||||||
|
|
||||||
return end_flags;
|
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) {
|
||||||
|
// $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);
|
||||||
|
|
||||||
|
if ((command == DOLLAR_LIST) && (flags[0] & FLAG_FOUND) && !(flags[1] & FLAG_ONLY))
|
||||||
|
*add_points = 23;
|
||||||
|
else if (flags[0] & (1 << (BITNUM_FLAG_ALT + (command & 0xf))))
|
||||||
|
*add_points = 23;
|
||||||
|
else
|
||||||
|
*failed = 1;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user