Browse Source

[1.30.01] espeakChar() & say-as tts:char, speak the unicode number for unknown characters.

lang=ta: change stress rule to first syllable.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@131 d46cf337-b52f-0410-862d-fd96e6ae7743
master
jonsd 17 years ago
parent
commit
0d2fa52994
6 changed files with 98 additions and 98 deletions
  1. 16
    41
      src/Makefile_pulseaudio
  2. 1
    1
      src/dictionary.cpp
  3. 75
    49
      src/numbers.cpp
  4. 1
    1
      src/synthdata.cpp
  5. 4
    6
      src/tr_languages.cpp
  6. 1
    0
      src/translate.h

+ 16
- 41
src/Makefile_pulseaudio View File

LIBDIR=/usr/lib LIBDIR=/usr/lib
DATADIR=/usr/share/espeak-data DATADIR=/usr/share/espeak-data


RELEASE = 1.30
RELEASE = 1.31
BIN2_NAME = espeak BIN2_NAME = espeak
LIB_NAME = libespeak.so LIB_NAME = libespeak.so
STATIC_LIB_NAME = libespeak.a STATIC_LIB_NAME = libespeak.a
LN_SF = /bin/ln -sf LN_SF = /bin/ln -sf
MKDIR = mkdir -p MKDIR = mkdir -p


#AUDIO = portaudio
AUDIO = pulseaudio
#BIN_NAME = speak


BIN_NAME = speak

ifeq ($(AUDIO),pulseaudio)
WAVE=wave_pulse.cpp
LIB_AUDIO=pulse
USE_AUDIO=USE_PULSEAUDIO
# the speak executable is not yet compliant with PulseAudio,
# speak_SOURCES defined for avoiding compilation errors.
speak_SOURCES = speak.cpp compiledict.cpp dictionary.cpp intonation.cpp \
readclause.cpp setlengths.cpp numbers.cpp synth_mbrola.cpp \
synthdata.cpp synthesize.cpp translate.cpp tr_english.cpp \
tr_languages.cpp voices.cpp wavegen.cpp phonemelist.cpp \
espeak_command.cpp event.cpp fifo.cpp $(WAVE) debug.cpp
else
#portaudio
WAVE=wave.cpp
LIB_AUDIO=portaudio
USE_AUDIO=USE_PORTAUDIO
speak_SOURCES = speak.cpp compiledict.cpp dictionary.cpp intonation.cpp \
readclause.cpp setlengths.cpp numbers.cpp synth_mbrola.cpp \
synthdata.cpp synthesize.cpp translate.cpp tr_english.cpp \
tr_languages.cpp voices.cpp wavegen.cpp phonemelist.cpp

endif

speak_SOURCES = speak.cpp compiledict.cpp dictionary.cpp intonation.cpp \
readclause.cpp setlengths.cpp numbers.cpp synth_mbrola.cpp \
synthdata.cpp synthesize.cpp translate.cpp tr_english.cpp \
tr_languages.cpp voices.cpp wavegen.cpp phonemelist.cpp
# speak_SOURCES = speak.cpp compiledict.cpp dictionary.cpp intonation.cpp \
# readclause.cpp setlengths.cpp numbers.cpp synth_mbrola.cpp \
# synthdata.cpp synthesize.cpp translate.cpp tr_english.cpp \
# tr_languages.cpp voices.cpp wavegen.cpp phonemelist.cpp


libespeak_SOURCES = speak_lib.cpp compiledict.cpp dictionary.cpp intonation.cpp \ libespeak_SOURCES = speak_lib.cpp compiledict.cpp dictionary.cpp intonation.cpp \
readclause.cpp setlengths.cpp numbers.cpp synth_mbrola.cpp \ readclause.cpp setlengths.cpp numbers.cpp synth_mbrola.cpp \
synthdata.cpp synthesize.cpp translate.cpp tr_english.cpp \ synthdata.cpp synthesize.cpp translate.cpp tr_english.cpp \
tr_languages.cpp voices.cpp wavegen.cpp phonemelist.cpp \ tr_languages.cpp voices.cpp wavegen.cpp phonemelist.cpp \
espeak_command.cpp event.cpp fifo.cpp $(WAVE) debug.cpp
espeak_command.cpp event.cpp fifo.cpp wave_pulse.cpp debug.cpp




SRCS1=$(speak_SOURCES) SRCS1=$(speak_SOURCES)
OBJS1=$(patsubst %.cpp,%.o,$(SRCS1)) OBJS1=$(patsubst %.cpp,%.o,$(SRCS1))
LIBS1=-lstdc++ -l$(LIB_AUDIO) -lpthread
LIBS1=-lstdc++ -lpulse -lpthread


SRCS2=$(libespeak_SOURCES) SRCS2=$(libespeak_SOURCES)
OBJS2=$(patsubst %.cpp,x_%.o,$(SRCS2)) OBJS2=$(patsubst %.cpp,x_%.o,$(SRCS2))
LIBS2=-lstdc++ -l$(LIB_AUDIO) -lpthread
LIBS2=-lstdc++ -lpulse -lpthread


SRCS3 = espeak.cpp SRCS3 = espeak.cpp
OBJS3=$(patsubst %.cpp,%.o,$(SRCS3)) OBJS3=$(patsubst %.cpp,%.o,$(SRCS3))
LIBS3=-lstdc++ ./libespeak.so LIBS3=-lstdc++ ./libespeak.so


#CXXFLAGS=-O2 -D$(USE_AUDIO)
CXXFLAGS=-D$(USE_AUDIO) -ggdb -DDEBUG_ENABLED
CXXFLAGS=-O2 -DUSE_PULSEAUDIO
#CXXFLAGS=-DUSE_PULSEAUDIO -ggdb -DDEBUG_ENABLED




all: $(BIN_NAME) $(LIB_NAME) $(STATIC_LIB_NAME) $(BIN2_NAME)
#all: $(BIN_NAME) $(LIB_NAME) $(STATIC_LIB_NAME) $(BIN2_NAME)
all: $(LIB_NAME) $(STATIC_LIB_NAME) $(BIN2_NAME)
mv $(LIB_NAME) $(LIB_NAME).$(LIBTAG) mv $(LIB_NAME) $(LIB_NAME).$(LIBTAG)


.cpp.o: .cpp.o:
$(CXX) $(CXXFLAGS) -D PATH_ESPEAK_DATA=\"$(DATADIR)\" -Wall -pedantic -I. -c -fno-exceptions $< $(CXX) $(CXXFLAGS) -D PATH_ESPEAK_DATA=\"$(DATADIR)\" -Wall -pedantic -I. -c -fno-exceptions $<


$(BIN_NAME): $(OBJS1)
$(CXX) -o $@ $(OBJS1) $(LIBS1)
# $(BIN_NAME): $(OBJS1)
# $(CXX) -o $@ $(OBJS1) $(LIBS1)


$(BIN2_NAME): $(OBJS3) $(LIB_NAME) $(BIN2_NAME): $(OBJS3) $(LIB_NAME)
$(CXX) -o $@ $(OBJS3) $(LIBS3) $(CXX) -o $@ $(OBJS3) $(LIBS3)
rm -f *.o *.a *~ rm -f *.o *.a *~


distclean: clean distclean: clean
rm -f $(BIN_NAME)
# rm -f $(BIN_NAME)
rm -f $(BIN2_NAME) rm -f $(BIN2_NAME)
rm -f $(LIB_NAME)* rm -f $(LIB_NAME)*



+ 1
- 1
src/dictionary.cpp View File

continue; // start again at the beginning of the word continue; // start again at the beginning of the word
} }
else else
if((letter >= 0x3200) && (letter < 0xa700))
if((letter >= 0x3200) && (letter < 0xa700) && (end_phonemes != NULL))
{ {
// ideograms // ideograms
// outside the range of the accent table, speak the unknown symbol sound // outside the range of the accent table, speak the unknown symbol sound

+ 75
- 49
src/numbers.cpp View File







void Translator::LookupLetter(int letter, int next_byte, char *ph_buf1)
{//==================================================================
int len;
unsigned char *p;
static char single_letter[10] = {0,0};
char ph_stress[2];
char ph_buf3[30];

len = utf8_out(letter,&single_letter[2]);
single_letter[len+2] = ' ';

if(next_byte != ' ')
next_byte = RULE_SPELLING;
single_letter[3+len] = next_byte; // follow by space-space if the end of the word, or space-0x31

single_letter[1] = '_';
if(Lookup(&single_letter[1],ph_buf3) == 0)
{
single_letter[1] = ' ';
if(Lookup(&single_letter[2],ph_buf3) == 0)
{
TranslateRules(&single_letter[2], ph_buf3, sizeof(ph_buf3), NULL,0,0);
}
}

if(ph_buf3[0] == 0)
{
ph_buf1[0] = 0;
return;
}

// at a stress marker at the start of the letter name, unless one is already marked
ph_stress[0] = phonSTRESS_P;
ph_stress[1] = 0;

for(p=(unsigned char *)ph_buf3; *p != 0; p++)
{
if(phoneme_tab[*p]->type == phSTRESS)
ph_stress[0] = 0; // stress is already marked
}
sprintf(ph_buf1,"%s%s",ph_stress,ph_buf3);
}



int Translator::TranslateLetter(char *word, char *phonemes, int control) int Translator::TranslateLetter(char *word, char *phonemes, int control)
{//===================================================================== {//=====================================================================
// get pronunciation for an isolated letter // get pronunciation for an isolated letter
int n_bytes; int n_bytes;
int letter; int letter;
int len; int len;
int next;
unsigned char *p;
char ph_stress[2];
char *p2;
char *pbuf;
char capital[20]; char capital[20];
char ph_buf[30];
char ph_buf[50];
char ph_buf2[50]; char ph_buf2[50];
char hexbuf[6];
static char single_letter[10] = {0,0}; static char single_letter[10] = {0,0};


ph_buf[0] = 0; ph_buf[0] = 0;
return(n_bytes); return(n_bytes);
} }


len = utf8_out(letter,&single_letter[2]);
single_letter[len+2] = ' ';

next = RULE_SPELLING;
if(word[n_bytes] == ' ')
next = ' ';
single_letter[3+len] = next; // follow by space-space if the end of the word, or space-0x31

single_letter[1] = '_';
if(Lookup(&single_letter[1],ph_buf) == 0)
{
single_letter[1] = ' ';
if(Lookup(&single_letter[2],ph_buf) == 0)
{
TranslateRules(&single_letter[2], ph_buf, sizeof(ph_buf), NULL,0,0);
}
}
LookupLetter(letter, word[n_bytes], ph_buf);


if(ph_buf[0] == phonSWITCH) if(ph_buf[0] == phonSWITCH)
{ {


if((ph_buf[0]==0) && !iswspace(letter)) if((ph_buf[0]==0) && !iswspace(letter))
Lookup("_??",ph_buf); Lookup("_??",ph_buf);
}

// at a stress marker at the start of the letter name, unless one is already marked
ph_stress[0] = phonSTRESS_P;
ph_stress[1] = 0;


for(p=(unsigned char *)ph_buf; *p != 0; p++)
{
if(phoneme_tab[*p]->type == phSTRESS)
ph_stress[0] = 0; // stress is already marked
if((control==4) && (ph_buf[0] != 0))
{
// speak the hexadecimal number of the character code
sprintf(hexbuf,"%x",letter);
pbuf = ph_buf;
for(p2 = hexbuf; *p2 != 0; p2++)
{
pbuf += strlen(pbuf);
LookupLetter(*p2, 0, pbuf);
}
}
} }


len = strlen(phonemes); len = strlen(phonemes);
sprintf(ph_buf2,"%c%s%s%s",0xff,capital,ph_stress,ph_buf); // the 0xff marker will be removed or replaced in SetSpellingStress()
sprintf(ph_buf2,"%c%s%s",0xff,capital,ph_buf); // the 0xff marker will be removed or replaced in SetSpellingStress()
if((len + strlen(ph_buf2)) < N_WORD_PHONEMES) if((len + strlen(ph_buf2)) < N_WORD_PHONEMES)
{ {
strcpy(&phonemes[len],ph_buf2); strcpy(&phonemes[len],ph_buf2);
} }
else else
{ {
if((count != n_stress) && (control < 4))
if(count != n_stress)
{ {
if(((count % 3) != 0) || (count == n_stress-1)) if(((count % 3) != 0) || (count == n_stress-1))
c = phonSTRESS_3; // reduce to secondary stress c = phonSTRESS_3; // reduce to secondary stress
switch(langopts.numbers & 0x6000) switch(langopts.numbers & 0x6000)
{ {
case 0x4000: case 0x4000:
if(decimal_count < 4)
// French/Polish decimal fraction
while(word[n_digits] == '0')
{ {
// Polish decimal fraction
if ((word[n_digits] != '0'))
{
LookupNum3(atoi(&word[n_digits]),buf1,0,0,0);
strcat(ph_out,buf1);
n_digits += decimal_count;
}
else
if ((word[n_digits+1] != '0'))
{
Lookup("_0",buf1);
strcat(ph_out,buf1);
LookupNum3(atoi(&word[n_digits]),buf1,0,0,0);
strcat(ph_out,buf1);
n_digits += decimal_count;
}
Lookup("_0",buf1);
strcat(ph_out,buf1);
decimal_count--;
n_digits++;
}
if(decimal_count < 6)
{
LookupNum3(atoi(&word[n_digits]),buf1,0,0,0);
strcat(ph_out,buf1);
n_digits += decimal_count;
} }
break; break;



+ 1
- 1
src/synthdata.cpp View File

#include "translate.h" #include "translate.h"
#include "wave.h" #include "wave.h"


const char *version_string = "1.31 19.Jan.08";
const char *version_string = "1.31.01 23.Jan.08";
const int version_phdata = 0x013100; const int version_phdata = 0x013100;


int option_device_number = -1; int option_device_number = -1;

+ 4
- 6
src/tr_languages.cpp View File

tr->langopts.stress_flags = 0x0024; // don't use secondary stress tr->langopts.stress_flags = 0x0024; // don't use secondary stress
tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove lengthen indicator from unstressed syllables tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove lengthen indicator from unstressed syllables


tr->langopts.numbers = 0x1509 + NUM_NOPAUSE | NUM_ROMAN;
tr->langopts.numbers = 0x1509 + 0x4000 + NUM_NOPAUSE | NUM_ROMAN;
SetLetterVowel(tr,'y'); SetLetterVowel(tr,'y');
} }
break; break;


case L('t','a'): case L('t','a'):
{ {
static const short stress_lengths_ta[8] = {190, 190, 210, 210, 0, 0, 220, 220};
static const unsigned char stress_amps_ta[8] = {17,14, 20,19, 20,24, 24,22 };
static const short stress_lengths_ta[8] = {190, 190, 200, 200, 0, 0, 220, 220};
static const unsigned char stress_amps_ta[8] = {18,18, 18,18, 20,20, 22,22 };


tr = new Translator(); tr = new Translator();
SetupTranslator(tr,stress_lengths_ta,stress_amps_ta); SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable


tr->langopts.stress_rule = 6; // stress on last heaviest syllable, excluding final syllable
tr->langopts.stress_rule = 1;
tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
// tr->langopts.numbers = 0x811;
// tr->langopts.numbers2 = 0x100;
tr->letter_bits_offset = OFFSET_TAMIL; tr->letter_bits_offset = OFFSET_TAMIL;


memset(tr->letter_bits,0,sizeof(tr->letter_bits)); memset(tr->letter_bits,0,sizeof(tr->letter_bits));

+ 1
- 0
src/translate.h View File

const char *LookupDict2(const char *word, const char *word2, char *phonetic, unsigned int *flags, int end_flags, WORD_TAB *wtab); const char *LookupDict2(const char *word, const char *word2, char *phonetic, unsigned int *flags, int end_flags, WORD_TAB *wtab);
const char *LookupSpecial(const char *string); const char *LookupSpecial(const char *string);
const char *LookupCharName(int c); const char *LookupCharName(int c);
void LookupLetter(int letter, int next_byte, char *ph_buf);
int LookupNum2(int value, int control, char *ph_out); int LookupNum2(int value, int control, char *ph_out);
int LookupNum3(int value, char *ph_out, int suppress_null, int thousandplex, int prev_thousands); int LookupNum3(int value, char *ph_out, int suppress_null, int thousandplex, int prev_thousands);
int LookupThousands(int value, int thousandplex, char *ph_out); int LookupThousands(int value, int thousandplex, char *ph_out);

Loading…
Cancel
Save