Merge branch 'upstream' into development

Conflicts:
	dictsource/dict_phonemes
	phsource/compile_report
This commit is contained in:
Reece H. Dunn
2013-03-11 22:13:40 +00:00
40 changed files with 677 additions and 498 deletions
+51 -41
View File
@@ -578,6 +578,7 @@ void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_b
} // end of LookupLetter
static const char *hex_letters[] = {"'e:j","b'i:","s'i:","d'i:","'i:","'Ef"}; // using phonemes available to all languages
int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
{//=========================================================================
@@ -593,6 +594,8 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
char *p2;
char *pbuf;
ALPHABET *alphabet;
int al_offset;
int al_flags;
int language;
int phontab_1;
int speak_letter_number;
@@ -633,14 +636,21 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
return(0);
}
alphabet = AlphabetFromChar(letter);
al_offset = 0;
al_flags = 0;
if((alphabet = AlphabetFromChar(letter)) != NULL)
{
al_offset = alphabet->offset;
al_flags = alphabet->flags;
}
if(alphabet != current_alphabet)
{
// speak the name of the alphabet
current_alphabet = alphabet;
if((alphabet != NULL) && !(alphabet->flags & AL_DONT_NAME) && (alphabet->offset != translator->letter_bits_offset))
if((alphabet != NULL) && !(al_flags & AL_DONT_NAME) && (al_offset != translator->letter_bits_offset))
{
if((alphabet->flags & AL_DONT_NAME) || (alphabet->offset == translator->langopts.alt_alphabet))
if((al_flags & AL_DONT_NAME) || (al_offset == translator->langopts.alt_alphabet))
{
// don't say the alphabet name
}
@@ -680,7 +690,7 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
if(ph_buf[0] == 0)
{
if((alphabet != NULL) && (alphabet->language != 0) && !(alphabet->flags & AL_NOT_LETTERS))
if((alphabet != NULL) && (alphabet->language != 0) && !(al_flags & AL_NOT_LETTERS))
language = alphabet->language;
else
language = L('e','n');
@@ -715,49 +725,27 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
if(ph_buf[0] == 0)
{
// character name not found
if((letter >= 0x2800) && (letter <= 0x28ff))
{
// braille dots symbol
Lookup(translator, "_braille", ph_buf);
if(ph_buf[0] == 0)
{
EncodePhonemes("br'e:l", ph_buf, NULL);
}
if(ph_buf[0] != 0)
{
pbuf = ph_buf + strlen(ph_buf);
for(ix=0; ix<8; ix++)
{
if(letter & (1 << ix))
{
*pbuf++ = phonPAUSE_VSHORT;
LookupLetter(translator, '1'+ix, 0, pbuf, 1);
pbuf += strlen(pbuf);
}
}
}
}
if(ph_buf[0]== 0)
{
if(iswalpha(letter))
Lookup(translator, "_?A", ph_buf);
if((ph_buf[0]==0) && !iswspace(letter))
Lookup(translator, "_??", ph_buf);
speak_letter_number = 1;
if(ph_buf[0] == 0)
if(!(al_flags & AL_NO_SYMBOL))
{
EncodePhonemes("l'et@", ph_buf, NULL);
if(translator->letter_bits_offset != 0)
speak_letter_number = 0; // non-latin alphabet, no _?? entry, may not be able to speak hexadecimal
if(iswalpha(letter))
Lookup(translator, "_?A", ph_buf);
if((ph_buf[0]==0) && !iswspace(letter))
Lookup(translator, "_??", ph_buf);
if(ph_buf[0] == 0)
{
EncodePhonemes("l'et@", ph_buf, NULL);
}
}
if(!(control & 2) && (alphabet != NULL) && (alphabet->flags & AL_NOT_CODE))
if(!(control & 2) && (al_flags & AL_NOT_CODE))
{
// don't speak the character code number
// don't speak the character code number, unless we want full details of this character
speak_letter_number = 0;
}
@@ -766,14 +754,36 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
if(speak_letter_number)
{
// speak the hexadecimal number of the character code
sprintf(hexbuf,"%x",letter);
if(al_offset == 0x2800)
{
// braille dots symbol, list the numbered dots
p2 = hexbuf;
for(ix=0; ix<8; ix++)
{
if(letter & (1 << ix))
{
*p2++ = '1'+ix;
}
}
*p2 = 0;
}
else
{
// speak the hexadecimal number of the character code
sprintf(hexbuf,"%x",letter);
}
pbuf = ph_buf;
for(p2 = hexbuf; *p2 != 0; p2++)
{
pbuf += strlen(pbuf);
*pbuf++ = phonPAUSE_VSHORT;
LookupLetter(translator, *p2, 0, pbuf, 1);
if(((pbuf[0] == 0) || (pbuf[0]==phonSWITCH)) && (*p2 >= 'a'))
{
// This language has no translation for 'a' to 'f', speak English names using base phonemes
EncodePhonemes(hex_letters[*p2 - 'a'], pbuf, NULL);
}
}
strcat(pbuf, pause_string);
}
+25 -13
View File
@@ -47,7 +47,6 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST *plist_out)
int replace_flags;
int n_plist_out = 0;
int word_end;
int switched_language = 0;
PHONEME_LIST2 *plist2;
PHONEME_TAB *next=NULL;
@@ -55,11 +54,8 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST *plist_out)
{
plist2 = &ph_list2[ix];
if(plist2->phcode == phonSWITCH)
switched_language ^= 1;
// don't do any substitution if the language has been temporarily changed
if(switched_language == 0)
if(!(plist2->synthflags & SFLAG_SWITCHED_LANG))
{
if(ix < (n_ph_list2 -1))
next = phoneme_tab[ph_list2[ix+1].phcode];
@@ -81,6 +77,9 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST *plist_out)
if((replace_flags & 2) && ((plist2->stresslevel & 0x7) > 3))
continue; // this replacement doesn't occur in stressed syllables
if((replace_flags & 4) && (plist2->sourceix == 0))
continue; // this replacement only occurs at the start of a word
// substitute the replacement phoneme
plist2->phcode = replace_phonemes[k].new_ph;
if((plist2->stresslevel > 1) && (phoneme_tab[plist2->phcode]->phflags & phUNSTRESSED))
@@ -117,7 +116,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
PHONEME_TAB *next, *next2;
int unstress_count = 0;
int word_stress = 0;
int switched_language = 0;
int current_phoneme_tab;
int max_stress;
int voicing;
int regression;
@@ -166,6 +165,20 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
}
}
// look for switch of phoneme tables
current_phoneme_tab = tr->phoneme_tab_ix;
for(j = 0; j < n_ph_list2; j++)
{
if(plist2[j].phcode == phonSWITCH)
{
current_phoneme_tab = plist2[j].tone_ph;
}
if(current_phoneme_tab != tr->phoneme_tab_ix)
{
plist2[j].synthflags |= SFLAG_SWITCHED_LANG;
}
}
if((regression = tr->langopts.param[LOPT_REGRESSIVE_VOICING]) != 0)
{
// set consonant clusters to all voiced or all unvoiced
@@ -180,10 +193,12 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
if(ph == NULL)
continue;
if(ph->code == phonSWITCH)
switched_language ^= 1;
if(switched_language)
if(plist2[j].synthflags & SFLAG_SWITCHED_LANG)
{
stop_propagation = 0;
voicing = 0;
continue;
}
type = ph->type;
@@ -295,8 +310,6 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
ph = phoneme_tab[phonPAUSE];
ph_list3[0].ph = ph;
switched_language = 0;
for(j=0; insert_ph || ((j < n_ph_list3) && (ix < N_PHONEME_LIST-3)); j++)
{
plist3 = &ph_list3[j];
@@ -333,7 +346,6 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
// change phoneme table
SelectPhonemeTable(plist3->tone_ph);
switched_language ^= SFLAG_SWITCHED_LANG;
}
next = phoneme_tab[plist3[1].phcode]; // the phoneme after this one
plist3[1].ph = next;
@@ -534,7 +546,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
phlist[ix].ph = ph;
phlist[ix].type = ph->type;
phlist[ix].env = PITCHfall; // default, can be changed in the "intonation" module
phlist[ix].synthflags = plist3->synthflags | switched_language;
phlist[ix].synthflags = plist3->synthflags;
phlist[ix].stresslevel = plist3->stresslevel & 0xf;
phlist[ix].wordstress = plist3->wordstress;
phlist[ix].tone_ph = plist3->tone_ph;
+6 -2
View File
@@ -224,6 +224,7 @@ void ProsodyDisplay::SelectPh(int index)
const char *name = "?";
char buf[120];
char len_string[20];
char param_string[20];
if(index < 0) return;
@@ -245,11 +246,14 @@ void ProsodyDisplay::SelectPh(int index)
y1 = p->pitch1;
y2 = p->pitch2;
len_string[0] = 0;
param_string[0] = 0;
if(p->std_length > 0)
sprintf(len_string," Length %d", p->std_length*2);
if(p->sound_param != 0)
sprintf(param_string,", %d", p->sound_param);
sprintf(buf,"Stress %s%d Amp %2d LengthMod %2d Pitch %3d %3d %s PhFlags %.2x [%s%s]",
emphasized,p->stresslevel&0x7,p->amp, p->length,y1,y2,name,p->ph->phflags, LookupManifest(p->phontab_addr), len_string);
sprintf(buf,"Stress %s%d Amp %2d LengthMod %2d Pitch %3d %3d %s PhFlags %.2x (%s%s)%s",
emphasized,p->stresslevel&0x7,p->amp, p->length,y1,y2,name,p->ph->phflags, LookupManifest(p->phontab_addr), param_string, len_string);
wxLogStatus(wxString(buf,wxConvLocal));
}
+7 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.46.45 10.Mar.13";
const char *version_string = "1.46.46 11.Mar.13";
const int version_phdata = 0x014640;
int option_device_number = -1;
@@ -1225,9 +1225,15 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
#ifdef _ESPEAKEDIT
plist->std_length = phdata->pd_param[i_SET_LENGTH];
if(phdata->sound_addr[0] != 0)
{
plist->phontab_addr = phdata->sound_addr[0]; // FMT address
plist->sound_param = phdata->sound_param[0];
}
else
{
plist->phontab_addr = phdata->sound_addr[1]; // WAV address
plist->sound_param = phdata->sound_param[1];
}
#endif
} // end of InterpretPhoneme
-1
View File
@@ -1869,7 +1869,6 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control)
n_phoneme_list = 0;
WcmdqStop();
embedded_value[EMBED_T] = 0;
return(0);
}
+2 -1
View File
@@ -56,7 +56,7 @@
#define EMBED_A 3 // amplitude/volume
#define EMBED_R 4 // pitch range/expression
#define EMBED_H 5 // echo/reverberation
#define EMBED_T 6 // different tone for announcing punctuation
#define EMBED_T 6 // different tone for announcing punctuation (not used)
#define EMBED_I 7 // sound icon
#define EMBED_S2 8 // speed (used in synthesize)
#define EMBED_Y 9 // say-as commands
@@ -223,6 +223,7 @@ typedef struct {
#ifdef _ESPEAKEDIT
unsigned char std_length;
unsigned int phontab_addr;
int sound_param;
#endif
} PHONEME_LIST;
+1
View File
@@ -94,6 +94,7 @@ ALPHABET alphabets [] = {
{"_ka", OFFSET_GEORGIAN, 0x10a0,0x10ff, L('k','a'), AL_WORDS},
{"_ko", OFFSET_KOREAN, 0x1100,0x11ff, 0, 0},
{"_eth", OFFSET_ETHIOPIC, 0x1200,0x139f, 0, 0},
{"_braille", 0x2800, 0x2800,0x28ff, 0, AL_NO_SYMBOL},
{"_ja", 0x3040, 0x3040,0x30ff, 0, AL_NOT_CODE},
{"_zh", 0x3100, 0x3100,0x9fff, 0, AL_NOT_CODE},
{NULL, 0, 0, 0, 0, 0}
+1 -1
View File
@@ -2489,7 +2489,7 @@ static int TranslateChar(Translator *tr, char *ptr, int prev_in, unsigned int c,
}
static const char *UCase_ga[] = {"bp","bhf","dt","gc","hA","mb","ng","ts","tA","nA",NULL};
static const char *UCase_ga[] = {"bp","bhf","dt","gc","hA","mb","nd","ng","ts","tA","nA",NULL};
int UpperCaseInWord(Translator *tr, char *word, int c)
{//=====================================================
+1
View File
@@ -277,6 +277,7 @@ extern ALPHABET *current_alphabet;
#define AL_NOT_LETTERS 0x02 // don't use the language for speaking letters
#define AL_WORDS 0x04 // use the language to speak words
#define AL_NOT_CODE 0x08 // don't speak the character code
#define AL_NO_SYMBOL 0x10 // don't repeat "symbol" or "character"
#define N_LOPTS 21
+11 -3
View File
@@ -192,6 +192,12 @@ static char *fgets_strip(char *buf, int size, FILE *f_in)
if(fgets(buf,size,f_in) == NULL)
return(NULL);
if(buf[0] == '#')
{
buf[0] = 0;
return(buf);
}
len = strlen(buf);
while((--len > 0) && isspace(buf[len]))
buf[len] = 0;
@@ -389,8 +395,10 @@ void VoiceReset(int tone_only)
// Set voice to the default values
int pk;
static unsigned char default_heights[N_PEAKS] = {128,128,120,120,110,110,128,128,128};
static unsigned char default_widths[N_PEAKS] = {128,128,128,160,171,171,128,128,128};
// static unsigned char default_heights[N_PEAKS] = {140,128,120,110,90,90,128,128,128}; // changed for v.1.47
// static unsigned char default_widths[N_PEAKS] = {128,128,128,160,171,171,128,128,128};
static unsigned char default_heights[N_PEAKS] = {128,128,120,120,110,110,128,128,128}; // previous version
static unsigned char default_widths[N_PEAKS] = {140,128,128,160,171,171,128,128,128};
static int breath_widths[N_PEAKS] = {0,200,200,400,400,400,600,600,600};
@@ -411,7 +419,7 @@ void VoiceReset(int tone_only)
voice->n_harmonic_peaks = 5;
voice->peak_shape = 0;
voice->voicing = 64;
voice->consonant_amp = 100;
voice->consonant_amp = 85; // change to 85 for v.1.47 was 100
voice->consonant_ampv = 100;
voice->samplerate = samplerate_native;
memset(voice->klattv,0,sizeof(voice->klattv));
+13 -20
View File
@@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005 to 2007 by Jonathan Duddington *
* Copyright (C) 2005 to 2013 by Jonathan Duddington *
* email: jonsd@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -244,7 +244,7 @@ static unsigned char wavemult[N_WAVEMULT] = {
105, 98, 90, 83, 76, 69, 62, 55, 49, 43, 37, 32, 27, 22, 18, 14,
11, 8, 5, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// set from y = pow(2,x) * 128, x=-1 to 1
unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1] = {
@@ -592,7 +592,7 @@ static PaError Pa_OpenDefaultStream2( PaStream** stream,
hostApiOutputParameters.device = Pa_GetDefaultOutputDevice();
if( hostApiOutputParameters.device == paNoDevice )
return paDeviceUnavailable;
return paDeviceUnavailable;
hostApiOutputParameters.channelCount = outputChannelCount;
hostApiOutputParameters.sampleFormat = sampleFormat;
@@ -834,15 +834,6 @@ static void WavegenSetEcho(void)
amp = embedded_value[EMBED_H];
delay = 130;
}
#ifdef deleted
if(embedded_value[EMBED_T] > 0)
{
// announcing punctuation, add a small echo
// This seems unpopular
amp = embedded_value[EMBED_T] * 8;
delay = 60;
}
#endif
if(delay == 0)
amp = 0;
@@ -854,7 +845,7 @@ static void WavegenSetEcho(void)
if(amp > 20)
echo_length = echo_head * 2; // perhaps allow 2 echo periods if the echo is loud.
// echo_amp units are 1/256ths of the amplitude of the original sound.
// echo_amp units are 1/256ths of the amplitude of the original sound.
echo_amp = amp;
// compensate (partially) for increase in amplitude due to echo
general_amplitude = GetAmplitude();
@@ -1559,7 +1550,7 @@ static int SetWithRange0(int value, int max)
static void SetPitchFormants()
{//===========================
int ix;
int factor;
int factor = 256;
int pitch_value;
// adjust formants to give better results for a different voice pitch
@@ -1570,11 +1561,13 @@ static void SetPitchFormants()
{
// only adjust if the pitch is higher than normal
factor = 256 + (25 * (pitch_value - 50))/50;
for(ix=0; ix<=5; ix++)
{
wvoice->freq[ix] = (wvoice->freq2[ix] * factor)/256;
}
}
for(ix=0; ix<=5; ix++)
{
wvoice->freq[ix] = (wvoice->freq2[ix] * factor)/256;
}
factor = embedded_value[EMBED_T]*3;
wvoice->height[0] = (wvoice->height2[0] * (256 - factor*2))/256;
wvoice->height[1] = (wvoice->height2[1] * (256 - factor))/256;
@@ -1755,7 +1748,7 @@ if(option_log_frames)
fprintf(f_log,"%3dmS %3d %3d %4d %4d (%3d %3d %3d %3d) to %3d %3d %4d %4d (%3d %3d %3d %3d)\n",length*1000/samplerate,
fr1->ffreq[0],fr1->ffreq[1],fr1->ffreq[2],fr1->ffreq[3], fr1->fheight[0],fr1->fheight[1],fr1->fheight[2],fr1->fheight[3],
fr2->ffreq[0],fr2->ffreq[1],fr2->ffreq[2],fr2->ffreq[3], fr2->fheight[0],fr2->fheight[1],fr2->fheight[2],fr2->fheight[3] );
fclose(f_log);
f_log=NULL;
}
@@ -2036,7 +2029,7 @@ static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text
{
sonicSetSpeed(sonicSpeedupStream, sonicSpeed);
}
sonicWriteShortToStream(sonicSpeedupStream, outbuf, length_in);
}