[1.29.18] Add data for Serbian voice ("sr").

Moved Croatian/Bosnian/Serbian dictionary source data to hbs_rules, hbs_list.
Added data for Ancient Greek voice ("grc").
In voice files, the attribute: word n  adds a short pause between words. n = 1 to 4 for increasing pause length.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@103 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2007-11-10 22:10:43 +00:00
parent c049552f9e
commit f9725f9f64
51 changed files with 1512 additions and 503 deletions
+35 -1
View File
@@ -2072,11 +2072,15 @@ wxString CompileAllDictionaries()
int err;
int errors = 0;
int dict_count = 0;
FILE *f_in;
FILE *log;
FILE *f_phused;
char dictname[80];
char fname_log[sizeof(path_dsource)+20];
char save_voice_name[80];
char path[sizeof(path_home)+40]; // path_dsource+20
char buf[200];
char voicename[80];
if(!wxDirExists(path_dictsource))
{
@@ -2121,8 +2125,38 @@ wxString CompileAllDictionaries()
dictstr = fname.GetName().BeforeLast('_');
strcpy(dictname,dictstr.mb_str(wxConvLocal));
dict_count++;
strcpy(voicename,dictname);
LoadVoice(dictname,0);
// read the *_rules file to see if a phoneme table is specified though a voice name
sprintf(path,"%s%s_rules",path_dsource,dictname);
if((f_in = fopen(path,"r")) != NULL)
{
unsigned int ix;
unsigned int c;
for(ix=0; ix<20; ix++)
{
if(fgets(buf,sizeof(buf),f_in) == NULL)
break;
if(memcmp(buf,"//voice=",8)==0)
{
for(ix=0; ix<sizeof(voicename); ix++)
{
if(isspace(c = buf[ix+8]))
{
break;
}
voicename[ix] = c;
}
voicename[ix] = 0;
break;
}
}
fclose(f_in);
}
LoadVoice(voicename,0);
if((err = CompileDictionary(path_dsource, dictname,log,NULL)) > 0)
{
+3 -2
View File
@@ -34,6 +34,7 @@
//#define OPT_FORMAT // format the text and write formatted copy to Log file
//#define OUTPUT_FORMAT
extern void Write4Bytes(FILE *f, int value);
int HashDictionary(const char *string);
static FILE *f_log = NULL;
@@ -1378,8 +1379,8 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
}
if(replace1 != 0)
{
fwrite(&replace1,1,4,f_out);
fwrite(&replace2,1,4,f_out);
Write4Bytes(f_out,replace1); // write as little-endian
Write4Bytes(f_out,replace2); // if big-endian, reverse the bytes in LoadDictionary()
}
}
break;
+29 -9
View File
@@ -86,6 +86,21 @@ void strncpy0(char *to,const char *from, int size)
to[size-1] = 0;
}
#ifdef ARCH_BIG
int reverse_word_bytes(int word)
{//=============================
// reverse the order of bytes from little-endian to big-endian
int ix;
int word2 = 0;
for(ix=24; ix>=0; ix -= 8)
{
word2 |= (word >> ix) & 0xff;
word2 = word2 << 8;
}
return(word2);
}
#endif
int LookupMnem(MNEM_TAB *table, char *string)
@@ -237,6 +252,15 @@ void Translator::InitGroups(void)
pw += 2; // find the end of the replacement list, each entry is 2 words.
}
p = (char *)(pw+1);
#ifdef ARCH_BIG
pw = (unsigned int *)langopts.replace_chars;
while(*pw != 0)
{
*pw = reverse_word_bytes(*pw);
pw++;
}
#endif
continue;
}
@@ -1280,23 +1304,19 @@ void Translator::SetWordStress(char *output, unsigned int dictionary_flags, int
if((ph = phoneme_tab[*p]) != NULL)
{
int gap = langopts.word_gap & 0xf00;
if(ph->type == phSTRESS)
ph = phoneme_tab[p[1]];
if(((gap) && (vowel_stress[1] >= 4) && (prev_stress >= 4)) || (langopts.word_gap & 0x8))
#ifdef deleted
int gap = langopts.word_gap & 0x700;
if((gap) && (vowel_stress[1] >= 4) && (prev_stress >= 4))
{
/* two primary stresses together, insert a short pause */
if(gap == 0x0300)
*output++ = phonPAUSE;
else
if((gap == 0x0200) && (ph->type == phVOWEL))
*output++ = phonGLOTTALSTOP;
else
*output++ = phonPAUSE_SHORT;
*output++ = pause_phonemes[gap >> 8];
}
else
#endif
if((langopts.vowel_pause & 0x30) && (ph->type == phVOWEL))
{
// word starts with a vowel
+3 -2
View File
@@ -81,8 +81,9 @@
#define phonSWITCH 21
#define phonX1 22 // a language specific action
#define phonPAUSE_VSHORT 23
#define phonT_REDUCED 24
#define phonPAUSE_LONG 24
#define phonT_REDUCED 25
extern const unsigned char pause_phonemes[8]; // 0, vshort, short, pause, long, glottalstop
// place of articulation
#define phPLACE 0xf0000
+7 -5
View File
@@ -30,6 +30,7 @@
#include "translate.h"
const unsigned char pause_phonemes[8] = {0, phonPAUSE_VSHORT, phonPAUSE_SHORT, phonPAUSE, phonPAUSE_LONG, phonGLOTTALSTOP, phonPAUSE_LONG, phonPAUSE_LONG};
int Translator::ChangePhonemes(PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch)
@@ -497,10 +498,6 @@ void Translator::MakePhonemeList(int post_pause, int start_sentence)
{
int x;
if(langopts.word_gap & 1)
{
insert_ph = phonPAUSE_VSHORT;
}
if(langopts.vowel_pause && (ph->type != phPAUSE) && (next->type == phVOWEL))
{
if(langopts.vowel_pause & 0x04)
@@ -524,6 +521,11 @@ void Translator::MakePhonemeList(int post_pause, int start_sentence)
insert_ph = phonPAUSE_SHORT;
}
}
if((x = (langopts.word_gap & 0x7)) != 0)
{
insert_ph = pause_phonemes[x];
}
}
next2 = phoneme_tab[(plist2+2)->phcode];
@@ -540,7 +542,7 @@ void Translator::MakePhonemeList(int post_pause, int start_sentence)
}
}
else
if(((langopts.word_gap & 2)==0) || ((plist2+1)->sourceix == 0))
if(((langopts.word_gap & 8)==0) || ((plist2+1)->sourceix == 0))
{
// This phoneme can be linked to a following vowel by inserting a linking phoneme
if(next->type == phVOWEL)
+1 -1
View File
@@ -455,7 +455,7 @@ void Translator::CalcLengths()
{
len = langopts.length_mods0[next2->ph->length_mod *10+ next->ph->length_mod];
if((next->newword) && (langopts.word_gap & 0x4))
if((next->newword) && (langopts.word_gap & 0x20))
{
// consider as a pause + first phoneme of the next word
length_mod = (len + langopts.length_mods0[next->ph->length_mod *10+ 1])/2;
+14 -4
View File
@@ -221,12 +221,13 @@ void MarkerEvent(int type, unsigned int char_position, int value, unsigned char
static void init_path(void)
{//========================
static void init_path(char *argv0)
{//===============================
#ifdef PLATFORM_WINDOWS
HKEY RegKey;
unsigned long size;
unsigned long var_type;
char *p;
char *env;
unsigned char buf[sizeof(path_home)-12];
@@ -234,9 +235,18 @@ static void init_path(void)
{
sprintf(path_home,"%s\\espeak-data",env);
if(GetFileLength(path_home) == -2)
return; // an espeak-data directory exists
return; // an espeak-data directory exists in the directory specified by environment variable
}
strcpy(path_home,argv0);
if((p = strrchr(path_home,'\\')) != NULL)
{
strcpy(&p[1],"espeak-data");
if(GetFileLength(path_home) == -2)
return; // an espeak-data directory exists in the same directory as the espeak program
}
// otherwise, look in the Windows Registry
buf[0] = 0;
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Speech\\Voices\\Tokens\\eSpeak", 0, KEY_READ, &RegKey);
size = sizeof(buf);
@@ -383,7 +393,7 @@ int main (int argc, char **argv)
option_multibyte = espeakCHARS_AUTO; // auto
f_trans = stdout;
init_path();
init_path(argv[0]);
#ifdef NEED_GETOPT
optind = 1;
+5 -1
View File
@@ -63,8 +63,12 @@ typedef struct {
int LookupMnem(MNEM_TAB *table, char *string);
#ifdef PLATFORM_WINDOWS
#define N_PATH_HOME 220
#else
#define N_PATH_HOME 150
#endif
#define N_PATH_HOME 120
extern char path_home[N_PATH_HOME]; // this is the espeak-data directory
extern void strncpy0(char *to,const char *from, int size);
+1 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.29.17 08.Nov.07";
const char *version_string = "1.29.18 10.Nov.07";
const int version_phdata = 0x012901;
int option_device_number = -1;
-10
View File
@@ -1142,16 +1142,6 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
DoMarker(espeakEVENT_WORD, (p->sourceix & 0x7ff) + clause_start_char, p->sourceix >> 11, clause_start_word + word_count++);
}
if((translator->langopts.word_gap & 1) || (translator->langopts.vowel_pause && (next->type == phVOWEL)))
{
// prevent word merging into next, make it look as though next is a pause
if((next->newword) && (next->type != phPAUSE))
{
// next_pause.ph = phoneme_tab[phonPAUSE];
// next = &next_pause;
}
}
EndAmplitude();
if(p->prepause > 0)
-2
View File
@@ -40,9 +40,7 @@ Translator_English::Translator_English() : Translator()
static const short stress_lengths2[8] = {182,140, 220,220, 0,0, 248,275};
memcpy(stress_lengths,stress_lengths2,sizeof(stress_lengths));
langopts.vowel_pause = 0;
langopts.stress_rule = 0;
langopts.word_gap = 0;
langopts.numbers = 0x41 + NUM_ROMAN;
}
+4 -13
View File
@@ -123,8 +123,6 @@ Translator *SelectTranslator(const char *name)
// 'diminished' is an unstressed final syllable
tr->langopts.stress_flags = 0x6 | 0x10;
tr->langopts.word_gap = 0;
tr->langopts.vowel_pause = 0;
tr->langopts.unstressed_wd1 = 0;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
@@ -141,7 +139,7 @@ Translator *SelectTranslator(const char *name)
static const short stress_lengths_de[8] = {150,130, 190,190, 0, 0, 260,275};
tr = new Translator();
tr->langopts.stress_rule = 0;
tr->langopts.word_gap = 0x2; // don't use linking phonemes
tr->langopts.word_gap = 0x8; // don't use linking phonemes
tr->langopts.vowel_pause = 0x30;
tr->langopts.param[LOPT_PREFIXES] = 1;
memcpy(tr->stress_lengths,stress_lengths_de,sizeof(tr->stress_lengths));
@@ -184,8 +182,6 @@ Translator *SelectTranslator(const char *name)
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.stress_rule = 2;
tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
tr->langopts.word_gap = 0;
tr->langopts.vowel_pause = 0;
tr->langopts.unstressed_wd1 = 0;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
@@ -238,8 +234,6 @@ Translator *SelectTranslator(const char *name)
// stress last syllable if it doesn't end in vowel or "s" or "n"
// 'diminished' is an unstressed final syllable
tr->langopts.stress_flags = 0x200 | 0x6 | 0x10;
tr->langopts.word_gap = 0;
tr->langopts.vowel_pause = 0;
tr->langopts.unstressed_wd1 = 0;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
@@ -398,7 +392,6 @@ SetLengthMods(tr,3); // all equal
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.stress_rule = 2;
tr->langopts.word_gap = 0;
tr->langopts.vowel_pause = 1;
tr->langopts.unstressed_wd1 = 2;
tr->langopts.unstressed_wd2 = 2;
@@ -449,7 +442,6 @@ SetLengthMods(tr,3); // all equal
tr = new Translator();
tr->langopts.stress_rule = 0;
tr->langopts.word_gap = 0;
tr->langopts.vowel_pause = 1;
tr->langopts.param[LOPT_DIERESES] = 1;
tr->langopts.param[LOPT_PREFIXES] = 1;
@@ -637,7 +629,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.stress_rule = 0;
tr->langopts.word_gap = 0x4; // length of a final vowel is less dependent on the next consonant
tr->langopts.word_gap = 0x20; // length of a final vowel is less dependent on the next consonant
tr->langopts.vowel_pause = 4;
tr->letter_groups[0] = vowels_vi;
// tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
@@ -650,7 +642,7 @@ SetLengthMods(tr,3); // all equal
case L('z','h'):
case L_zhy:
{
static const short stress_lengths_zh[8] = {220,150, 230,230, 230,0, 230,250};
static const short stress_lengths_zh[8] = {230,150, 230,230, 230,0, 230,250};
static const unsigned char stress_amps_zh[] = {22,16, 22,22, 22,22, 22,22 };
tr = new Translator;
@@ -663,7 +655,7 @@ SetLengthMods(tr,3); // all equal
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
tr->langopts.tone_numbers = 1; // a number after letters indicates a tone number (eg. pinyin or jyutping)
tr->langopts.ideographs = 1;
tr->langopts.word_gap = 0x5; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
if(name2 == L('z','h'))
{
tr->langopts.textmode = 1;
@@ -955,7 +947,6 @@ Translator_Afrikaans::Translator_Afrikaans() : Translator()
static const short stress_lengths2[8] = {170,140, 220,220, 0, 0, 250,270};
langopts.stress_rule = 0;
langopts.word_gap = 0;
langopts.vowel_pause = 0x30;
langopts.param[LOPT_DIERESES] = 1;
langopts.param[LOPT_PREFIXES] = 1;
+3 -4
View File
@@ -254,11 +254,10 @@ extern const int param_defaults[N_SPEECH_PARAM];
typedef struct {
// bit0=don't link consonants with the next word
// bit1=don't add linking phonemes
// bit2=length of a final vowel doesn't depend on the next phoneme
// bits0-2 separate words with (1=pause_vshort, 2=pause_short, 3=pause, 4=pause_long 5=[?] phonemme)
// bit 3=don't use linking phoneme
// bit4=longer pause before STOP, VSTOP,FRIC
// bit8-11=separate words with adjacent stressed syllables with (1=pause, 2=long pausem 3=[?] phoneme)
// bit5=length of a final vowel doesn't depend on the next phoneme
int word_gap;
int vowel_pause;
int stress_rule; // 1=first syllable, 2=penultimate, 3=last