mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-09 16:01:12 +00:00
Merge branch 'upstream' into development
Conflicts: dictsource/dict_phonemes phsource/compile_report platforms/riscos/cpp/speak_riscos platforms/riscos/s/cmhgfile
This commit is contained in:
+33
-26
@@ -984,39 +984,46 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
|
||||
|
||||
static const char *M_Variant(int value)
|
||||
{//====================================
|
||||
// returns M, or perhaps MA for some cases
|
||||
// returns M, or perhaps MA or MB for some cases
|
||||
|
||||
if(translator->translator_name == L('l','t'))
|
||||
int teens = 0;
|
||||
|
||||
if(((value % 100) > 10) && ((value % 100) < 20))
|
||||
teens = 1;
|
||||
|
||||
switch((translator->langopts.numbers2 >> 6) & 0x7)
|
||||
{
|
||||
// Lithuanian
|
||||
case 1: // lang=ru use singular for xx1 except for x11
|
||||
if((teens == 0) && ((value % 10) == 1))
|
||||
return("1M");
|
||||
break;
|
||||
|
||||
case 2: // lang=cs,sk
|
||||
if((value >= 2) && (value <= 4))
|
||||
return("0MA");
|
||||
break;
|
||||
|
||||
case 3: // lang=pl
|
||||
if((teens == 0) && (((value % 10) >= 2) && ((value % 10) <= 4)))
|
||||
return("0MA");
|
||||
break;
|
||||
|
||||
case 4: // lang=lt
|
||||
if((teens == 1) || ((value % 10) == 0))
|
||||
return("0MB");
|
||||
if((value % 10) == 1)
|
||||
return("0MA");
|
||||
if(((value % 10) == 0) || ((value % 100) > 10) && ((value % 100) < 20))
|
||||
{
|
||||
return("0MB");
|
||||
}
|
||||
return("0M");
|
||||
}
|
||||
break;
|
||||
|
||||
if((translator->langopts.numbers2 & 0x100) && (value >= 2) && (value <= 4))
|
||||
return("0MA"); // Czech, Slovak
|
||||
else
|
||||
if(((value % 100) < 10) || ((value % 100) > 20)) // but not teens, 10 to 19
|
||||
{
|
||||
if ((translator->langopts.numbers2 & 0x40) &&
|
||||
((value % 10)>=2) &&
|
||||
((value % 10)<=4))
|
||||
case 5: // lang=bs,hr,sr
|
||||
if(teens == 0)
|
||||
{
|
||||
// for Polish language - two forms of plural!
|
||||
return("0MA");
|
||||
if((value % 10) == 1)
|
||||
return("1M");
|
||||
if(((value % 10) >= 2) && ((value % 10) <= 4))
|
||||
return("0MA");
|
||||
}
|
||||
|
||||
if((translator->langopts.numbers2 & 0x80) &&
|
||||
((value % 10)==1))
|
||||
{
|
||||
return("1MA");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return("0M");
|
||||
}
|
||||
|
||||
+1
-1
@@ -1591,7 +1591,7 @@ static void SetProsodyParameter(int param_type, wchar_t *attr1, PARAM_STACK *sp)
|
||||
static int ReplaceKeyName(char *outbuf, int index, int &outix)
|
||||
{//===========================================================
|
||||
// Replace some key-names by single characters, so they can be pronounced in different languages
|
||||
MNEM_TAB keynames[] = {
|
||||
static MNEM_TAB keynames[] = {
|
||||
{"space ",0xe020},
|
||||
{"tab ", 0xe009},
|
||||
{"underscore ", 0xe05f},
|
||||
|
||||
@@ -136,6 +136,8 @@ static int speed3 = 118;
|
||||
|
||||
//#define TEST_SPEED
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
|
||||
void SetSpeed(int control)
|
||||
{//=======================
|
||||
int x;
|
||||
@@ -312,6 +314,147 @@ printf("%3d: speedf %d %d %d pause=%d %d wav=%d lenmod=%d %d\n",wpm,speed1,
|
||||
#endif
|
||||
} // end of SetSpeed
|
||||
|
||||
#else // not using sonic speed-up
|
||||
|
||||
void SetSpeed(int control)
|
||||
{//=======================
|
||||
// This is the earlier version of SetSpeed() before sonic speed-up was added
|
||||
int x;
|
||||
int s1;
|
||||
int wpm;
|
||||
int wpm2;
|
||||
|
||||
speed.loud_consonants = 0;
|
||||
speed.min_sample_len = 450;
|
||||
speed.lenmod_factor = 110; // controls the effect of FRFLAG_LEN_MOD reduce length change
|
||||
speed.lenmod2_factor = 100;
|
||||
|
||||
wpm = embedded_value[EMBED_S];
|
||||
if(control == 2)
|
||||
wpm = embedded_value[EMBED_S2];
|
||||
|
||||
#ifdef TEST_SPEED
|
||||
if(wpm > 1000)
|
||||
{
|
||||
// TESTING
|
||||
test = wpm / 1000;
|
||||
wpm = wpm % 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(voice->speed_percent > 0)
|
||||
{
|
||||
wpm = (wpm * voice->speed_percent)/100;
|
||||
}
|
||||
if(wpm > 450)
|
||||
wpm = 450;
|
||||
|
||||
if(wpm > 360)
|
||||
{
|
||||
speed.loud_consonants = (wpm - 360) / 8;
|
||||
}
|
||||
|
||||
wpm2 = wpm;
|
||||
if(wpm > 359) wpm2 = 359;
|
||||
if(wpm < 80) wpm2 = 80;
|
||||
x = speed_lookup[wpm2-80];
|
||||
|
||||
if(wpm >= 380)
|
||||
x = 7;
|
||||
if(wpm >= 400)
|
||||
x = 6;
|
||||
|
||||
if(control & 1)
|
||||
{
|
||||
// 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;
|
||||
|
||||
if(x <= 7)
|
||||
{
|
||||
speed1 = x;
|
||||
speed2 = speed3 = x - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(control & 2)
|
||||
{
|
||||
// these are used in synthesis file
|
||||
|
||||
if(wpm > 350)
|
||||
{
|
||||
speed.lenmod_factor = 85 - (wpm - 350) / 3;
|
||||
speed.lenmod2_factor = 60 - (wpm - 350) / 8;
|
||||
}
|
||||
else
|
||||
if(wpm > 250)
|
||||
{
|
||||
speed.lenmod_factor = 110 - (wpm - 250)/4;
|
||||
speed.lenmod2_factor = 110 - (wpm - 250)/2;
|
||||
}
|
||||
|
||||
s1 = (x * voice->speedf1)/256;
|
||||
|
||||
if(wpm >= 170)
|
||||
speed.wav_factor = 110 + (150*s1)/128; // reduced speed adjustment, used for playing recorded sounds
|
||||
else
|
||||
speed.wav_factor = 128 + (128*s1)/130; // = 215 at 170 wpm
|
||||
|
||||
if(wpm >= 350)
|
||||
{
|
||||
speed.wav_factor = wav_factor_350[wpm-350];
|
||||
}
|
||||
|
||||
if(wpm >= 390)
|
||||
{
|
||||
speed.min_sample_len = 450 - (wpm - 400)/2;
|
||||
if(wpm > 440)
|
||||
speed.min_sample_len = 420 - (wpm - 440);
|
||||
}
|
||||
|
||||
speed.pause_factor = (256 * s1)/115; // full speed adjustment, used for pause length
|
||||
speed.clause_pause_factor = 0;
|
||||
|
||||
if(wpm > 430)
|
||||
{
|
||||
speed.pause_factor = 12;
|
||||
// speed.clause_pause_factor = 15;
|
||||
}
|
||||
else
|
||||
if(wpm > 400)
|
||||
{
|
||||
speed.pause_factor = 13;
|
||||
// speed.clause_pause_factor = 15;
|
||||
}
|
||||
else
|
||||
if(wpm > 374)
|
||||
{
|
||||
speed.pause_factor = 14;
|
||||
}
|
||||
else
|
||||
if(wpm > 350)
|
||||
{
|
||||
speed.pause_factor = pause_factor_350[wpm - 350];
|
||||
}
|
||||
|
||||
if(speed.clause_pause_factor == 0)
|
||||
{
|
||||
// restrict the reduction of pauses between clauses
|
||||
if((speed.clause_pause_factor = speed.pause_factor) < 16)
|
||||
speed.clause_pause_factor = 16;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST_SPEED
|
||||
//if(control==3)
|
||||
printf("%3d: speedf %d %d %d pause=%d %d wav=%d lenmod=%d %d\n",wpm,speed1,speed2,speed3, speed.pause_factor,speed.clause_pause_factor, speed.wav_factor,speed.lenmod_factor,speed.lenmod2_factor);
|
||||
#endif
|
||||
} // end of SetSpeed
|
||||
|
||||
#endif // of INCLUDE_SONIC
|
||||
|
||||
|
||||
#ifdef deleted
|
||||
void SetAmplitude(int amp)
|
||||
|
||||
@@ -20,11 +20,15 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "speech.h"
|
||||
#include "sonic.h"
|
||||
#ifdef INCLUDE_SONIC
|
||||
|
||||
struct sonicStreamStruct {
|
||||
short *inputBuffer;
|
||||
@@ -965,3 +969,4 @@ int sonicChangeShortSpeed(
|
||||
sonicDestroyStream(stream);
|
||||
return numSamples;
|
||||
}
|
||||
#endif // INCLUDE_SONIC
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
// conditional compilation options
|
||||
#define INCLUDE_KLATT
|
||||
#define INCLUDE_MBROLA
|
||||
#define INCLUDE_SONIC
|
||||
|
||||
#if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
|
||||
#define ARCH_BIG
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@
|
||||
#include "translate.h"
|
||||
#include "wave.h"
|
||||
|
||||
const char *version_string = "1.46.21 25.Jul.12";
|
||||
const char *version_string = "1.46.22 09.Aug.12";
|
||||
const int version_phdata = 0x014600;
|
||||
|
||||
int option_device_number = -1;
|
||||
@@ -975,7 +975,7 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
if(instn2 < 8)
|
||||
{
|
||||
// ChangeIf
|
||||
if(StressCondition(tr, plist, instn2 & 7, 1))
|
||||
if(StressCondition(tr, plist, instn2 & 7, 1) == true)
|
||||
{
|
||||
phdata->pd_param[i_CHANGE_PHONEME] = instn & 0xff;
|
||||
end_flag = 1; // change phoneme, exit
|
||||
|
||||
@@ -1237,6 +1237,7 @@ void DoPhonemeMarker(int type, int char_posn, int length, char *name)
|
||||
} // end of DoMarker
|
||||
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
void DoSonicSpeed(int value)
|
||||
{//=========================
|
||||
// value, multiplier * 1024
|
||||
@@ -1244,6 +1245,7 @@ void DoSonicSpeed(int value)
|
||||
wcmdq[wcmdq_tail][1] = value;
|
||||
WcmdqInc();
|
||||
} // end of DoSonicSpeed
|
||||
#endif
|
||||
|
||||
|
||||
void DoVoiceChange(voice_t *v)
|
||||
|
||||
+8
-10
@@ -118,8 +118,8 @@ static const unsigned short chars_ignore_default[] = {
|
||||
0, 0 };
|
||||
|
||||
// alternatively, ignore characters but allow zero-width-non-joiner (lang-fa)
|
||||
static const unsigned short chars_ignore_fa[] = {
|
||||
0x200c, 0x0605, // zero width non-joiner, replace with not-used Arabic character code
|
||||
static const unsigned short chars_ignore_zwnj_hyphen[] = {
|
||||
0x200c, '-', // zero width non-joiner, replace with hyphen
|
||||
0x200d, 1, // zero width joiner
|
||||
0, 0 };
|
||||
|
||||
@@ -661,13 +661,11 @@ Translator *SelectTranslator(const char *name)
|
||||
|
||||
case L('f','a'): // Farsi
|
||||
{
|
||||
static const char fa_ZWNJ[] = {0x05, 0}; // use letter group G for ZWNJ U+200c
|
||||
tr->letter_bits_offset = OFFSET_ARABIC;
|
||||
tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND;
|
||||
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
|
||||
|
||||
tr->chars_ignore = chars_ignore_fa;
|
||||
SetLetterBits(tr,LETTERGP_G,(char *)fa_ZWNJ);
|
||||
tr->chars_ignore = chars_ignore_zwnj_hyphen; // replace ZWNJ by hyphen
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -763,7 +761,7 @@ Translator *SelectTranslator(const char *name)
|
||||
tr->langopts.accents = 1;
|
||||
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_DECIMAL_COMMA | NUM_THOUS_SPACE | NUM_DFRACTION_2 | NUM_ROMAN_CAPITALS;
|
||||
tr->langopts.numbers2 = 0x4a; // variant numbers before thousands,milliards
|
||||
tr->langopts.numbers2 = 0xa + NUM2_THOUSANDS_VAR5; // variant numbers before thousands,milliards
|
||||
tr->langopts.replace_chars = replace_cyrillic_latin;
|
||||
|
||||
SetLetterVowel(tr,'y');
|
||||
@@ -999,7 +997,7 @@ SetLengthMods(tr,3); // all equal
|
||||
tr->langopts.unstressed_wd2 = 2;
|
||||
tr->langopts.param[LOPT_DIERESES] = 1;
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_4 | NUM_ORDINAL_DOT;
|
||||
tr->langopts.numbers2 = 0x100;
|
||||
tr->langopts.numbers2 = NUM2_THOUSANDS_VAR4;
|
||||
tr->langopts.max_roman = 5000;
|
||||
}
|
||||
break;
|
||||
@@ -1098,7 +1096,7 @@ SetLengthMods(tr,3); // all equal
|
||||
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x9;
|
||||
tr->langopts.max_initial_consonants = 7; // for example: wchrzczony :)
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_2;
|
||||
tr->langopts.numbers2 = 0x40;
|
||||
tr->langopts.numbers2 = NUM2_THOUSANDS_VAR3;
|
||||
tr->langopts.param[LOPT_COMBINE_WORDS] = 4 + 0x100; // combine 'nie' (marked with $alt2) with some 1-syllable (and 2-syllable) words (marked with $alt)
|
||||
SetLetterVowel(tr,'y');
|
||||
}
|
||||
@@ -1170,7 +1168,7 @@ SetLengthMods(tr,3); // all equal
|
||||
tr->langopts.param[LOPT_COMBINE_WORDS] = 4; // combine some prepositions with the following word
|
||||
|
||||
tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2 | NUM_ROMAN;
|
||||
tr->langopts.numbers2 = 0x100;
|
||||
tr->langopts.numbers2 = NUM2_THOUSANDS_VAR2;
|
||||
tr->langopts.thousands_sep = STRESSPOSN_1L; //no thousands separator
|
||||
tr->langopts.decimal_sep = ',';
|
||||
|
||||
@@ -1478,7 +1476,7 @@ static void Translator_Russian(Translator *tr)
|
||||
tr->langopts.stress_flags = 0x0020; // waas 0x1010
|
||||
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED;
|
||||
tr->langopts.numbers2 = 0xc2; // variant numbers before thousands
|
||||
tr->langopts.numbers2 = 0x2 + NUM2_THOUSANDS_VAR1; // variant numbers before thousands
|
||||
tr->langopts.phoneme_change = 1;
|
||||
tr->langopts.testing = 2;
|
||||
|
||||
|
||||
+2
-2
@@ -372,7 +372,7 @@ int IsAlpha(unsigned int c)
|
||||
{//========================
|
||||
// Replacement for iswalph() which also checks for some in-word symbols
|
||||
|
||||
const unsigned short extra_indic_alphas[] = {
|
||||
static const unsigned short extra_indic_alphas[] = {
|
||||
0xa70,0xa71, // Gurmukhi: tippi, addak
|
||||
0 };
|
||||
|
||||
@@ -1013,7 +1013,7 @@ if((wmark > 0) && (wmark < 8))
|
||||
found = TranslateNumber(tr, word1, phonemes, dictionary_flags, wtab, 0);
|
||||
}
|
||||
|
||||
if(!found & ((wflags & FLAG_UPPERS) != FLAG_FIRST_UPPER))
|
||||
if(!found && ((wflags & FLAG_UPPERS) != FLAG_FIRST_UPPER))
|
||||
{
|
||||
// either all upper or all lower case
|
||||
|
||||
|
||||
+6
-3
@@ -446,10 +446,13 @@ typedef struct {
|
||||
|
||||
#define NUM2_MULTIPLE_ORDINAL 0x1000
|
||||
#define NUM2_ENGLISH_NUMERALS 0x2000
|
||||
#define NUM2_THOUSANDS_VAR1 0x40
|
||||
#define NUM2_THOUSANDS_VAR2 0x80
|
||||
#define NUM2_THOUSANDS_VAR3 0xc0
|
||||
#define NUM2_THOUSANDS_VAR4 0x100
|
||||
#define NUM2_THOUSANDS_VAR5 0x140
|
||||
// bits 1-4 use variant form of numbers before thousands,millions,etc.
|
||||
// bit6=(LANG=pl) two forms of plural, M or MA
|
||||
// bit7=(LANG-ru) use MB for 1 thousand, million, etc
|
||||
// bit8=(LANG=cs,sk) two forms of plural, M or MA
|
||||
// bits 6-8 use different forms of thousand, million, etc (M MA MB)
|
||||
// bit9=(LANG=rw) say "thousand" and "million" before its number, not after
|
||||
// bit12=(LANG=el,es) use ordinal form of hundreds and tens as well as units
|
||||
// bit13=(LANG=ne) speak (non-replaced) English numerals in English
|
||||
|
||||
+22
-4
@@ -34,9 +34,10 @@
|
||||
#include "phoneme.h"
|
||||
#include "synthesize.h"
|
||||
#include "voice.h"
|
||||
#include "sonic.h"
|
||||
|
||||
//#undef INCLUDE_KLATT
|
||||
#ifdef INCLUDE_SONIC
|
||||
#include "sonic.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_PORTAUDIO
|
||||
#include "portaudio.h"
|
||||
@@ -150,8 +151,10 @@ static PortAudioStream *pa_stream=NULL;
|
||||
static PaStream *pa_stream=NULL;
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
static sonicStream sonicSpeedupStream = NULL;
|
||||
double sonicSpeed = 1.0;
|
||||
#endif
|
||||
|
||||
// 1st index=roughness
|
||||
// 2nd index=modulation_type
|
||||
@@ -295,11 +298,15 @@ void WcmdqStop()
|
||||
{//=============
|
||||
wcmdq_head = 0;
|
||||
wcmdq_tail = 0;
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
if(sonicSpeedupStream != NULL)
|
||||
{
|
||||
sonicDestroyStream(sonicSpeedupStream);
|
||||
sonicSpeedupStream = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_PORTAUDIO
|
||||
Pa_AbortStream(pa_stream);
|
||||
#endif
|
||||
@@ -1912,14 +1919,18 @@ int WavegenFill2(int fill_zeros)
|
||||
}
|
||||
wdata.n_mix_wavefile = 0;
|
||||
wdata.amplitude_fmt = 100;
|
||||
#ifdef INCLUDE_KLATT
|
||||
KlattReset(1);
|
||||
#endif
|
||||
result = PlaySilence(length,resume);
|
||||
break;
|
||||
|
||||
case WCMD_WAVE:
|
||||
echo_complete = echo_length;
|
||||
wdata.n_mix_wavefile = 0;
|
||||
#ifdef INCLUDE_KLATT
|
||||
KlattReset(1);
|
||||
#endif
|
||||
result = PlayWave(length,resume,(unsigned char*)q[2], q[3] & 0xff, q[3] >> 8);
|
||||
break;
|
||||
|
||||
@@ -1989,9 +2000,11 @@ int WavegenFill2(int fill_zeros)
|
||||
wdata.amplitude_fmt = 100; // percentage, but value=0 means 100%
|
||||
break;
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
case WCMD_SONIC_SPEED:
|
||||
sonicSpeed = (double)q[1] / 1024;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
if(result==0)
|
||||
@@ -2009,6 +2022,7 @@ int WavegenFill2(int fill_zeros)
|
||||
} // end of WavegenFill2
|
||||
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
/* Speed up the audio samples with libsonic. */
|
||||
static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text)
|
||||
{//==============================================================================
|
||||
@@ -2035,6 +2049,7 @@ static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text
|
||||
}
|
||||
return sonicReadShortFromStream(sonicSpeedupStream, outbuf, length_out);
|
||||
} // end of SpeedUp
|
||||
#endif
|
||||
|
||||
|
||||
/* Call WavegenFill2, and then speed up the output samples. */
|
||||
@@ -2042,16 +2057,18 @@ int WavegenFill(int fill_zeros)
|
||||
{//============================
|
||||
int finished;
|
||||
unsigned char *p_start;
|
||||
int length;
|
||||
int max_length;
|
||||
|
||||
p_start = out_ptr;
|
||||
|
||||
// fill_zeros is ignored. It is now done in the portaudio callback
|
||||
finished = WavegenFill2(0);
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
if(sonicSpeed > 1.0)
|
||||
{
|
||||
int length;
|
||||
int max_length;
|
||||
|
||||
max_length = (out_end - p_start);
|
||||
length = 2*SpeedUp((short *)p_start, (out_ptr-p_start)/2, max_length/2, finished);
|
||||
out_ptr = p_start + length;
|
||||
@@ -2059,6 +2076,7 @@ int WavegenFill(int fill_zeros)
|
||||
if(length >= max_length)
|
||||
finished = 0; // there may be more data to flush
|
||||
}
|
||||
#endif
|
||||
return finished;
|
||||
} // end of WavegenFill
|
||||
|
||||
|
||||
Reference in New Issue
Block a user