[1.26.05] Fix count of upper-case letters in a word to consider multibyte characters.

Mbrola translations, option to not match across a word boundary.
Mbrola translations, allow check of lengthen indicator [:].
espeakedit, add operation to apply a voice's formants modifications to a keyframe.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@47 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2007-06-14 18:41:52 +00:00
parent 2dbbff737b
commit 188b0d7c11
20 changed files with 220 additions and 131 deletions
+1 -1
View File
@@ -129,7 +129,7 @@ wxMenuBar *MakeMenu(int type)
menu_bar->Append(voice_menu, _T("&Voice"));
menu_bar->Append(option_menu, _T("&Options"));
menu_bar->Append(tools_menu, _T("&Tools"));
menu_bar->Append(data_menu, _T("&Data"));
menu_bar->Append(data_menu, _T("&Compile"));
menu_bar->Append(help_menu, _T("&Help"));
return(menu_bar);
+23 -9
View File
@@ -239,8 +239,11 @@ static int GetC(void)
int c;
int c1;
int c2;
int cbuf[4];
int ix;
int n_bytes;
unsigned char m;
static int ungot2 = 0;
static const unsigned char mask[4] = {0xff,0x1f,0x0f,0x07};
static const unsigned char mask2[4] = {0,0x80,0x20,0x30};
@@ -250,7 +253,16 @@ static int GetC(void)
return(c1);
}
c1 = GetC_get();
if(ungot2 != 0)
{
c1 = ungot2;
ungot2 = 0;
}
else
{
c1 = GetC_get();
}
if(option_multibyte == espeakCHARS_WCHAR)
{
count_characters++;
@@ -271,14 +283,13 @@ static int GetC(void)
if(((c1 & 0xf8) == 0xf0) && ((c1 & 0x0f) <= 4))
n_bytes = 3;
if(n_bytes > 0)
if((ix = n_bytes) > 0)
{
c = c1 & mask[n_bytes];
m = mask2[n_bytes];
while(n_bytes > 0)
c = c1 & mask[ix];
m = mask2[ix];
while(ix > 0)
{
c2 = GetC_get();
if(c2 == 0)
if((c2 = cbuf[ix] = GetC_get()) == 0)
{
if(option_multibyte==espeakCHARS_AUTO)
option_multibyte=espeakCHARS_8BIT; // change "auto" option to "no"
@@ -288,14 +299,17 @@ static int GetC(void)
if((c2 & 0xc0) != 0x80)
{
// This is not UTF8. Change to 8-bit characterset.
if(n_bytes > 1)
ungot2 = cbuf[2];
GetC_unget(c2);
break;
}
m = 0x80;
c = (c << 6) + (c2 & 0x3f);
n_bytes--;
ix--;
}
if(n_bytes == 0)
if(ix == 0)
{
count_characters++;
return(c);
+15
View File
@@ -377,6 +377,21 @@ void SpectFrame::ToggleMarker(int n)
}
void SpectFrame::ApplyVoiceMods()
{//==============================
// apply the modifications to the formants which are defined in the current voice
int pk;
for(pk=0; pk<N_PEAKS; pk++)
{
peaks[pk].pkfreq = (peaks[pk].pkfreq * voice->freq2[pk])/256;
peaks[pk].pkheight = (peaks[pk].pkheight * voice->height2[pk])/256;
peaks[pk].pkwidth = (peaks[pk].pkwidth * voice->width2[pk])/256;
peaks[pk].pkright = (peaks[pk].pkright * voice->width2[pk])/256;
}
}
double SpectFrame::GetRms(int seq_amplitude)
{//=========================================
+1
View File
@@ -98,6 +98,7 @@ public:
void ZeroPeaks();
void CopyPeaks(SpectFrame *sf);
void ToggleMarker(int n);
void ApplyVoiceMods();
void MakeWave(int peaks, PitchEnvelope &pitch, int amplitude, int duration);
void MakeHtab(int numh, int *htab, int pitch);
+7 -1
View File
@@ -468,7 +468,7 @@ void SpectDisplay::OnMenu(wxCommandEvent& event)
int code;
wxKeyEvent keyevent;
SpectFrame *sf;
static int key[] = {0x1044,0x3044,0x104e,0x1047,0x105a,0x1051,0x3051,WXK_F1,WXK_F2,0x1049};
static int key[] = {0x1044,0x3044,0x104e,0x1047,0x105a,0x1051,0x3051,WXK_F1,WXK_F2,0x1049,WXK_F10};
id = event.GetId();
@@ -773,6 +773,11 @@ void SpectDisplay::OnKey(wxKeyEvent& event)
display = 2;
break;
case WXK_F10:
sf->ApplyVoiceMods();
display = 2;
break;
case WXK_F2:
// make and play sequence
ReadDialogValues();
@@ -1002,6 +1007,7 @@ void InitSpectrumDisplay()
menu_spectdisplay->Append(207,_T("Hide Interpolation CTRL+SHIFT+Q"));
menu_spectdisplay->Append(205,_T("Zero Peaks CTRL+Z"));
menu_spectdisplay->Append(210,_T("Toggle Marker"),menu_markers);
menu_spectdisplay->Append(211,_T("Apply the formant adjustments from current voice"));
menu_spectdisplay->AppendSeparator();
menu_spectdisplay->Append(208,_T("Play Selected Frame F1"));
menu_spectdisplay->Append(209,_T("Play All F2"));
+9
View File
@@ -196,6 +196,7 @@ int GetMbrName(PHONEME_LIST *plist, PHONEME_TAB *ph, PHONEME_TAB *ph_prev, PHONE
// bit 0 skip the next phoneme
// bit 1 match this and Previous phoneme
// bit 2 only at the start of a word
// bit 4 don't match two phonemes across a word boundary
pr = mbrola_tab;
while(pr->name != 0)
@@ -205,9 +206,17 @@ int GetMbrName(PHONEME_LIST *plist, PHONEME_TAB *ph, PHONEME_TAB *ph_prev, PHONE
if(pr->next_phoneme == 0)
found = 1;
else
if((pr->next_phoneme == ':') && (plist->synthflags & SFLAG_LENGTHEN))
{
found = 1;
}
else
{
if(pr->control & 2)
other_ph = ph_prev;
else
if((pr->control & 8) && ((plist+1)->newword))
other_ph = phoneme_tab[phPAUSE]; // don't match the next phoneme over a word boundary
else
other_ph = ph_next;
+1 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.26.04 13.Jun.07";
const char *version_string = "1.26.05 14.Jun.07";
const int version_phdata = 0x012601;
int option_device_number = -1;
+5
View File
@@ -271,6 +271,7 @@ Translator *SelectTranslator(const char *name)
case L('h','r'): // Croatian
case L('s','r'): // Serbian
{
static const wchar_t replace_chars_hr[] =
{0x430,0x431,0x446,0x45b,0x447,0x434,0x452,0x45f,
@@ -389,6 +390,10 @@ Translator *SelectTranslator(const char *name)
tr = new Translator();
tr->charset_a0 = charsets[4]; // ISO-8859-4, includes a,e,i,o,u-macron
tr->langopts.stress_rule = 2;
tr->langopts.stress_flags = 0x21;
tr->langopts.unstressed_wd1 = 0;
tr->langopts.unstressed_wd2 = 2;
tr->langopts.param[LOPT_DIERESES] = 1;
}
break;
+6 -1
View File
@@ -1601,6 +1601,7 @@ void *Translator::TranslateClause(FILE *f_text, const void *vp_input, int *tone_
int dict_flags; // returned from dictionary lookup
int word_flags; // set here
int embedded_count = 0;
int letter_count = 0;
char *word;
char *p;
int j, k;
@@ -1854,6 +1855,8 @@ if((c == '/') && (langopts.testing & 2) && isdigit(next_in) && IsAlpha(prev_out)
{
if(!IsAlpha(prev_out) || (langopts.ideographs && (c >= 0x3000)))
{
letter_count = 0;
if((prev_out != ' ') && (prev_out != '\''))
{
// start of word, insert space if not one there already
@@ -1875,6 +1878,8 @@ if((c == '/') && (langopts.testing & 2) && isdigit(next_in) && IsAlpha(prev_out)
}
}
letter_count++;
if(iswupper(c))
{
c = towlower(c);
@@ -1909,7 +1914,7 @@ if((c == '/') && (langopts.testing & 2) && isdigit(next_in) && IsAlpha(prev_out)
source_index = prev_source_index; // unget
}
#endif
if((all_upper_case) && ((ix - words[word_count].start) > 1))
if((all_upper_case) && (letter_count > 2))
{
if((c == 's') && (next_in==' '))
{