[1.26.04] lang=pl, fixed bug where "nie" duplicated the next word.

Added attributes in voice file: voicing, breath, breathw.
Added "en-wisper" voice.
espeakedit, fixed crash when playing sounds using a voice file with a high pitch.
lang=it, use phoneme [u], not [U]
Added directory docs to svn.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@45 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2007-06-13 08:08:41 +00:00
parent 3ab4a32bab
commit 257ddb2436
33 changed files with 3439 additions and 255 deletions
+30 -31
View File
@@ -42,10 +42,11 @@
FILE *f_wavtest = NULL;
FILE *f_events = NULL;
int OpenWaveFile3(const char *path, int rate)
/******************************************/
FILE *OpenWaveFile3(const char *path)
/***********************************/
{
int *p;
FILE *f;
static unsigned char wave_hdr[44] = {
'R','I','F','F',0,0,0,0,'W','A','V','E','f','m','t',' ',
@@ -54,56 +55,54 @@ int OpenWaveFile3(const char *path, int rate)
if(path == NULL)
return(2);
return(NULL);
// set the sample rate in the header
p = (int *)(&wave_hdr[24]);
p[0] = rate;
p[1] = rate * 2;
p[0] = samplerate;
p[1] = samplerate * 2;
f_wavtest = fopen(path,"wb");
f = fopen(path,"wb");
if(f_wavtest != NULL)
if(f != NULL)
{
fwrite(wave_hdr,1,sizeof(wave_hdr),f_wavtest);
return(0);
fwrite(wave_hdr,1,sizeof(wave_hdr),f);
}
return(1);
return(f);
} // end of OpenWaveFile
void CloseWaveFile3(int rate)
/******************/
void CloseWaveFile3(FILE *f)
/*************************/
{
unsigned int pos;
static int value;
fflush(f_wavtest);
pos = ftell(f_wavtest);
fflush(f);
pos = ftell(f);
value = pos - 8;
fseek(f_wavtest,4,SEEK_SET);
fwrite(&value,4,1,f_wavtest);
fseek(f,4,SEEK_SET);
fwrite(&value,4,1,f);
value = rate;
fseek(f_wavtest,24,SEEK_SET);
fwrite(&value,4,1,f_wavtest);
value = samplerate;
fseek(f,24,SEEK_SET);
fwrite(&value,4,1,f);
value = rate*2;
fseek(f_wavtest,28,SEEK_SET);
fwrite(&value,4,1,f_wavtest);
value = samplerate*2;
fseek(f,28,SEEK_SET);
fwrite(&value,4,1,f);
value = pos - 44;
fseek(f_wavtest,40,SEEK_SET);
fwrite(&value,4,1,f_wavtest);
fseek(f,40,SEEK_SET);
fwrite(&value,4,1,f);
fclose(f_wavtest);
f_wavtest = NULL;
fclose(f);
} // end of CloseWaveFile2
} // end of CloseWaveFile3
int TestUriCallback(int type, const char *uri, const char *base)
@@ -126,7 +125,8 @@ if(f_wavtest == NULL) return(0);
if(wav == NULL)
{
fprintf(f_events,"Finished\n");
CloseWaveFile3(samplerate);
CloseWaveFile3(f_wavtest);
f_wavtest = NULL;
fclose(f_events);
return(0);
}
@@ -1183,8 +1183,7 @@ void TestTest(int control)
//CharsetToUnicode("ISO-8859-4");
//CharsetToUnicode("ISCII");
//return;
return;
if(control==2)
{
@@ -1206,7 +1205,7 @@ if(control==2)
textbuf[ix] = 0;
fclose(f);
OpenWaveFile3("/home/jsd1/speechdata/text/test.wav",samplerate);
f_wavtest = OpenWaveFile3("/home/jsd1/speechdata/text/test.wav");
f_events = fopen("/home/jsd1/speechdata/text/events","w");
fprintf(f_events,"Audio Text Length Type Id\n");
+4 -2
View File
@@ -962,7 +962,8 @@ void SpectSeq::MakeWave(int start, int end, PitchEnvelope &pitch)
// }
len_samples = int(((total_length * lfactor + 50) * samplerate) / 1000);
SetPitch(len_samples,pitch.env,pitch.pitch1-pbase,pitch.pitch2-pbase);
// SetPitch(len_samples,pitch.env,pitch.pitch1-pbase,pitch.pitch2-pbase);
SetPitch(len_samples,pitch.env,9,44);
fname_speech = WavFileName();
OpenWaveFile2(fname_speech);
@@ -1038,7 +1039,8 @@ void SpectFrame::MakeWave(int control, PitchEnvelope &pitche, int amplitude, int
len_samples = (length * samplerate) / 1000;
pbase = voice->pitch_base >> 12;
SetPitch(len_samples + 50,pitche.env,pitche.pitch1-pbase,pitche.pitch2-pbase);
// SetPitch(len_samples + 50,pitche.env,pitche.pitch1-pbase,pitche.pitch2-pbase);
SetPitch(len_samples + 50,pitche.env,9,44);
fname_speech = WavFileName();
if(OpenWaveFile2(fname_speech) != 0)
+1 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.26.03 12.Jun.07";
const char *version_string = "1.26.04 13.Jun.07";
const int version_phdata = 0x012601;
int option_device_number = -1;
+11
View File
@@ -81,6 +81,15 @@ typedef struct {
DOUBLEX right_inc;
} wavegen_peaks_t;
typedef struct {
double a;
double b;
double c;
double x1;
double x2;
} RESONATOR;
typedef struct {
short length;
unsigned char n_frames;
@@ -240,3 +249,5 @@ int DoSample(PHONEME_TAB *ph1, PHONEME_TAB *ph2, int which, int length_mod, int
int DoSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB *next_ph,
int which, PHONEME_LIST *plist, int modulation);
int PauseLength(int pause);
void InitBreath(void);
+1 -1
View File
@@ -1187,8 +1187,8 @@ int Translator::TranslateWord2(char *word, WORD_TAB *wtab, int pre_pause, int ne
if(sylimit & 0x100)
{
// only if the second word has $alt attribute
flags2 = translator->TranslateWord(p2+1, 0, wtab+1);
strcpy(ph_buf,word_phonemes);
flags2 = translator->TranslateWord(p2+1, 0, wtab+1);
if((flags2 & FLAG_ALT_TRANS) == 0)
{
ok = 0;
+4
View File
@@ -36,6 +36,7 @@ typedef struct {
int echo_amp;
int n_harmonic_peaks; // highest formant which is formed from adding harmonics
int peak_shape; // alternative shape for formant peaks (0=standard 1=squarer)
int voicing; // 100% = 64, level of formant-synthesized sound
// parameters used by Wavegen
int freq[N_PEAKS]; // 100% = 256
@@ -47,6 +48,9 @@ typedef struct {
int height2[N_PEAKS]; // 100% = 256
int width2[N_PEAKS]; // 100% = 256
int breath[N_PEAKS]; // amount of breath for each formant. breath[0] indicates whether any are set.
int breathw[N_PEAKS]; // width of each breath formant
// This table provides the opportunity for tone control.
// Adjustment of harmonic amplitudes, steps of 8Hz
// value of 128 means no change
+37 -12
View File
@@ -84,23 +84,26 @@ char voice_name[40];
#define V_ROUGHNESS 11
#define V_CLARITY 12
#define V_TONE 13
#define V_VOICING 14
#define V_BREATH 15
#define V_BREATHW 16
// these override defaults set by the translator
#define V_WORDGAP 15
#define V_INTONATION 16
#define V_STRESSLENGTH 17
#define V_STRESSAMP 18
#define V_STRESSADD 19
#define V_DICTRULES 20
#define V_STRESSRULE 21
#define V_CHARSET 22
#define V_NUMBERS 23
#define V_OPTION 24
#define V_WORDGAP 17
#define V_INTONATION 18
#define V_STRESSLENGTH 19
#define V_STRESSAMP 20
#define V_STRESSADD 21
#define V_DICTRULES 22
#define V_STRESSRULE 23
#define V_CHARSET 24
#define V_NUMBERS 25
#define V_OPTION 26
#define V_MBROLA 25
#define V_MBROLA 27
// these need a phoneme table to have been specified
#define V_REPLACE 26
#define V_REPLACE 28
@@ -133,6 +136,9 @@ static keywtab_t keyword_tab[] = {
{"roughness", V_ROUGHNESS},
{"clarity", V_CLARITY},
{"tone", V_TONE},
{"voicing", V_VOICING},
{"breath", V_BREATH},
{"breathw", V_BREATHW},
{"numbers", V_NUMBERS},
{"option", V_OPTION},
{"mbrola", V_MBROLA},
@@ -352,7 +358,9 @@ static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname, const char*lea
void VoiceReset(int tone_only)
{//===========================
// Set voice to the default values
int pk;
static int breath_widths[N_PEAKS] = {0,200,200,400,400,400,600,600,600};
// default is: pitch 82,118
voice->pitch_base = 0x49000; // default, 73 << 12;
@@ -363,17 +371,21 @@ void VoiceReset(int tone_only)
voice->flutter = 64;
voice->n_harmonic_peaks = 5;
voice->peak_shape = 1;
voice->voicing = 64;
#ifdef PLATFORM_RISCOS
voice->roughness = 1;
#else
voice->roughness = 2;
#endif
InitBreath();
for(pk=0; pk<N_PEAKS; pk++)
{
voice->freq[pk] = 256;
voice->height[pk] = 256;
voice->width[pk] = 256;
voice->breath[pk] = 0;
voice->breathw[pk] = breath_widths[pk]; // default breath formant woidths
// adjust formant smoothing depending on sample rate
formant_rate[pk] = (formant_rate_22050[pk] * 22050)/samplerate;
@@ -769,6 +781,19 @@ voice_t *LoadVoice(char *vname, int control)
}
break;
case V_VOICING:
if(sscanf(p,"%d",&value)==1)
voice->voicing = (value * 64)/100;
break;
case V_BREATH:
voice->breath[0] = Read8Numbers(p,&voice->breath[1]);
break;
case V_BREATHW:
voice->breathw[0] = Read8Numbers(p,&voice->breathw[1]);
break;
case V_MBROLA:
{
char name[40];
+126 -1
View File
@@ -49,7 +49,7 @@
#include "sintab.h"
#define PI 3.1415927
#define PI2 6.283185307
#define STEPSIZE 64 // 2.9mS at 22 kHz sample rate
#define N_WAV_BUF 10
@@ -82,6 +82,9 @@ static int echo_tail;
static int echo_amp = 0;
static short echo_buf[N_ECHO_BUF];
static int voicing;
RESONATOR rbreath[N_PEAKS];
static int harm_sqrt_n = 0;
@@ -124,6 +127,9 @@ static int cycle_samples; // number of samples in a cycle at current pit
static int cbytes;
static int hf_factor;
static double minus_pi_t;
static double two_pi_t;
unsigned char *out_ptr;
unsigned char *out_start;
@@ -770,6 +776,7 @@ static void WavegenSetEcho(void)
int delay;
int amp;
voicing = wvoice->voicing;
delay = wvoice->echo_delay;
amp = wvoice->echo_amp;
@@ -824,6 +831,8 @@ int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control)
if(wvoice == NULL)
return(1);
hmax = (peaks[wvoice->n_harmonic_peaks].freq + peaks[wvoice->n_harmonic_peaks].right)/pitch;
if(hmax >= MAX_HARMONIC)
hmax = MAX_HARMONIC-1;
// restrict highest harmonic to half the samplerate
hmax_samplerate = (((samplerate * 19)/40) << 16)/pitch; // only 95% of Nyquist freq
@@ -961,6 +970,110 @@ static void AdvanceParameters()
static double resonator(RESONATOR *r, double input)
{//================================================
double x;
x = r->a * input + r->b * r->x1 + r->c * r->x2;
r->x2 = r->x1;
r->x1 = x;
return x;
}
static void setresonator(RESONATOR *rp, int freq, int bwidth, int init)
{//====================================================================
// freq Frequency of resonator in Hz
// bwidth Bandwidth of resonator in Hz
// init Initialize internal data
double x;
double arg;
if(init)
{
rp->x1 = 0;
rp->x2 = 0;
}
// x = exp(-pi * bwidth * t)
arg = minus_pi_t * bwidth;
x = exp(arg);
// c = -(x*x)
rp->c = -(x * x);
// b = x * 2*cos(2 pi * freq * t)
arg = two_pi_t * freq;
rp->b = x * cos(arg) * 2.0;
// a = 1.0 - b - c
rp->a = 1.0 - rp->b - rp->c;
} // end if setresonator
void InitBreath(void)
{//==================
int ix;
minus_pi_t = -PI / samplerate;
two_pi_t = -2.0 * minus_pi_t;
for(ix=0; ix<N_PEAKS; ix++)
{
setresonator(&rbreath[ix],2000,200,1);
}
} // end of InitBreath
void SetBreath()
{//=============
int pk;
if(wvoice->breath[0] == 0)
return;
for(pk=1; pk<N_PEAKS; pk++)
{
if(wvoice->breath[pk] != 0)
{
// breath[0] indicates that some breath formants are needed
// set the freq from the current ynthesis formant and the width from the voice data
setresonator(&rbreath[pk], peaks[pk].freq >> 16, wvoice->breathw[pk],0);
}
}
} // end of SetBreath
#define getrandom(min,max) ((rand()%(int)(((max)+1)-(min)))+(min))
int ApplyBreath(void)
{//==================
int noise;
int ix;
int amp;
int value = 0;
noise = getrandom(-4095,4095);
for(ix=1; ix < N_PEAKS; ix++)
{
if((amp = wvoice->breath[ix]) > 0)
{
amp *= (peaks[ix].height >> 13);
value += int(resonator(&rbreath[ix],noise) * amp);
}
}
return (value);
}
static int Wavegen()
{//=================
unsigned short waveph;
@@ -1015,6 +1128,7 @@ static int Wavegen()
hswitch ^= 1;
maxh2 = PeaksToHarmspect(peaks,pitch<<4,hspect[hswitch],1);
SetBreath();
}
else
if((samplecount & 0x07) == 0)
@@ -1150,6 +1264,17 @@ static int Wavegen()
h++;
}
#endif
if(voicing != 64)
{
total = (total >> 6) * voicing;
}
if(wvoice->breath[0])
{
total += ApplyBreath();
}
// mix with sampled wave if required
z2 = 0;
if(mix_wavefile_ix < n_mix_wavefile)