[1.33] continued

git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@159 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2008-03-06 14:47:20 +00:00
parent c3b8c1b807
commit eab1faff96
23 changed files with 395 additions and 89 deletions
+4 -4
View File
@@ -1,4 +1,4 @@
# removed -fno-exceptions because it caused problems with stdio library on some platforms
# remove -fno-exceptions because it caused problems with stdio library on some platforms (ARM)
PREFIX=/
BINDIR=$(PREFIX)/usr/bin
@@ -6,7 +6,7 @@ INCDIR=$(PREFIX)/usr/include/espeak
LIBDIR=$(PREFIX)/usr/lib
DATADIR=$(PREFIX)/usr/share/espeak-data
RELEASE = 1.31
RELEASE = 1.33
BIN_NAME = speak
BIN2_NAME = espeak
LIB_NAME = libespeak.so
@@ -68,7 +68,7 @@ all: $(BIN_NAME) $(LIB_NAME) $(STATIC_LIB_NAME) $(BIN2_NAME)
mv $(LIB_NAME) $(LIB_NAME).$(LIBTAG)
.cpp.o:
$(CXX) $(CXXFLAGS) -D PATH_ESPEAK_DATA=\"$(DATADIR)\" -Wall -pedantic -I. -c $<
$(CXX) $(CXXFLAGS) -D PATH_ESPEAK_DATA=\"$(DATADIR)\" -Wall -pedantic -I. -c -fno-exceptions $<
$(BIN_NAME): $(OBJS1)
$(CXX) -o $@ $(OBJS1) $(LIBS1)
@@ -80,7 +80,7 @@ $(BIN2_NAME): $(OBJS3) $(LIB_NAME)
x_%.o: %.cpp
$(CXX) $(CXXFLAGS) -Wall -fpic -pedantic \
-I. -D LIBRARY -c $< -o x_$*.o
-I. -D LIBRARY -c -fno-exceptions $< -o x_$*.o
$(LIB_NAME): $(OBJS2)
$(CXX) -shared $(SONAME_OPT)$(LIB_NAME).$(LIB_VERSION) -o $@ $(OBJS2) $(LIBS2)
+15 -5
View File
@@ -36,6 +36,11 @@
#include "voice.h"
#include "spect.h"
#ifdef PLATFORM_POSIX
#include <unistd.h>
#endif
#define tNUMBER 1
#define tSTRING 2
@@ -742,6 +747,7 @@ int Compile::LoadWavefile(FILE *f, const char *fname)
int resample_wav = 0;
char fname_temp[100];
int scale_factor=0;
int fd_temp;
char command[sizeof(path_source)+200];
fseek(f,24,SEEK_SET);
@@ -762,12 +768,16 @@ int Compile::LoadWavefile(FILE *f, const char *fname)
Error("Not mono: ",fname);
}
#else
sprintf(fname_temp,"%s.wav",tmpnam(NULL));
sprintf(command,"sox \"%s%s.wav\" -r %d -c 1 -w %s polyphase\n",path_source,fname,samplerate,fname_temp);
if(system(command) < 0)
strcpy(fname_temp,"/tmp/espeakXXXXXX");
if((fd_temp = mkstemp(fname_temp)) >= 0)
{
Error("Failed to resample: ",command);
return(0);
close(fd_temp);
sprintf(command,"sox \"%s%s.wav\" -r %d -c 1 -w %s polyphase\n",path_source,fname,samplerate,fname_temp);
if(system(command) < 0)
{
Error("Failed to resample: ",command);
return(0);
}
}
f = fopen(fname_temp,"rb");
+2 -2
View File
@@ -1516,8 +1516,8 @@ int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, cha
}
value = N_HASH_DICT;
fwrite(&value,4,1,f_out);
fwrite(&offset_rules,4,1,f_out);
Write4Bytes(f_out,value);
Write4Bytes(f_out,offset_rules);
compile_dictlist_start();
+25 -17
View File
@@ -87,20 +87,24 @@ 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);
}
// use the following macros for translation from little endian to host's endianness
#ifdef ARCH_BIG
#define FIX_ENDIAN_USHORT(val) ((unsigned short) ( \
(unsigned short) ((unsigned short) (val) >> 8) | \
(unsigned short) ((unsigned short) (val) << 8)))
#define FIX_ENDIAN_UINT(val) ((unsigned int) ( \
(((unsigned int) (val) & (unsigned int) 0x000000ffU) << 24) | \
(((unsigned int) (val) & (unsigned int) 0x0000ff00U) << 8) | \
(((unsigned int) (val) & (unsigned int) 0x00ff0000U) >> 8) | \
(((unsigned int) (val) & (unsigned int) 0xff000000U) >> 24)))
#else
# define FIX_ENDIAN_USHORT(val) (val)
# define FIX_ENDIAN_UINT(val) (val)
#endif
@@ -157,7 +161,7 @@ int Translator::LoadDictionary(const char *name, int no_error)
size = GetFileLength(fname);
f = fopen(fname,"rb");
if((f == NULL) || (size == 0))
if((f == NULL) || (size <= 0))
{
if(no_error == 0)
{
@@ -175,13 +179,15 @@ int Translator::LoadDictionary(const char *name, int no_error)
pw = (int *)data_dictlist;
length = pw[1];
length = FIX_ENDIAN_UINT(pw[1]);
if(size <= (N_HASH_DICT + sizeof(int)*2))
{
fprintf(stderr,"Empty _dict file: '%s\n",fname);
return(2);
}
if((pw[0] != N_HASH_DICT) || (length <= 0) || (length > 0x8000000))
if((FIX_ENDIAN_UINT(pw[0]) != N_HASH_DICT) ||
(length <= 0) || (length > 0x8000000))
{
fprintf(stderr,"Bad data: '%s'\n",fname);
return(2);
@@ -258,7 +264,9 @@ void Translator::InitGroups(void)
pw = (unsigned int *)langopts.replace_chars;
while(*pw != 0)
{
*pw = reverse_word_bytes(*pw);
*pw = FIX_ENDIAN_UINT(*pw);
pw++;
*pw = FIX_ENDIAN_UINT(*pw);
pw++;
}
#endif
+2 -2
View File
@@ -126,7 +126,7 @@ static const short non_ascii_tab[] = {
// characters U+00e0 to U+017f
const short letter_accents_0e0[] = {
const unsigned short letter_accents_0e0[] = {
LETTER('a',M_GRAVE,0), // U+00e0
LETTER('a',M_ACUTE,0),
LETTER('a',M_CIRCUMFLEX,0),
@@ -291,7 +291,7 @@ LETTER('s',M_NAME,0), // long-s // U+17f
// characters U+0250 to U+029F
const short letter_accents_250[] = {
const unsigned short letter_accents_250[] = {
LETTER('a',M_TURNED,0), // U+250
LETTER(L_ALPHA,0,0),
LETTER(L_ALPHA,M_TURNED,0),
+14 -4
View File
@@ -34,6 +34,10 @@
#include "voice.h"
#include "translate.h"
#ifdef PLATFORM_POSIX
#include <unistd.h>
#endif
#include <locale.h>
#define N_XML_BUF 256
@@ -642,6 +646,7 @@ static int LoadSoundFile(const char *fname, int index)
if((f = fopen(fname,"rb")) != NULL)
{
int ix;
int fd_temp;
const char *resample;
int header[3];
@@ -660,11 +665,16 @@ static int LoadSoundFile(const char *fname, int index)
else
resample = "polyphase";
sprintf(fname_temp,"%s.wav",tmpnam(NULL));
sprintf(command,"sox \"%s\" -r %d -w -s -c1 %s %s\n", fname, samplerate, fname_temp, resample);
if(system(command) == 0)
strcpy(fname_temp,"/tmp/espeakXXXXXX");
if((fd_temp = mkstemp(fname_temp)) >= 0)
{
fname = fname_temp;
close(fd_temp);
// sprintf(fname_temp,"%s.wav",tmpnam(NULL));
sprintf(command,"sox \"%s\" -r %d -w -s -c1 %s %s\n", fname, samplerate, fname_temp, resample);
if(system(command) == 0)
{
fname = fname_temp;
}
}
}
}
+1 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.32 04.Mar.08";
const char *version_string = "1.33 06.Mar.08";
const int version_phdata = 0x013200;
int option_device_number = -1;
+1 -1
View File
@@ -82,7 +82,7 @@ const char *WordToString(unsigned int word)
int ix;
static char buf[5];
for(ix=0; ix<3; ix++)
for(ix=0; ix<4; ix++)
buf[ix] = word >> (ix*8);
buf[4] = 0;
return(buf);
+1 -1
View File
@@ -656,7 +656,7 @@ SetLengthMods(tr,3); // all equal
case L('t','a'): // Tamil
{
static const short stress_lengths_ta[8] = {190, 190, 200, 200, 0, 0, 220, 220};
static const short stress_lengths_ta[8] = {200, 200, 210, 210, 0, 0, 230, 230};
static const unsigned char stress_amps_ta[8] = {18,18, 18,18, 20,20, 22,22 };
tr = new Translator();
+22 -9
View File
@@ -893,26 +893,39 @@ if((wmark > 0) && (wmark < 8))
}
wordx[-1] = c_temp;
pfix = 1;
prefix_chars[0] = 0;
n_chars = prefix_type & 0x3f;
for(ix=0; ix < n_chars; ix++) // num. of bytes to remove
if((prefix_type & SUFX_B) == 0)
{
prefix_chars[pfix++] = *wordx++;
if((prefix_type & SUFX_B) && (ix == (n_chars-1)))
for(ix=(prefix_type & 0xf); ix>0; ix--) // num. of characters to remove
{
prefix_chars[pfix-1] = 0; // discard the last character of the prefix, this is the separator character
wordx++;
while((*wordx & 0xc0) == 0x80) wordx++; // for multibyte characters
}
}
prefix_chars[pfix] = 0;
else
{
pfix = 1;
prefix_chars[0] = 0;
n_chars = prefix_type & 0x3f;
for(ix=0; ix < n_chars; ix++) // num. of bytes to remove
{
prefix_chars[pfix++] = *wordx++;
if((prefix_type & SUFX_B) && (ix == (n_chars-1)))
{
prefix_chars[pfix-1] = 0; // discard the last character of the prefix, this is the separator character
}
}
prefix_chars[pfix] = 0;
}
c_temp = wordx[-1];
wordx[-1] = ' ';
confirm_prefix = 1;
if(prefix_type & SUFX_B)
{
// SUFX_B is used for Turkish, tr_rules contains "(Pb£
// retranslate the prefix part
char *wordpf;
char prefix_phonemes2[12];
+20
View File
@@ -31,6 +31,11 @@
#include "translate.h"
#include "prosodydisplay.h"
#ifdef PLATFORM_POSIX
#include <unistd.h>
#endif
#include "wx/font.h"
#include "wx/textctrl.h"
#include "wx/button.h"
@@ -372,6 +377,7 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
int clause_tone;
int clause_count;
FILE *f;
int fd_temp;
char fname_temp[100];
static int n_ph_list;
static PHONEME_LIST ph_list[N_PH_LIST+1];
@@ -383,11 +389,25 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
case T_RULES:
case MENU_SPEAK_RULES:
option_phonemes = 2;
#ifdef PLATFORM_POSIX
strcpy(fname_temp,"/tmp/espeakXXXXXX");
if((fd_temp = mkstemp(fname_temp)) >= 0)
{
close(fd_temp);
if((f = fopen(fname_temp,"w+")) != NULL)
{
f_trans = f; // write translation rule trace to a temp file
}
}
#else
strcpy(fname_temp,tmpnam(NULL));
if((f = fopen(fname_temp,"w+")) != NULL)
{
f_trans = f; // write translation rule trace to a temp file
}
#endif
case T_TRANSLATE:
case MENU_SPEAK_TRANSLATE:
option_multibyte = espeakCHARS_AUTO;
+9
View File
@@ -1052,6 +1052,14 @@ static int ScoreVoice(espeak_VOICE *voice_spec, const char *spec_language, int s
p = voice->languages; // list of languages+dialects for which this voice is suitable
if(strcmp(spec_language,"mbrola")==0)
{
// only list mbrola voices
if(memcmp(voice->identifier,"mb/",3) == 0)
return(100);
return(0);
}
if(spec_n_parts == 0)
{
score = 100;
@@ -1198,6 +1206,7 @@ static int SetVoiceScores(espeak_VOICE *voice_select, espeak_VOICE **voices, int
for(ix=0; ix<n_voices_list; ix++)
{
vp = voices_list[ix];
if(((control & 1) == 0) && (memcmp(vp->identifier,"mb/",3) == 0))
continue;
+4 -2
View File
@@ -816,8 +816,8 @@ static void WavegenSetEcho(void)
if(embedded_value[EMBED_T] > 0)
{
// announcing punctuation
amp = embedded_value[EMBED_T] * 10;
delay = 130;
amp = embedded_value[EMBED_T] * 8;
delay = 60;
}
if(delay == 0)
@@ -825,6 +825,8 @@ static void WavegenSetEcho(void)
echo_head = (delay * samplerate)/1000;
echo_length = echo_head; // ensure completion of echo at the end of speech. Use 1 delay period?
if(amp == 0)
echo_length = 0;
if(amp > 20)
echo_length = echo_head * 2; // perhaps allow 2 echo periods if the echo is loud.