mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-10 08:13:55 +00:00
Merge branch 'development'
Conflicts: phsource/phonemes
This commit is contained in:
+4
-1
@@ -294,7 +294,7 @@ static keywtab_t keywords[] = {
|
||||
{"Continue", tSTATEMENT, kCONTINUE},
|
||||
|
||||
{"ChangePhoneme", tINSTRN1, i_CHANGE_PHONEME},
|
||||
{"ReplaceNextPhoneme", tINSTRN1, i_REPLACE_NEXT_PHONEME},
|
||||
{"ChangeNextPhoneme", tINSTRN1, i_REPLACE_NEXT_PHONEME},
|
||||
{"InsertPhoneme", tINSTRN1, i_INSERT_PHONEME},
|
||||
{"AppendPhoneme", tINSTRN1, i_APPEND_PHONEME},
|
||||
{"IfNextVowelAppend", tINSTRN1, i_APPEND_IFNEXTVOWEL},
|
||||
@@ -1133,6 +1133,9 @@ static unsigned int StringToWord(const char *string)
|
||||
unsigned char c;
|
||||
unsigned int word;
|
||||
|
||||
if(string==NULL)
|
||||
return(0);
|
||||
|
||||
word = 0;
|
||||
for(ix=0; ix<4; ix++)
|
||||
{
|
||||
|
||||
+20
-6
@@ -50,8 +50,9 @@ static char *hash_chains[N_HASH_DICT];
|
||||
static char letterGroupsDefined[N_LETTER_GROUPS];
|
||||
|
||||
MNEM_TAB mnem_rules[] = {
|
||||
{"unpr", 0x01},
|
||||
{"noprefix", 0x02}, // rule fails if a prefix has been removed
|
||||
{"unpr", DOLLAR_UNPR},
|
||||
{"noprefix", DOLLAR_NOPREFIX}, // rule fails if a prefix has been removed
|
||||
{"list", DOLLAR_LIST}, // a pronunciation is given in the *_list file
|
||||
|
||||
{"w_alt1", 0x11},
|
||||
{"w_alt2", 0x12},
|
||||
@@ -314,6 +315,7 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
|
||||
value = *rule++ & 0xff;
|
||||
if((value != 0x01) || (control & FLAG_UNPRON_TEST))
|
||||
{
|
||||
// TODO write the string backwards if in RULE_PRE
|
||||
p[0] = '$';
|
||||
name = LookupMnemName(mnem_rules, value);
|
||||
strcpy(&p[1],name);
|
||||
@@ -1102,21 +1104,33 @@ static void copy_rule_string(char *string, int *state_out)
|
||||
break;
|
||||
|
||||
case '$':
|
||||
output[ix++] = RULE_DOLLAR;
|
||||
c = 0;
|
||||
value = 0;
|
||||
mr = mnem_rules;
|
||||
while(mr->mnem != NULL)
|
||||
{
|
||||
len = strlen(mr->mnem);
|
||||
if(memcmp(p, mr->mnem, len) == 0)
|
||||
{
|
||||
c = mr->value;
|
||||
value = mr->value;
|
||||
p += len;
|
||||
break;
|
||||
}
|
||||
mr++;
|
||||
}
|
||||
if(c == 0)
|
||||
|
||||
if(state == 1)
|
||||
{
|
||||
// pre-rule, put the number before the RULE_DOLLAR
|
||||
output[ix++] = value;
|
||||
c = RULE_DOLLAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
output[ix++] = RULE_DOLLAR;
|
||||
c = value;
|
||||
}
|
||||
|
||||
if(value == 0)
|
||||
{
|
||||
fprintf(f_log,"%5d: $ command not recognized\n",linenum);
|
||||
error_count++;
|
||||
|
||||
+36
-8
@@ -1929,6 +1929,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
int add_points;
|
||||
int command;
|
||||
int check_atstart;
|
||||
unsigned int *flags;
|
||||
|
||||
MatchRecord match;
|
||||
static MatchRecord best;
|
||||
@@ -2166,11 +2167,11 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
|
||||
case RULE_DOLLAR:
|
||||
command = *rule++;
|
||||
if(command == 0x01)
|
||||
if(command == DOLLAR_UNPR)
|
||||
{
|
||||
match.end_type = SUFX_UNPRON; // $unpron
|
||||
}
|
||||
else if(command == 0x02) // $noprefix
|
||||
else if(command == DOLLAR_NOPREFIX) // $noprefix
|
||||
{
|
||||
if(word_flags & FLAG_PREFIX_REMOVED)
|
||||
failed = 1; // a prefix has been removed
|
||||
@@ -2185,16 +2186,20 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
else
|
||||
failed = 1;
|
||||
}
|
||||
else if((command & 0xf0) == 0x20)
|
||||
else if(((command & 0xf0) == 0x20) || (command == DOLLAR_LIST))
|
||||
{
|
||||
// $p_alt
|
||||
// $list or $p_alt
|
||||
// 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(LookupFlags(tr, &word_buf[1]) & (1 << (BITNUM_FLAG_ALT + (command & 0xf))))
|
||||
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;
|
||||
@@ -2408,6 +2413,28 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
failed = 1;
|
||||
break;
|
||||
|
||||
case RULE_DOLLAR:
|
||||
command = *rule++;
|
||||
if((command==DOLLAR_LIST) || ((command & 0xf0) == 0x20))
|
||||
{
|
||||
// $list or $p_alt
|
||||
// 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;
|
||||
|
||||
case RULE_SYLLABLE:
|
||||
/* more than specified number of vowels to the left */
|
||||
syllable_count = 1;
|
||||
@@ -3586,14 +3613,15 @@ int Lookup(Translator *tr, const char *word, char *ph_out)
|
||||
}
|
||||
|
||||
|
||||
int LookupFlags(Translator *tr, const char *word)
|
||||
{//==============================================
|
||||
int LookupFlags(Translator *tr, const char *word, unsigned int **flags_out)
|
||||
{//===========================================================================
|
||||
char buf[100];
|
||||
static unsigned int flags[2];
|
||||
char *word1 = (char *)word;
|
||||
|
||||
flags[0] = flags[1] = 0;
|
||||
LookupDictList(tr, &word1, buf, flags, 0, NULL);
|
||||
*flags_out = flags;
|
||||
return(flags[0]);
|
||||
}
|
||||
|
||||
@@ -3654,7 +3682,7 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
||||
}
|
||||
|
||||
// remove bytes from the end of the word and replace them by spaces
|
||||
for(i=0; (i<len_ending) && (i < sizeof(ending)-1); i++)
|
||||
for(i=0; (i<len_ending) && (i < (int)sizeof(ending)-1); i++)
|
||||
{
|
||||
ending[i] = word_end[i];
|
||||
word_end[i] = ' ';
|
||||
|
||||
+7
-1
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* Copyright (C) 2013 by Reece H. Dunn *
|
||||
* *
|
||||
@@ -139,6 +139,12 @@ if(argc > 1)
|
||||
if(strcmp(param,"--compile")==0)
|
||||
{
|
||||
samplerate_native = samplerate = 22050;
|
||||
LoadPhData(NULL);
|
||||
if(LoadVoice("", 0) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to load default voice\n");
|
||||
exit(1);
|
||||
}
|
||||
CompilePhonemeData();
|
||||
CompileIntonation();
|
||||
}
|
||||
|
||||
@@ -399,6 +399,14 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
|
||||
InterpretPhoneme(tr, 0x100, plist3, &phdata, &worddata);
|
||||
|
||||
if((alternative = phdata.pd_param[pd_CHANGE_NEXTPHONEME]) > 0)
|
||||
{
|
||||
ph_list3[j+1].ph = phoneme_tab[alternative];
|
||||
ph_list3[j+1].phcode = alternative;
|
||||
ph_list3[j+1].type = phoneme_tab[alternative]->type;
|
||||
next = phoneme_tab[alternative];
|
||||
}
|
||||
|
||||
if(((alternative = phdata.pd_param[pd_INSERTPHONEME]) > 0) && (inserted == 0))
|
||||
{
|
||||
// PROBLEM: if we insert a phoneme before a vowel then we loose the stress.
|
||||
|
||||
+13
-10
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -343,19 +343,22 @@ void ProsodyDisplay::OnMouse(wxMouseEvent& event)
|
||||
|
||||
line = pt.y / FRAMEHEIGHT;
|
||||
|
||||
// find which phoneme is selected on this line
|
||||
for(ix=linetab[line]; (ix<linetab[line+1]) && (ix<numph); ix++)
|
||||
if(line < num_lines)
|
||||
{
|
||||
xpos += GetWidth(&phlist[ix]);
|
||||
if(xpos > pt.x)
|
||||
// find which phoneme is selected on this line
|
||||
for(ix=linetab[line]; (ix<linetab[line+1]) && (ix<numph); ix++)
|
||||
{
|
||||
selected_ph = ix;
|
||||
SelectPh(selected_ph);
|
||||
break;
|
||||
xpos += GetWidth(&phlist[ix]);
|
||||
if(xpos > pt.x)
|
||||
{
|
||||
selected_ph = ix;
|
||||
SelectPh(selected_ph);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RefreshLine(line);
|
||||
RefreshLine(line);
|
||||
}
|
||||
|
||||
if(event.RightDown())
|
||||
{
|
||||
|
||||
+15
-3
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -2092,7 +2092,13 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
|
||||
}
|
||||
if((attr2 = GetSsmlAttribute(px,"time")) != NULL)
|
||||
{
|
||||
value = (attrnumber(attr2,0,1) * 25) / speed.pause_factor; // compensate for speaking speed to keep constant pause length
|
||||
value2 = attrnumber(attr2,0,1); // pause in mS
|
||||
|
||||
// compensate for speaking speed to keep constant pause length, see function PauseLength()
|
||||
// 'value' here is x 10mS
|
||||
value = (value2 * 256) / (speed.clause_pause_factor * 10);
|
||||
if(value < 200)
|
||||
value = (value2 * 256) / (speed.pause_factor * 10);
|
||||
|
||||
if(terminator == 0)
|
||||
terminator = CLAUSE_NONE;
|
||||
@@ -2100,7 +2106,13 @@ static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outb
|
||||
if(terminator)
|
||||
{
|
||||
if(value > 0xfff)
|
||||
value = 0xfff;
|
||||
{
|
||||
// scale down the value and set a scaling indicator bit
|
||||
value = value / 32;
|
||||
if(value > 0xfff)
|
||||
value = 0xfff;
|
||||
terminator |= CLAUSE_PAUSE_LONG;
|
||||
}
|
||||
return(terminator + value);
|
||||
}
|
||||
break;
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@
|
||||
#include "translate.h"
|
||||
#include "wave.h"
|
||||
|
||||
const char *version_string = "1.48.02 02.Feb.14";
|
||||
const char *version_string = "1.48.03 04.Mar.14";
|
||||
const int version_phdata = 0x014801;
|
||||
|
||||
int option_device_number = -1;
|
||||
|
||||
+14
-4
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -188,7 +188,7 @@ static void DoPitch(unsigned char *env, int pitch1, int pitch2)
|
||||
|
||||
int PauseLength(int pause, int control)
|
||||
{//====================================
|
||||
int len;
|
||||
unsigned int len;
|
||||
|
||||
if(control == 0)
|
||||
{
|
||||
@@ -210,8 +210,10 @@ int PauseLength(int pause, int control)
|
||||
|
||||
static void DoPause(int length, int control)
|
||||
{//=========================================
|
||||
// length in nominal mS
|
||||
// control = 1, less shortening at fast speeds
|
||||
int len;
|
||||
unsigned int len;
|
||||
int srate2;
|
||||
|
||||
if(length == 0)
|
||||
len = 0;
|
||||
@@ -219,7 +221,15 @@ static void DoPause(int length, int control)
|
||||
{
|
||||
len = PauseLength(length, control);
|
||||
|
||||
len = (len * samplerate) / 1000; // convert from mS to number of samples
|
||||
if(len < 90000)
|
||||
{
|
||||
len = (len * samplerate) / 1000; // convert from mS to number of samples
|
||||
}
|
||||
else
|
||||
{
|
||||
srate2 = samplerate / 25; // avoid overflow
|
||||
len = (len * srate2) / 40;
|
||||
}
|
||||
}
|
||||
|
||||
EndPitch(1);
|
||||
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -212,7 +212,7 @@ typedef struct {
|
||||
unsigned char tone_ph; // tone phoneme to use with this vowel
|
||||
|
||||
PHONEME_TAB *ph;
|
||||
short length; // length_mod
|
||||
unsigned int length; // length_mod
|
||||
unsigned char env; // pitch envelope number
|
||||
unsigned char type;
|
||||
unsigned char prepause;
|
||||
@@ -239,6 +239,7 @@ typedef struct {
|
||||
#define pd_INSERTPHONEME i_INSERT_PHONEME
|
||||
#define pd_APPENDPHONEME i_APPEND_PHONEME
|
||||
#define pd_CHANGEPHONEME i_CHANGE_PHONEME
|
||||
#define pd_CHANGE_NEXTPHONEME i_REPLACE_NEXT_PHONEME
|
||||
#define pd_LENGTHMOD i_SET_LENGTH
|
||||
|
||||
#define pd_FORNEXTPH 0x2
|
||||
@@ -379,7 +380,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
int pause_factor;
|
||||
int clause_pause_factor;
|
||||
int min_pause;
|
||||
unsigned int min_pause;
|
||||
int wav_factor;
|
||||
int lenmod_factor;
|
||||
int lenmod2_factor;
|
||||
|
||||
@@ -781,7 +781,7 @@ Translator *SelectTranslator(const char *name)
|
||||
static const unsigned char stress_amps_eu[8] = {16,16, 18,18, 18,18, 18,18 };
|
||||
SetupTranslator(tr,stress_lengths_eu,stress_amps_eu);
|
||||
tr->langopts.stress_rule = STRESSPOSN_2L; // ?? second syllable ??
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_AND_UNITS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_VIGESIMAL;
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_VIGESIMAL;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
+3
-1
@@ -104,7 +104,6 @@ static int embedded_read;
|
||||
unsigned int embedded_list[N_EMBEDDED_LIST];
|
||||
|
||||
// the source text of a single clause (UTF8 bytes)
|
||||
#define N_TR_SOURCE 800
|
||||
static char source[N_TR_SOURCE+40]; // extra space for embedded command & voice change info at end
|
||||
|
||||
int n_replace_phonemes;
|
||||
@@ -2655,6 +2654,9 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
charix[charix_top+3] = 0;
|
||||
|
||||
clause_pause = (terminator & 0xfff) * 10; // mS
|
||||
if(terminator & CLAUSE_PAUSE_LONG)
|
||||
clause_pause = clause_pause * 32 ; // pause value is *320mS not *10mS
|
||||
|
||||
tone = (terminator >> 12) & 0x7;
|
||||
if(tone2 != 0)
|
||||
{
|
||||
|
||||
+13
-2
@@ -26,6 +26,9 @@
|
||||
#define N_WORD_PHONEMES 200 // max phonemes in a word
|
||||
#define N_WORD_BYTES 160 // max bytes for the UTF8 characters in a word
|
||||
#define N_CLAUSE_WORDS 300 // max words in a clause
|
||||
#define N_TR_SOURCE 800 // the source text of a single clause (UTF8 bytes)
|
||||
|
||||
|
||||
#define N_RULE_GROUP2 120 // max num of two-letter rule chains
|
||||
#define N_HASH_DICT 1024
|
||||
#define N_CHARSETS 20
|
||||
@@ -180,6 +183,11 @@
|
||||
#define RULE_SPELLING 31 // W while spelling letter-by-letter
|
||||
#define RULE_LAST_RULE 31
|
||||
|
||||
#define DOLLAR_UNPR 0x01
|
||||
#define DOLLAR_NOPREFIX 0x02
|
||||
#define DOLLAR_LIST 0x03
|
||||
|
||||
|
||||
#define LETTERGP_A 0
|
||||
#define LETTERGP_B 1
|
||||
#define LETTERGP_C 2
|
||||
@@ -191,7 +199,7 @@
|
||||
|
||||
|
||||
// Punctuation types returned by ReadClause()
|
||||
// bits 0-7 pause x 10mS, bits 12-14 intonation type,
|
||||
// bits 0-11 pause x 10mS
|
||||
// bits12-14 intonation type
|
||||
// bit 15- don't need space after the punctuation
|
||||
// bit 19=sentence, bit 18=clause, bits 17=voice change
|
||||
@@ -199,6 +207,8 @@
|
||||
// bit 20= punctuation character can be inside a word (Armenian)
|
||||
// bit 21= speak the name of the punctuation character
|
||||
// bit 22= dot after the last word
|
||||
// bit 23= pause is x 320mS (not x 10mS)
|
||||
|
||||
#define CLAUSE_BIT_SENTENCE 0x80000
|
||||
#define CLAUSE_BIT_CLAUSE 0x40000
|
||||
#define CLAUSE_BIT_VOICE 0x20000
|
||||
@@ -206,6 +216,7 @@
|
||||
#define PUNCT_IN_WORD 0x100000
|
||||
#define PUNCT_SAY_NAME 0x200000
|
||||
#define CLAUSE_DOT 0x400000
|
||||
#define CLAUSE_PAUSE_LONG 0x800000
|
||||
|
||||
#define CLAUSE_NONE ( 0 + 0x04000)
|
||||
#define CLAUSE_PARAGRAPH (70 + 0x80000)
|
||||
@@ -741,7 +752,7 @@ int SetTranslator2(const char *name);
|
||||
void DeleteTranslator(Translator *tr);
|
||||
void ProcessLanguageOptions(LANGUAGE_OPTIONS *langopts);
|
||||
int Lookup(Translator *tr, const char *word, char *ph_out);
|
||||
int LookupFlags(Translator *tr, const char *word);
|
||||
int LookupFlags(Translator *tr, const char *word, unsigned int **flags_out);
|
||||
|
||||
int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *flags, WORD_TAB *wtab, int control);
|
||||
int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab);
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2014 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
|
||||
Reference in New Issue
Block a user