mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-12-03 14:59:52 +00:00
Merge branch 'master' into android
Conflicts: README dictsource/dict_log dictsource/dict_phonemes phsource/compile_report phsource/error_log phsource/vowel/vowelchart.png phsource/vowelcharts/af.png phsource/vowelcharts/am.png phsource/vowelcharts/bo.png phsource/vowelcharts/ca.png phsource/vowelcharts/cs.png phsource/vowelcharts/de.png phsource/vowelcharts/en-n.png phsource/vowelcharts/en-us.png phsource/vowelcharts/en-wm.png phsource/vowelcharts/en.png phsource/vowelcharts/es-la.png phsource/vowelcharts/es.png phsource/vowelcharts/et.png phsource/vowelcharts/fa.png phsource/vowelcharts/fr-ca.png phsource/vowelcharts/fr.png phsource/vowelcharts/hi.png phsource/vowelcharts/ht.png phsource/vowelcharts/hu.png phsource/vowelcharts/ka.png phsource/vowelcharts/kk.png phsource/vowelcharts/ml.png phsource/vowelcharts/mt.png phsource/vowelcharts/ne.png phsource/vowelcharts/nl.png phsource/vowelcharts/pt-pt.png phsource/vowelcharts/si.png phsource/vowelcharts/sk.png phsource/vowelcharts/sq.png phsource/vowelcharts/tn.png phsource/vowelcharts/tr.png platforms/big_endian/phondata-manifest
This commit is contained in:
-153
@@ -1,153 +0,0 @@
|
||||
# remove -fno-exceptions if it causes problems with stdio library on some platforms (ARM)
|
||||
|
||||
DATADIR=/usr/share/espeak-data
|
||||
|
||||
PREFIX=/usr
|
||||
BINDIR=$(PREFIX)/bin
|
||||
INCDIR=$(PREFIX)/include/espeak
|
||||
LIBDIR=$(PREFIX)/lib
|
||||
|
||||
RELEASE = 1.46
|
||||
BIN_NAME = speak
|
||||
BIN2_NAME = espeak
|
||||
LIB_NAME = libespeak.so
|
||||
STATIC_LIB_NAME = libespeak.a
|
||||
LIB_VERSION = 1
|
||||
LIBTAG = $(LIB_VERSION).$(RELEASE)
|
||||
|
||||
# Use SONAME_OPT=-Wl,h, on Solaris
|
||||
SONAME_OPT=-Wl,-soname,
|
||||
|
||||
# Use EXTRA_LIBS=-lm on Solaris
|
||||
EXTRA_LIBS =
|
||||
|
||||
INSTALL = install
|
||||
LN_SF = /bin/ln -sf
|
||||
MKDIR = mkdir -p
|
||||
|
||||
# 'runtime' uses pulseaudio if it is running, else uses portaudio
|
||||
#AUDIO = runtime
|
||||
AUDIO = portaudio
|
||||
#AUDIO = portaudio0
|
||||
#AUDIO = portaudio2
|
||||
#AUDIO = pulseaudio
|
||||
#AUDIO = sada
|
||||
|
||||
ifeq ($(AUDIO),runtime)
|
||||
WAVE=wave.cpp wave_pulse.cpp
|
||||
LIB_AUDIO=-lpulse -lpulse-simple -lportaudio
|
||||
USE_AUDIO=-DUSE_PULSEAUDIO -DUSE_PORTAUDIO
|
||||
else
|
||||
ifeq ($(AUDIO),pulseaudio)
|
||||
WAVE=wave_pulse.cpp
|
||||
LIB_AUDIO=-lpulse
|
||||
USE_AUDIO=-DUSE_PULSEAUDIO
|
||||
else
|
||||
ifeq ($(AUDIO),portaudio)
|
||||
WAVE=wave.cpp
|
||||
LIB_AUDIO=-lportaudio
|
||||
USE_AUDIO=-DUSE_PORTAUDIO
|
||||
else
|
||||
ifeq ($(AUDIO),portaudio0)
|
||||
WAVE=wave.cpp
|
||||
LIB_AUDIO=/usr/lib/libportaudio.so.0
|
||||
USE_AUDIO=-DUSE_PORTAUDIO
|
||||
else
|
||||
ifeq ($(AUDIO),portaudio2)
|
||||
WAVE=wave.cpp
|
||||
LIB_AUDIO=/usr/lib/libportaudio.so.2
|
||||
USE_AUDIO=-DUSE_PORTAUDIO
|
||||
else
|
||||
ifeq ($(AUDIO),sada)
|
||||
WAVE=wave_sada.cpp
|
||||
USE_AUDIO=-DUSE_SADA
|
||||
else
|
||||
WAVE=wave.cpp
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
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 mbrowrap.cpp \
|
||||
tr_languages.cpp voices.cpp wavegen.cpp phonemelist.cpp klatt.cpp sonic.cpp
|
||||
|
||||
libespeak_SOURCES = speak_lib.cpp compiledict.cpp dictionary.cpp intonation.cpp \
|
||||
readclause.cpp setlengths.cpp numbers.cpp synth_mbrola.cpp \
|
||||
synthdata.cpp synthesize.cpp translate.cpp mbrowrap.cpp \
|
||||
tr_languages.cpp voices.cpp wavegen.cpp phonemelist.cpp \
|
||||
espeak_command.cpp event.cpp fifo.cpp $(WAVE) debug.cpp klatt.cpp sonic.cpp
|
||||
|
||||
SRCS1=$(speak_SOURCES)
|
||||
OBJS1=$(patsubst %.cpp,%.o,$(SRCS1))
|
||||
LIBS1=-lstdc++ $(LIB_AUDIO) -lpthread $(EXTRA_LIBS)
|
||||
|
||||
SRCS2=$(libespeak_SOURCES)
|
||||
OBJS2=$(patsubst %.cpp,x_%.o,$(SRCS2))
|
||||
LIBS2=-lstdc++ $(LIB_AUDIO) -lpthread
|
||||
|
||||
SRCS3 = espeak.cpp
|
||||
OBJS3=$(patsubst %.cpp,%.o,$(SRCS3))
|
||||
LIBS3=-lstdc++ -L . -lespeak
|
||||
|
||||
CXXFLAGS=-O2
|
||||
|
||||
|
||||
all: $(BIN_NAME) $(LIB_NAME) $(STATIC_LIB_NAME) $(BIN2_NAME)
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) $(CXXFLAGS) $(USE_AUDIO) -D PATH_ESPEAK_DATA=\"$(DATADIR)\" -Wall -pedantic -I. -c -fno-exceptions $<
|
||||
|
||||
$(BIN_NAME): $(OBJS1)
|
||||
$(CXX) $(LDFLAGS) -o $@ $(OBJS1) $(LIBS1)
|
||||
|
||||
$(BIN2_NAME): $(OBJS3) $(LIB_NAME)
|
||||
$(CXX) $(LDFLAGS) -o $@ $(OBJS3) $(LIBS3)
|
||||
|
||||
|
||||
|
||||
x_%.o: %.cpp
|
||||
$(CXX) $(CXXFLAGS) $(USE_AUDIO) -D PATH_ESPEAK_DATA=\"$(DATADIR)\" -Wall -fpic -fvisibility=hidden -pedantic \
|
||||
-I. -D LIBRARY -c -fno-exceptions $< -o x_$*.o
|
||||
|
||||
$(LIB_NAME): $(OBJS2)
|
||||
$(CXX) $(LDFLAGS) -shared $(SONAME_OPT)$(LIB_NAME).$(LIB_VERSION) -o $@ \
|
||||
$(OBJS2) $(LIBS2)
|
||||
mv $(LIB_NAME) $(LIB_NAME).$(LIBTAG)
|
||||
$(LN_SF) $(LIB_NAME).$(LIBTAG) $(LIB_NAME).$(LIB_VERSION)
|
||||
$(LN_SF) $(LIB_NAME).$(LIB_VERSION) $(LIB_NAME)
|
||||
|
||||
$(STATIC_LIB_NAME): $(OBJS2)
|
||||
$(AR) cqs $(STATIC_LIB_NAME) $(OBJS2)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a *~
|
||||
|
||||
distclean: clean
|
||||
rm -f $(BIN_NAME)
|
||||
rm -f $(BIN2_NAME)
|
||||
rm -f $(LIB_NAME)*
|
||||
|
||||
install: all
|
||||
# Create directories
|
||||
rm -rf $(DESTDIR)$(DATADIR)
|
||||
$(MKDIR) $(DESTDIR)$(BINDIR)
|
||||
$(MKDIR) $(DESTDIR)$(LIBDIR)
|
||||
$(MKDIR) $(DESTDIR)$(INCDIR)
|
||||
$(MKDIR) $(DESTDIR)$(DATADIR)
|
||||
# Install espeak executable
|
||||
$(INSTALL) -m 755 $(BIN2_NAME) $(DESTDIR)$(BINDIR)
|
||||
# Install shared library
|
||||
$(INSTALL) -m 755 $(LIB_NAME).$(LIBTAG) $(DESTDIR)$(LIBDIR)
|
||||
# Install static library
|
||||
$(INSTALL) -m 755 $(STATIC_LIB_NAME) $(DESTDIR)$(LIBDIR)
|
||||
$(LN_SF) $(LIB_NAME).$(LIBTAG) $(DESTDIR)$(LIBDIR)/$(LIB_NAME).$(LIB_VERSION)
|
||||
$(LN_SF) $(LIB_NAME).$(LIB_VERSION) $(DESTDIR)$(LIBDIR)/$(LIB_NAME)
|
||||
# Install development headers
|
||||
$(INSTALL) -pm 644 speak_lib.h $(DESTDIR)$(INCDIR)
|
||||
# Install data files
|
||||
cp -prf ../espeak-data/* $(DESTDIR)$(DATADIR)
|
||||
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
# remove -fno-exceptions if it causes problems with stdio library on some platforms (ARM)
|
||||
|
||||
DATADIR=/usr/share/espeak-data
|
||||
|
||||
PREFIX=/usr
|
||||
BINDIR=$(PREFIX)/bin
|
||||
INCDIR=$(PREFIX)/include/espeak
|
||||
LIBDIR=$(PREFIX)/lib
|
||||
|
||||
RELEASE = 1.46
|
||||
SPEAK = speak
|
||||
ESPEAK = espeak
|
||||
ESPEAKEDIT = espeakedit
|
||||
LIBESPEAK = libespeak.so
|
||||
STATIC_LIBESPEAK = libespeak.a
|
||||
LIB_VERSION = 1
|
||||
LIBTAG = $(LIB_VERSION).$(RELEASE)
|
||||
|
||||
# Use SONAME_OPT=-Wl,h, on Solaris
|
||||
SONAME_OPT=-Wl,-soname,
|
||||
|
||||
# Use EXTRA_LIBS=-lm on Solaris
|
||||
EXTRA_LIBS =
|
||||
|
||||
INSTALL = install
|
||||
LN_SF = /bin/ln -sf
|
||||
MKDIR = mkdir -p
|
||||
|
||||
# AUDIO='runtime' uses pulseaudio if it is running, else uses portaudio
|
||||
|
||||
if AUDIO_RUNTIME
|
||||
WAVE=wave.cpp wave_pulse.cpp
|
||||
LIB_AUDIO=-lpulse -lpulse-simple -lportaudio
|
||||
USE_AUDIO=-DUSE_PULSEAUDIO -DUSE_PORTAUDIO
|
||||
else
|
||||
if AUDIO_PULSEAUDIO
|
||||
WAVE=wave_pulse.cpp
|
||||
LIB_AUDIO=-lpulse
|
||||
USE_AUDIO=-DUSE_PULSEAUDIO
|
||||
else
|
||||
if AUDIO_PORTAUDIO
|
||||
WAVE=wave.cpp
|
||||
LIB_AUDIO=-lportaudio
|
||||
USE_AUDIO=-DUSE_PORTAUDIO
|
||||
else
|
||||
if AUDIO_PORTAUDIO0
|
||||
WAVE=wave.cpp
|
||||
LIB_AUDIO=/usr/lib/libportaudio.so.0
|
||||
USE_AUDIO=-DUSE_PORTAUDIO
|
||||
else
|
||||
if AUDIO_PORTAUDIO2
|
||||
WAVE=wave.cpp
|
||||
LIB_AUDIO=/usr/lib/libportaudio.so.2
|
||||
USE_AUDIO=-DUSE_PORTAUDIO
|
||||
else
|
||||
if AUDIO_SADA
|
||||
WAVE=wave_sada.cpp
|
||||
USE_AUDIO=-DUSE_SADA
|
||||
else
|
||||
WAVE=wave.cpp
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
CXXFLAGS = -O2 -Wall -c
|
||||
CPPFLAGS = -pedantic -fno-exceptions -D PATH_ESPEAK_DATA=\"$(DATADIR)\"
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) $(CXXFLAGS) $(USE_AUDIO) -I. $(CPPFLAGS) $<
|
||||
|
||||
e_%.o: %.cpp
|
||||
$(CXX) $(CXXFLAGS) $(espeakedit_CXXFLAGS) $(USE_AUDIO) $(CPPFLAGS) -I. $< -o e_$*.o
|
||||
|
||||
x_%.o: %.cpp
|
||||
$(CXX) $(CXXFLAGS) $(USE_AUDIO) -fpic -fvisibility=hidden \
|
||||
-I. -D LIBRARY $(CPPFLAGS) $< -o x_$*.o
|
||||
|
||||
all: $(SPEAK) $(LIBESPEAK) $(STATIC_LIBESPEAK) $(ESPEAK) $(ESPEAKEDIT)
|
||||
|
||||
common_SOURCE = compiledict.cpp dictionary.cpp intonation.cpp \
|
||||
klatt.cpp mbrowrap.cpp numbers.cpp readclause.cpp \
|
||||
phonemelist.cpp setlengths.cpp sonic.cpp \
|
||||
synthdata.cpp synthesize.cpp synth_mbrola.cpp \
|
||||
translate.cpp tr_languages.cpp voices.cpp wavegen.cpp
|
||||
|
||||
speak_SOURCE = speak.cpp $(common_SOURCE)
|
||||
speak_OBJS = ${speak_SOURCE:%.cpp=%.o}
|
||||
speak_LIBS = -lstdc++ $(LIB_AUDIO) -lpthread $(EXTRA_LIBS)
|
||||
$(SPEAK): $(speak_OBJS)
|
||||
$(CXX) $(LDFLAGS) -o $@ $(speak_OBJS) $(speak_LIBS)
|
||||
|
||||
espeak_SOURCE = espeak.cpp
|
||||
espeak_OBJS = ${espeak_SOURCE:%.cpp=%.o}
|
||||
espeak_LIBS = -lstdc++ -L . -lespeak
|
||||
$(ESPEAK): $(espeak_OBJS) $(LIB_NAME)
|
||||
$(CXX) $(LDFLAGS) -o $@ $(espeak_OBJS) $(espeak_LIBS)
|
||||
|
||||
libespeak_SOURCE = speak_lib.cpp $(common_SOURCE) \
|
||||
espeak_command.cpp event.cpp fifo.cpp $(WAVE) debug.cpp
|
||||
libespeak_OBJS = ${libespeak_SOURCE:%.cpp=x_%.o}
|
||||
libespeak_LIBS = -lstdc++ $(LIB_AUDIO) -lpthread
|
||||
$(LIBESPEAK): $(libespeak_OBJS)
|
||||
$(CXX) $(LDFLAGS) -shared $(SONAME_OPT)$(LIBESPEAK).$(LIB_VERSION) -o $@ \
|
||||
$(libespeak_OBJS) $(libespeak_LIBS)
|
||||
mv $(LIBESPEAK) $(LIBESPEAK).$(LIBTAG)
|
||||
$(LN_SF) $(LIBESPEAK).$(LIBTAG) $(LIBESPEAK).$(LIB_VERSION)
|
||||
$(LN_SF) $(LIBESPEAK).$(LIB_VERSION) $(LIBESPEAK)
|
||||
|
||||
$(STATIC_LIBESPEAK): $(libespeak_OBJS)
|
||||
$(AR) cqs $(STATIC_LIBESPEAK) $(libespeak_OBJS)
|
||||
|
||||
|
||||
espeakedit_SOURCE = $(common_SOURCE) compiledata.cpp debug.cpp espeakedit.cpp \
|
||||
event.cpp extras.cpp fifo.cpp formantdlg.cpp \
|
||||
menus.cpp options.cpp prosodydisplay.cpp \
|
||||
espeak_command.cpp speak_lib.cpp spect.cpp \
|
||||
spectdisplay.cpp spectseq.cpp \
|
||||
transldlg.cpp voicedlg.cpp vowelchart.cpp $(WAVE)
|
||||
espeakedit_OBJS=${espeakedit_SOURCE:%.cpp=e_%.o}
|
||||
espeakedit_LIBS=-lstdc++ $(LIB_AUDIO)
|
||||
espeakedit_CXXFLAGS = ${WX_CXXFLAGS} -D_LARGEFILE_SOURCE=1 -DNO_GCC_PRAGMA -D_ESPEAKEDIT
|
||||
$(ESPEAKEDIT): $(espeakedit_OBJS)
|
||||
$(CXX) $(LDFLAGS) -o $@ $(espeakedit_OBJS) $(espeakedit_LIBS) ${WX_LIBS}
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a *~
|
||||
|
||||
distclean: clean
|
||||
rm -f $(SPEAK)
|
||||
rm -f $(ESPEAK)
|
||||
rm -f $(LIBESPEAK)*
|
||||
rm -f $(STATIC_LIBESPEAK)
|
||||
rm -f $(ESPEAKEDIT)
|
||||
|
||||
install: all
|
||||
rm -rf $(DESTDIR)$(DATADIR)
|
||||
$(MKDIR) $(DESTDIR)$(BINDIR)
|
||||
$(MKDIR) $(DESTDIR)$(LIBDIR)
|
||||
$(MKDIR) $(DESTDIR)$(INCDIR)
|
||||
$(MKDIR) $(DESTDIR)$(DATADIR)
|
||||
$(INSTALL) -m 755 $(ESPEAK) $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL) -m 755 $(LIBESPEAK).$(LIBTAG) $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL) -m 755 $(STATIC_LIBESPEAK) $(DESTDIR)$(LIBDIR)
|
||||
$(LN_SF) $(LIBESPEAK).$(LIBTAG) $(DESTDIR)$(LIBDIR)/$(LIBESPEAK).$(LIB_VERSION)
|
||||
$(LN_SF) $(LIBESPEAK).$(LIB_VERSION) $(DESTDIR)$(LIBDIR)/$(LIBESPEAK)
|
||||
$(INSTALL) -pm 644 speak_lib.h $(DESTDIR)$(INCDIR)
|
||||
cp -prf ../espeak-data/* $(DESTDIR)$(DATADIR)
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
# Makefile for 'espeakedit' program
|
||||
|
||||
SRCS= compiledata.cpp compiledict.cpp debug.cpp dictionary.cpp espeak_command.cpp \
|
||||
espeakedit.cpp event.cpp extras.cpp fifo.cpp formantdlg.cpp intonation.cpp \
|
||||
klatt.cpp mbrowrap.cpp menus.cpp numbers.cpp options.cpp phonemelist.cpp \
|
||||
prosodydisplay.cpp readclause.cpp setlengths.cpp speak_lib.cpp spect.cpp \
|
||||
spectdisplay.cpp spectseq.cpp synthdata.cpp synthesize.cpp synth_mbrola.cpp \
|
||||
translate.cpp transldlg.cpp tr_languages.cpp voicedlg.cpp voices.cpp vowelchart.cpp \
|
||||
wave.cpp wavegen.cpp sonic.cpp
|
||||
|
||||
OBJS=$(patsubst %.cpp,%.o,$(SRCS))
|
||||
|
||||
WX_LIBS = -pthread -lwx_gtk2u_xrc-2.6 -lwx_gtk2u_qa-2.6 -lwx_gtk2u_html-2.6 \
|
||||
-lwx_gtk2u_adv-2.6 -lwx_gtk2u_core-2.6 -lwx_baseu_xml-2.6 -lwx_baseu_net-2.6 -lwx_baseu-2.6
|
||||
|
||||
LIBS=-lstdc++ -lportaudio
|
||||
|
||||
CPPFLAGS = -Wall -g -fexceptions -I/usr/lib/wx/include/gtk2-unicode-release-2.6
|
||||
-I/usr/include/wx-2.6 \
|
||||
-DGTK_NO_CHECK_CASTS -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES
|
||||
-D_LARGEFILE_SOURCE=1 -DNO_GCC_PRAGMA -D_ESPEAKEDIT
|
||||
|
||||
CXXFLAGS = -O2 -Wall -fexceptions -I/usr/lib/wx/include/gtk2-unicode-release-2.6 -I/usr/include/wx-2.6 \
|
||||
-DGTK_NO_CHECK_CASTS -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D_LARGEFILE_SOURCE=1 -DNO_GCC_PRAGMA -D_ESPEAKEDIT
|
||||
|
||||
all: espeakedit
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) $(CXXFLAGS) -I. -c -fno-exceptions $<
|
||||
|
||||
espeakedit: $(OBJS)
|
||||
$(CXX) -o $@ $(OBJS) $(LIBS) $(WX_LIBS)
|
||||
|
||||
clean:
|
||||
rm -f *.o *~
|
||||
|
||||
distclean: clean
|
||||
rm -f espeakedit
|
||||
|
||||
+93
-46
@@ -71,6 +71,7 @@ typedef struct {
|
||||
#define k_AND 1
|
||||
#define k_OR 2
|
||||
#define k_THEN 3
|
||||
#define k_NOT 4
|
||||
|
||||
#define kTHISSTRESS 0x800
|
||||
|
||||
@@ -90,17 +91,19 @@ static keywtab_t k_conditions[] = {
|
||||
{"AND", 0, k_AND},
|
||||
{"OR", 0, k_OR},
|
||||
{"THEN", 0, k_THEN},
|
||||
{"prevPh", tWHICH_PHONEME, 0x000},
|
||||
{"prevPhW", tWHICH_PHONEME, 0x500},
|
||||
{"thisPh", tWHICH_PHONEME, 0x100},
|
||||
{"nextPh", tWHICH_PHONEME, 0x200},
|
||||
{"next2Ph", tWHICH_PHONEME, 0x300},
|
||||
{"nextPhW", tWHICH_PHONEME, 0x400},
|
||||
{"nextVowel",tWHICH_PHONEME, 0x600},
|
||||
// {"next2PhW", tWHICH_PHONEME, 0x700},
|
||||
{"NOT", 0, k_NOT},
|
||||
{"prevPh", tWHICH_PHONEME, 0},
|
||||
{"prevPhW", tWHICH_PHONEME, 5},
|
||||
{"thisPh", tWHICH_PHONEME, 1},
|
||||
{"nextPh", tWHICH_PHONEME, 2},
|
||||
{"next2Ph", tWHICH_PHONEME, 3},
|
||||
{"nextPhW", tWHICH_PHONEME, 4},
|
||||
{"next2PhW", tWHICH_PHONEME, 6},
|
||||
{"nextVowel",tWHICH_PHONEME, 7},
|
||||
{"prevVowel",tWHICH_PHONEME, 8},
|
||||
// {"next2PhW", tWHICH_PHONEME, 0x800},
|
||||
|
||||
// {"numVowels", tTEST, 0x000},
|
||||
// {"afterStress", tTEST, 0x000},
|
||||
|
||||
{"PreVoicing", tTEST, 0xf01},
|
||||
{"KlattSynth", tTEST, 0xf02},
|
||||
@@ -605,7 +608,7 @@ return;
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
address = ((instn & 0xf) << 16) + *pc++;
|
||||
address = ((instn & 0xf) << 16) + *pc++;
|
||||
fprintf(f_out, " %d %.5x",(instn >> 4) & 0xff,address*4);
|
||||
break;
|
||||
}
|
||||
@@ -770,7 +773,7 @@ static void CompileReport(void)
|
||||
}
|
||||
n = ix;
|
||||
qsort((void *)list,n,sizeof(REF_HASH_TAB *),(int (*)(const void *,const void *))ref_sorter);
|
||||
|
||||
|
||||
data_path = "";
|
||||
prev_mnemonic = 0;
|
||||
prev_table = 0;
|
||||
@@ -1197,7 +1200,7 @@ static int LookupPhoneme(const char *string, int control)
|
||||
|
||||
// don't use phoneme number 0, reserved for string terminator
|
||||
start = 1;
|
||||
|
||||
|
||||
if(control==2)
|
||||
start = 8; // don't look for control and stress phonemes (allows these characters to be
|
||||
// used for other purposes)
|
||||
@@ -1267,12 +1270,12 @@ static int NextItem(int type)
|
||||
int sign;
|
||||
char *p;
|
||||
keywtab_t *pk;
|
||||
|
||||
|
||||
item_type = -1;
|
||||
|
||||
f_in_displ = ftell(f_in);
|
||||
f_in_linenum = linenum;
|
||||
|
||||
|
||||
while(!feof(f_in))
|
||||
{
|
||||
c = get_char();
|
||||
@@ -1592,7 +1595,7 @@ int LoadSpect(const char *path, int control)
|
||||
|
||||
wxString filename = path_phsource + path_sep + wxString(path,wxConvLocal);
|
||||
wxFileInputStream stream(filename);
|
||||
|
||||
|
||||
if(stream.Ok() == FALSE)
|
||||
{
|
||||
error("Failed to open: '%s'",path);
|
||||
@@ -1616,7 +1619,7 @@ int LoadSpect(const char *path, int control)
|
||||
seq_out.sqflags=0;
|
||||
seq_out.length_total=0;
|
||||
|
||||
total = 0;
|
||||
total = 0;
|
||||
for(frame=0; frame < spectseq->numframes; frame++)
|
||||
{
|
||||
|
||||
@@ -1650,7 +1653,7 @@ for(ix=0; ix<8; ix++)
|
||||
seq_out.n_frames++;
|
||||
if(frame > 0)
|
||||
total += spectseq->frames[frame-1]->length;
|
||||
}
|
||||
}
|
||||
}
|
||||
seq_out.length_total = int(total);
|
||||
|
||||
@@ -1665,7 +1668,7 @@ for(ix=0; ix<8; ix++)
|
||||
for(frame=0; frame < spectseq->numframes; frame++)
|
||||
{
|
||||
fr = spectseq->frames[frame];
|
||||
|
||||
|
||||
if(fr->keyframe)
|
||||
{
|
||||
if(klatt_flag)
|
||||
@@ -1756,7 +1759,7 @@ for(ix=0; ix<8; ix++)
|
||||
n_frames++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(klatt_flag)
|
||||
{
|
||||
seqk_out.n_frames = seq_out.n_frames;
|
||||
@@ -1799,7 +1802,7 @@ static int LoadWavefile(FILE *f, const char *fname)
|
||||
fseek(f,24,SEEK_SET);
|
||||
sr1 = Read4Bytes(f);
|
||||
sr2 = Read4Bytes(f);
|
||||
fseek(f,40,SEEK_SET);
|
||||
fseek(f,40,SEEK_SET);
|
||||
|
||||
if((sr1 != samplerate_native) || (sr2 != sr1*2))
|
||||
{
|
||||
@@ -1828,7 +1831,7 @@ static int LoadWavefile(FILE *f, const char *fname)
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
f = fopen(fname_temp,"rb");
|
||||
if(f == NULL)
|
||||
{
|
||||
@@ -2078,7 +2081,7 @@ static int LoadDataFile(const char *path, int control)
|
||||
if(addr == 0)
|
||||
{
|
||||
sprintf(buf,"%s%s",path_source,path);
|
||||
|
||||
|
||||
if((f = fopen(buf,"rb")) == NULL)
|
||||
{
|
||||
sprintf(buf,"%s%s.wav",path_source,path);
|
||||
@@ -2091,7 +2094,7 @@ static int LoadDataFile(const char *path, int control)
|
||||
|
||||
id = Read4Bytes(f);
|
||||
rewind(f);
|
||||
|
||||
|
||||
if(id == 0x43455053)
|
||||
{
|
||||
addr = LoadSpect(path, control);
|
||||
@@ -2121,7 +2124,7 @@ static int LoadDataFile(const char *path, int control)
|
||||
addr = -1;
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
|
||||
if(addr > 0)
|
||||
{
|
||||
fprintf(f_phcontents,"%c 0x%.5x %s\n",type_code,addr & 0x7fffff,path);
|
||||
@@ -2188,7 +2191,7 @@ static int CompileToneSpec(void)
|
||||
*prog_out++ = i_AMPENV + ((amp_env >> 16) & 0xf);
|
||||
*prog_out++ = amp_env;
|
||||
}
|
||||
|
||||
|
||||
return(0);
|
||||
} // end of CompileToneSpec
|
||||
|
||||
@@ -2217,7 +2220,7 @@ int CompileSound(int keyword, int isvowel)
|
||||
{
|
||||
value = -128;
|
||||
error("Parameter < -128",NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2256,9 +2259,11 @@ int CompileIf(int elif)
|
||||
int key;
|
||||
int finish = 0;
|
||||
int word = 0;
|
||||
int word2;
|
||||
int data;
|
||||
int bitmap;
|
||||
int brackets;
|
||||
int not_flag;
|
||||
USHORT *prog_last_if = NULL;
|
||||
|
||||
then_count = 2;
|
||||
@@ -2266,6 +2271,8 @@ int CompileIf(int elif)
|
||||
|
||||
while(!finish)
|
||||
{
|
||||
not_flag = 0;
|
||||
word2 = 0;
|
||||
if(prog_out >= prog_out_max)
|
||||
{
|
||||
error("Phoneme program too large", NULL);
|
||||
@@ -2274,10 +2281,25 @@ int CompileIf(int elif)
|
||||
|
||||
if((key = NextItem(tCONDITION)) < 0)
|
||||
error("Expected a condition, not '%s'",item_string);
|
||||
|
||||
|
||||
if((item_type == 0) && (key == k_NOT))
|
||||
{
|
||||
not_flag = 1;
|
||||
if((key = NextItem(tCONDITION)) < 0)
|
||||
error("Expected a condition, not '%s'",item_string);
|
||||
}
|
||||
|
||||
if(item_type == tWHICH_PHONEME)
|
||||
{
|
||||
// prevPh(), thisPh(), nextPh(), next2Ph()
|
||||
// prevPh(), thisPh(), nextPh(), next2Ph() etc
|
||||
if(key >= 6)
|
||||
{
|
||||
// put the 'which' code in the next instruction
|
||||
word2 = key;
|
||||
key = 6;
|
||||
}
|
||||
key = key << 8;
|
||||
|
||||
data = NextItemBrackets(tPROPERTIES,0);
|
||||
if(data >= 0)
|
||||
{
|
||||
@@ -2320,6 +2342,11 @@ int CompileIf(int elif)
|
||||
prog_last_if = prog_out;
|
||||
*prog_out++ = word | i_CONDITION;
|
||||
|
||||
if(word2 != 0)
|
||||
*prog_out++ = word2;
|
||||
if(not_flag)
|
||||
*prog_out++ = i_NOT;
|
||||
|
||||
// expect AND, OR, THEN
|
||||
switch(NextItem(tCONDITION))
|
||||
{
|
||||
@@ -2416,7 +2443,7 @@ int CompileElse(void)
|
||||
{
|
||||
ref = prog_out;
|
||||
*prog_out++ = 0;
|
||||
|
||||
|
||||
if((p = if_stack[if_level].p_else) != NULL)
|
||||
{
|
||||
*ref = ref - p; // backwards offset to the previous else
|
||||
@@ -2461,14 +2488,14 @@ int CompileEndif(void)
|
||||
do
|
||||
{
|
||||
chain = *p; // a chain of previous else links
|
||||
|
||||
|
||||
offset = prog_out - p;
|
||||
if(offset > MAX_JUMP)
|
||||
{
|
||||
error("IF block is too long",NULL);
|
||||
}
|
||||
*p = i_JUMP + offset;
|
||||
|
||||
|
||||
p -= chain;
|
||||
} while (chain > 0);
|
||||
}
|
||||
@@ -2489,7 +2516,7 @@ static int CompileSwitch(int type)
|
||||
// check the instructions in the Switch
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
// count_VowelStart = 0;
|
||||
// count_VowelEnding = 0;
|
||||
|
||||
@@ -2664,7 +2691,7 @@ int CompilePhoneme(int compile_phoneme)
|
||||
phoneme_flags = 0;
|
||||
place_articulation = 0;
|
||||
|
||||
NextItem(tSTRING);
|
||||
NextItem(tSTRING);
|
||||
if(compile_phoneme)
|
||||
{
|
||||
phcode = LookupPhoneme(item_string,1); // declare phoneme if not already there
|
||||
@@ -2825,7 +2852,7 @@ int CompilePhoneme(int compile_phoneme)
|
||||
phcode = LookupPhoneme(item_string,1);
|
||||
phoneme_out->start_type = phcode;
|
||||
break;
|
||||
|
||||
|
||||
case kENDTYPE:
|
||||
phcode = NextItem(tPHONEMEMNEM);
|
||||
if(phcode == -1)
|
||||
@@ -2882,7 +2909,7 @@ int CompilePhoneme(int compile_phoneme)
|
||||
case kSWITCH_PREVVOWEL:
|
||||
endphoneme = CompileSwitch(1);
|
||||
break;
|
||||
|
||||
|
||||
case kSWITCH_NEXTVOWEL:
|
||||
endphoneme = CompileSwitch(2);
|
||||
break;
|
||||
@@ -2908,7 +2935,7 @@ int CompilePhoneme(int compile_phoneme)
|
||||
DecThenCount();
|
||||
endphoneme = CompileSound(keyword,0);
|
||||
break;
|
||||
|
||||
|
||||
case kVOWELIN:
|
||||
DecThenCount();
|
||||
endphoneme = CompileVowelTransition(1);
|
||||
@@ -2968,7 +2995,7 @@ int CompilePhoneme(int compile_phoneme)
|
||||
}
|
||||
phoneme_out->phflags = place_articulation << 16;
|
||||
phoneme_out->phflags |= phoneme_flags;
|
||||
|
||||
|
||||
if(phoneme_out->phflags & phVOICED)
|
||||
{
|
||||
if(phoneme_out->type == phSTOP)
|
||||
@@ -2977,15 +3004,15 @@ int CompilePhoneme(int compile_phoneme)
|
||||
if(phoneme_out->type == phFRICATIVE)
|
||||
phoneme_out->type = phVFRICATIVE;
|
||||
}
|
||||
|
||||
|
||||
if(phoneme_out->std_length == 0)
|
||||
{
|
||||
if(phoneme_out->type == phVOWEL)
|
||||
phoneme_out->std_length = 180/2; // default length for vowel
|
||||
}
|
||||
|
||||
|
||||
phoneme_out->phflags |= phLOCAL; //declared in this phoneme table
|
||||
|
||||
|
||||
if(phoneme_out->type == phDELETED)
|
||||
{
|
||||
phoneme_out->mnemonic = 0x01; // will not be recognised
|
||||
@@ -3334,7 +3361,7 @@ static void CompilePhonemeFiles()
|
||||
stack[stack_ix].linenum = linenum;
|
||||
strcpy(stack[stack_ix].fname,current_fname);
|
||||
stack[stack_ix++].file = f_in;
|
||||
|
||||
|
||||
f_in = f;
|
||||
strncpy0(current_fname,item_string,sizeof(current_fname));
|
||||
linenum = 1;
|
||||
@@ -3382,7 +3409,7 @@ static void CompilePhonemeData2(const char *source)
|
||||
wxString report_dict;
|
||||
|
||||
#ifdef MAKE_ENVELOPES
|
||||
make_envs();
|
||||
make_envs();
|
||||
#endif
|
||||
|
||||
n_envelopes = 0;
|
||||
@@ -3391,6 +3418,24 @@ memset(markers_used,0,sizeof(markers_used));
|
||||
|
||||
f_errors = stderr;
|
||||
|
||||
if(!wxDirExists(path_phsource))
|
||||
{
|
||||
if(gui_flag)
|
||||
{
|
||||
wxString dirname = wxDirSelector(_T("Phoneme source directory"),path_phsource);
|
||||
if(!dirname.IsEmpty())
|
||||
{
|
||||
path_phsource = dirname;
|
||||
strncpy0(path_source,path_phsource.mb_str(wxConvLocal),sizeof(path_source)-1);
|
||||
strcat(path_source,"/");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"Can't find phoneme source directory: %s\n",path_source);
|
||||
}
|
||||
}
|
||||
|
||||
strncpy0(current_fname,source,sizeof(current_fname));
|
||||
|
||||
strncpy0(fname,path_phfile.mb_str(wxConvLocal),sizeof(fname));
|
||||
@@ -3493,8 +3538,10 @@ memset(markers_used,0,sizeof(markers_used));
|
||||
fprintf(f_errors,"\nRefs %d, Reused %d\n",count_references,duplicate_references);
|
||||
fclose(f_in);
|
||||
fclose(f_phdata);
|
||||
fclose(f_errors);
|
||||
fclose(f_prog_log);
|
||||
if(f_errors != stderr)
|
||||
fclose(f_errors);
|
||||
if(f_prog_log != NULL)
|
||||
fclose(f_prog_log);
|
||||
fclose(f_phindex);
|
||||
fclose(f_phtab);
|
||||
fclose(f_phcontents);
|
||||
@@ -3525,7 +3572,7 @@ fprintf(f_errors,"\nRefs %d, Reused %d\n",count_references,duplicate_references
|
||||
{
|
||||
strncpy0(fname,(report+report_dict).mb_str(wxConvLocal),sizeof(fname));
|
||||
fprintf(stderr,"%s\n",fname);
|
||||
|
||||
|
||||
}
|
||||
} // end of CompilePhonemeData
|
||||
|
||||
@@ -3605,7 +3652,7 @@ void CompileMbrola()
|
||||
wxLogError(_T("Can't write to: ")+wxString(buf,wxConvLocal));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
data[count].name = 0; // list terminator
|
||||
Write4Bytes(f_out, mbrola_ctrl);
|
||||
|
||||
|
||||
+46
-43
@@ -266,7 +266,7 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(rb == RULE_DOLLAR)
|
||||
{
|
||||
value = *rule++ & 0xff;
|
||||
@@ -380,13 +380,13 @@ static int compile_line(char *linebuf, char *dict_line, int *hash)
|
||||
int multiple_numeric_hyphen = 0;
|
||||
char *multiple_string = NULL;
|
||||
char *multiple_string_end = NULL;
|
||||
|
||||
|
||||
int len_word;
|
||||
int len_phonetic;
|
||||
int text_not_phonemes; // this word specifies replacement text, not phonemes
|
||||
unsigned int wc;
|
||||
int all_upper_case;
|
||||
|
||||
|
||||
char *mnemptr;
|
||||
unsigned char flag_codes[100];
|
||||
char encoded_ph[200];
|
||||
@@ -416,12 +416,12 @@ static char nullstring[] = {0};
|
||||
#endif
|
||||
|
||||
step = 0;
|
||||
|
||||
|
||||
c = 0;
|
||||
while(c != '\n')
|
||||
{
|
||||
c = *p;
|
||||
|
||||
|
||||
if((c == '?') && (step==0))
|
||||
{
|
||||
// conditional rule, allow only if the numbered condition is set for the voice
|
||||
@@ -449,14 +449,14 @@ static char nullstring[] = {0};
|
||||
flag_codes[n_flag_codes++] = ix + flag_offset;
|
||||
c = *p;
|
||||
}
|
||||
|
||||
|
||||
if((c == '$') && isalnum(p[1]))
|
||||
{
|
||||
/* read keyword parameter */
|
||||
mnemptr = p;
|
||||
while(!isspace2(c = *p)) p++;
|
||||
*p = 0;
|
||||
|
||||
|
||||
flagnum = LookupMnem(mnem_flags,mnemptr);
|
||||
if(flagnum > 0)
|
||||
{
|
||||
@@ -485,12 +485,12 @@ static char nullstring[] = {0};
|
||||
error_count++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((c == '/') && (p[1] == '/') && (multiple_words==0))
|
||||
{
|
||||
c = '\n'; /* "//" treat comment as end of line */
|
||||
}
|
||||
|
||||
|
||||
switch(step)
|
||||
{
|
||||
case 0:
|
||||
@@ -507,7 +507,7 @@ static char nullstring[] = {0};
|
||||
step = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 1:
|
||||
if((c == '-') && multiple_words)
|
||||
{
|
||||
@@ -567,7 +567,7 @@ static char nullstring[] = {0};
|
||||
step = 3;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 3:
|
||||
if(!isspace2(c))
|
||||
{
|
||||
@@ -575,7 +575,7 @@ static char nullstring[] = {0};
|
||||
step = 4;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 4:
|
||||
if(isspace2(c))
|
||||
{
|
||||
@@ -583,13 +583,13 @@ static char nullstring[] = {0};
|
||||
step = 5;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 5:
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
|
||||
if(word[0] == 0)
|
||||
{
|
||||
return(0); /* blank line */
|
||||
@@ -698,7 +698,7 @@ static char nullstring[] = {0};
|
||||
|
||||
*hash = HashDictionary(word);
|
||||
len_phonetic = strlen(encoded_ph);
|
||||
|
||||
|
||||
dict_line[1] = len_word; // bit 6 indicates whether the word has been compressed
|
||||
len_word &= 0x3f;
|
||||
|
||||
@@ -715,7 +715,7 @@ static char nullstring[] = {0};
|
||||
length = len_word + len_phonetic + 3;
|
||||
strcpy(&dict_line[(len_word)+2],encoded_ph);
|
||||
}
|
||||
|
||||
|
||||
for(ix=0; ix<n_flag_codes; ix++)
|
||||
{
|
||||
dict_line[ix+length] = flag_codes[ix];
|
||||
@@ -790,12 +790,12 @@ static void compile_dictlist_end(FILE *f_out)
|
||||
fflush(f_log);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
for(hash=0; hash<N_HASH_DICT; hash++)
|
||||
{
|
||||
p = hash_chains[hash];
|
||||
hash_counts[hash] = (int)ftell(f_out);
|
||||
|
||||
|
||||
while(p != NULL)
|
||||
{
|
||||
length = *(p+sizeof(char *));
|
||||
@@ -818,7 +818,7 @@ static int compile_dictlist_file(const char *path, const char* filename)
|
||||
char buf[200];
|
||||
char fname[sizeof(path_home)+45];
|
||||
char dict_line[128];
|
||||
|
||||
|
||||
text_mode = 0;
|
||||
|
||||
// try with and without '.txt' extension
|
||||
@@ -833,7 +833,7 @@ static int compile_dictlist_file(const char *path, const char* filename)
|
||||
fprintf(f_log,"Compiling: '%s'\n",fname);
|
||||
|
||||
linenum=0;
|
||||
|
||||
|
||||
while(fgets(buf,sizeof(buf),f_in) != NULL)
|
||||
{
|
||||
linenum++;
|
||||
@@ -842,7 +842,7 @@ static int compile_dictlist_file(const char *path, const char* filename)
|
||||
if(length == 0) continue; /* blank line */
|
||||
|
||||
hash_counts[hash]++;
|
||||
|
||||
|
||||
p = (char *)malloc(length+sizeof(char *));
|
||||
if(p == NULL)
|
||||
{
|
||||
@@ -853,13 +853,13 @@ static int compile_dictlist_file(const char *path, const char* filename)
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
memcpy(p,&hash_chains[hash],sizeof(char *));
|
||||
hash_chains[hash] = p;
|
||||
memcpy(p+sizeof(char *),dict_line,length);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
fprintf(f_log,"\t%d entries\n",count);
|
||||
fclose(f_in);
|
||||
return(0);
|
||||
@@ -920,7 +920,7 @@ static void copy_rule_string(char *string, int &state)
|
||||
output = &rule_phonemes[len];
|
||||
}
|
||||
sxflags = 0x808000; // to ensure non-zero bytes
|
||||
|
||||
|
||||
for(p=string,ix=0;;)
|
||||
{
|
||||
literal = 0;
|
||||
@@ -1126,6 +1126,9 @@ static void copy_rule_string(char *string, int &state)
|
||||
case 'a':
|
||||
sxflags |= SUFX_A;
|
||||
break;
|
||||
case 'm':
|
||||
sxflags |= SUFX_M;
|
||||
break;
|
||||
default:
|
||||
if(isdigit(c))
|
||||
value = (value*10) + (c - '0');
|
||||
@@ -1173,7 +1176,7 @@ static char *compile_rule(char *input)
|
||||
rule_phonemes[0]=0;
|
||||
|
||||
p = buf;
|
||||
|
||||
|
||||
for(ix=0; finish==0; ix++)
|
||||
{
|
||||
c = input[ix];
|
||||
@@ -1186,7 +1189,7 @@ static char *compile_rule(char *input)
|
||||
copy_rule_string(buf,state);
|
||||
p = buf;
|
||||
break;
|
||||
|
||||
|
||||
case '(': // start of suffix section
|
||||
*p = 0;
|
||||
state = 2;
|
||||
@@ -1199,7 +1202,7 @@ static char *compile_rule(char *input)
|
||||
error_count++;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case '\n': // end of line
|
||||
case '\r':
|
||||
case 0: // end of line
|
||||
@@ -1207,14 +1210,14 @@ static char *compile_rule(char *input)
|
||||
copy_rule_string(buf,state);
|
||||
finish=1;
|
||||
break;
|
||||
|
||||
|
||||
case '\t': // end of section section
|
||||
case ' ':
|
||||
*p = 0;
|
||||
copy_rule_string(buf,state);
|
||||
p = buf;
|
||||
break;
|
||||
|
||||
|
||||
case '?':
|
||||
if(state==2)
|
||||
state=0;
|
||||
@@ -1227,7 +1230,7 @@ static char *compile_rule(char *input)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(strcmp(rule_match,"$group")==0)
|
||||
strcpy(rule_match,group_name);
|
||||
|
||||
@@ -1249,7 +1252,7 @@ static char *compile_rule(char *input)
|
||||
}
|
||||
strcpy(output,buf);
|
||||
len = strlen(buf)+1;
|
||||
|
||||
|
||||
len_name = strlen(group_name);
|
||||
if((len_name > 0) && (memcmp(rule_match,group_name,len_name) != 0))
|
||||
{
|
||||
@@ -1382,7 +1385,7 @@ static void print_rule_group(FILE *f_out, int n_rules, char **rules, char *name)
|
||||
len1 = strlen(p) + 1;
|
||||
p = &p[len1];
|
||||
len2 = strlen(p);
|
||||
|
||||
|
||||
rule_match[0]=0;
|
||||
rule_pre[0]=0;
|
||||
rule_post[0]=0;
|
||||
@@ -1420,7 +1423,7 @@ static void print_rule_group(FILE *f_out, int n_rules, char **rules, char *name)
|
||||
}
|
||||
}
|
||||
*pout = 0;
|
||||
|
||||
|
||||
spaces = 12;
|
||||
if(condition > 0)
|
||||
{
|
||||
@@ -1441,10 +1444,10 @@ static void print_rule_group(FILE *f_out, int n_rules, char **rules, char *name)
|
||||
fprintf(f_out,"%s",buf);
|
||||
spaces = 0;
|
||||
}
|
||||
|
||||
|
||||
for(ix=0; ix<spaces; ix++)
|
||||
fputc(' ',f_out);
|
||||
|
||||
|
||||
spaces = 14;
|
||||
sprintf(buf," %s ",rule_match);
|
||||
if(rule_post[0] != 0)
|
||||
@@ -1633,7 +1636,7 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
|
||||
int n_rgroups = 0;
|
||||
int n_groups3 = 0;
|
||||
RGROUP rgroup[N_RULE_GROUP2];
|
||||
|
||||
|
||||
linenum = 0;
|
||||
group_name[0] = 0;
|
||||
|
||||
@@ -1649,7 +1652,7 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
|
||||
if((p = (unsigned char *)strstr(buf,"//")) != NULL)
|
||||
*p = 0;
|
||||
|
||||
if(buf[0] == '\r') buf++; // ignore extra \r in \r\n
|
||||
if(buf[0] == '\r') buf++; // ignore extra \r in \r\n
|
||||
}
|
||||
|
||||
if((buf == NULL) || (buf[0] == '.'))
|
||||
@@ -1711,7 +1714,7 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
|
||||
{
|
||||
// group character is given as a character code (max 16 bits)
|
||||
p = (unsigned char *)group_name;
|
||||
|
||||
|
||||
if(char_code > 0x100)
|
||||
{
|
||||
*p++ = (char_code >> 8);
|
||||
@@ -1730,7 +1733,7 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((group3_ix == 0) && (strlen(group_name) > 2))
|
||||
{
|
||||
if(utf8_in(&c,group_name) < 2)
|
||||
@@ -1738,14 +1741,14 @@ static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
|
||||
fprintf(f_log,"%5d: Group name longer than 2 bytes (UTF8)",linenum);
|
||||
error_count++;
|
||||
}
|
||||
|
||||
|
||||
group_name[2] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
switch(compile_mode)
|
||||
{
|
||||
case 1: // .group
|
||||
@@ -1915,10 +1918,10 @@ int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, cha
|
||||
compile_dictlist_file(path,"list");
|
||||
}
|
||||
compile_dictlist_file(path,"extra");
|
||||
|
||||
|
||||
compile_dictlist_end(f_out);
|
||||
offset_rules = ftell(f_out);
|
||||
|
||||
|
||||
fprintf(f_log,"Compiling: '%s'\n",fname_in);
|
||||
|
||||
compile_dictrules(f_in,f_out,fname_temp);
|
||||
|
||||
+89
-47
@@ -18,7 +18,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
@@ -161,7 +161,7 @@ static void InitGroups(Translator *tr)
|
||||
|
||||
if(p[0] == RULE_REPLACEMENTS)
|
||||
{
|
||||
pw = (unsigned int *)(((long)p+4) & ~3); // advance to next word boundary
|
||||
pw = (unsigned int *)(((long64)p+4) & ~3); // advance to next word boundary
|
||||
tr->langopts.replace_chars = pw;
|
||||
while(pw[0] != 0)
|
||||
{
|
||||
@@ -218,7 +218,7 @@ static void InitGroups(Translator *tr)
|
||||
{
|
||||
if(tr->groups2_start[c] == 255)
|
||||
tr->groups2_start[c] = tr->n_groups2;
|
||||
|
||||
|
||||
tr->groups2_count[c]++;
|
||||
tr->groups2[tr->n_groups2] = p;
|
||||
tr->groups2_name[tr->n_groups2++] = (c + (c2 << 8));
|
||||
@@ -347,8 +347,8 @@ int HashDictionary(const char *string)
|
||||
|
||||
|
||||
|
||||
char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme)
|
||||
/*********************************************************************/
|
||||
const char *EncodePhonemes(const char *p, char *outptr, unsigned char *bad_phoneme)
|
||||
/***************************************************************************/
|
||||
/* Translate a phoneme string from ascii mnemonics to internal phoneme numbers,
|
||||
from 'p' up to next blank .
|
||||
Returns advanced 'p'
|
||||
@@ -364,7 +364,8 @@ char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme)
|
||||
int consumed;
|
||||
unsigned int mnemonic_word;
|
||||
|
||||
bad_phoneme[0] = 0;
|
||||
if(bad_phoneme != NULL)
|
||||
bad_phoneme[0] = 0;
|
||||
|
||||
// skip initial blanks
|
||||
while(isspace(*p))
|
||||
@@ -424,8 +425,11 @@ char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme)
|
||||
if(max_ph == 0)
|
||||
{
|
||||
// not recognised, report and ignore
|
||||
bad_phoneme[0] = *p;
|
||||
bad_phoneme[1] = 0;
|
||||
if(bad_phoneme != NULL)
|
||||
{
|
||||
bad_phoneme[0] = *p;
|
||||
bad_phoneme[1] = 0;
|
||||
}
|
||||
*outptr++ = 0;
|
||||
return(p+1);
|
||||
}
|
||||
@@ -485,7 +489,7 @@ sprintf(outptr,"* ");
|
||||
continue; /* indicates unrecognised phoneme */
|
||||
if((ph = phoneme_tab[phcode]) == NULL)
|
||||
continue;
|
||||
|
||||
|
||||
if((ph->type == phSTRESS) && (ph->std_length <= 4) && (ph->program == 0))
|
||||
{
|
||||
if(ph->std_length > 1)
|
||||
@@ -495,7 +499,7 @@ sprintf(outptr,"* ");
|
||||
{
|
||||
mnem = ph->mnemonic;
|
||||
|
||||
while((c = (mnem & 0xff)) != 0)
|
||||
while((c = (mnem & 0xff)) != 0)
|
||||
{
|
||||
*outptr++ = c;
|
||||
mnem = mnem >> 8;
|
||||
@@ -517,7 +521,7 @@ sprintf(outptr,"* ");
|
||||
unsigned short ipa1[96] = {
|
||||
0x20,0x21,0x22,0x2b0,0x24,0x25,0x0e6,0x2c8,0x28,0x27e,0x2a,0x2b,0x2cc,0x2d,0x2e,0x2f,
|
||||
0x252,0x31,0x32,0x25c,0x34,0x35,0x36,0x37,0x275,0x39,0x2d0,0x2b2,0x3c,0x3d,0x3e,0x294,
|
||||
0x259,0x251,0x3b2,0xe7,0xf0,0x25b,0x46,0x262,0x127,0x26a,0x25f,0x4b,0x4c,0x271,0x14b,0x254,
|
||||
0x259,0x251,0x3b2,0xe7,0xf0,0x25b,0x46,0x262,0x127,0x26a,0x25f,0x4b,0x29f,0x271,0x14b,0x254,
|
||||
0x3a6,0x263,0x280,0x283,0x3b8,0x28a,0x28c,0x153,0x3c7,0xf8,0x292,0x32a,0x5c,0x5d,0x5e,0x5f,
|
||||
0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x261,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
|
||||
0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x303,0x7f
|
||||
@@ -561,7 +565,7 @@ char *WritePhMnemonic(char *phon_out, PHONEME_TAB *ph, PHONEME_LIST *plist, int
|
||||
}
|
||||
else
|
||||
{
|
||||
InterpretPhoneme(NULL, 0, plist, &phdata);
|
||||
InterpretPhoneme(NULL, 0, plist, &phdata, NULL);
|
||||
}
|
||||
|
||||
len = strlen(phdata.ipa_string);
|
||||
@@ -634,7 +638,7 @@ void GetTranslatedPhonemeString(char *phon_out, int n_phon_out, int use_ipa)
|
||||
char *buf;
|
||||
char phon_buf[30];
|
||||
PHONEME_LIST *plist;
|
||||
|
||||
|
||||
static const char *stress_chars = "==,,''";
|
||||
|
||||
if(phon_out != NULL)
|
||||
@@ -690,7 +694,7 @@ void GetTranslatedPhonemeString(char *phon_out, int n_phon_out, int use_ipa)
|
||||
buf = WritePhMnemonic(buf, phoneme_tab[plist->tone_ph], NULL, use_ipa);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
len = buf - phon_buf;
|
||||
max_len = (n_phon_out - phon_out_ix - 5); // allow for " ..." and zero byte terminator
|
||||
if(len > max_len)
|
||||
@@ -935,7 +939,7 @@ static int GetVowelStress(Translator *tr, unsigned char *phonemes, signed char *
|
||||
max_stress = 4;
|
||||
primary_posn = j;
|
||||
}
|
||||
|
||||
|
||||
/* reduce any preceding primary stress markers */
|
||||
for(ix=1; ix<j; ix++)
|
||||
{
|
||||
@@ -1125,6 +1129,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
int stressflags;
|
||||
int dflags = 0;
|
||||
int first_primary;
|
||||
int long_vowel;
|
||||
|
||||
signed char vowel_stress[N_WORD_PHONEMES/2];
|
||||
char syllable_weight[N_WORD_PHONEMES/2];
|
||||
@@ -1162,7 +1167,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
|
||||
max_output = output + (N_WORD_PHONEMES-3); /* check for overrun */
|
||||
|
||||
// any stress position marked in the xx_list dictionary ?
|
||||
// any stress position marked in the xx_list dictionary ?
|
||||
stressed_syllable = dflags & 0x7;
|
||||
if(dflags & 0x8)
|
||||
{
|
||||
@@ -1213,7 +1218,7 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
ix++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch(tr->langopts.stress_rule)
|
||||
{
|
||||
case 8:
|
||||
@@ -1271,12 +1276,12 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
mnem = phoneme_tab[final_ph]->mnemonic;
|
||||
mnem2 = phoneme_tab[final_ph2]->mnemonic;
|
||||
|
||||
if((mnem == 's') && (mnem2 == 'n'))
|
||||
if((mnem == 's') && (phoneme_tab[final_ph2]->type == phNASAL))
|
||||
{
|
||||
// -ns stress remains on penultimate syllable
|
||||
}
|
||||
else
|
||||
if(((mnem != 'n') && (mnem != 's')) || (phoneme_tab[final_ph2]->type != phVOWEL))
|
||||
if(((phoneme_tab[final_ph]->type != phNASAL) && (mnem != 's')) || (phoneme_tab[final_ph2]->type != phVOWEL))
|
||||
{
|
||||
stressed_syllable = vowel_count - 1;
|
||||
}
|
||||
@@ -1440,6 +1445,39 @@ void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags,
|
||||
vowel_stress[ix] = 4;
|
||||
}
|
||||
break;
|
||||
|
||||
case 12: // LANG=kl (Greenlandic)
|
||||
long_vowel = 0;
|
||||
for(ix=1; ix < vowel_count; ix++)
|
||||
{
|
||||
if(vowel_stress[ix] == 4)
|
||||
vowel_stress[ix] = 3; // change marked stress (consonant clusters) to secondary (except the last)
|
||||
|
||||
if(vowel_length[ix] > 0)
|
||||
{
|
||||
long_vowel = ix;
|
||||
vowel_stress[ix] = 3; // give secondary stress to all long vowels
|
||||
}
|
||||
}
|
||||
|
||||
// 'stressed_syllable' gives the last marked stress
|
||||
if(stressed_syllable == 0)
|
||||
{
|
||||
// no marked stress, choose the last long vowel
|
||||
if(long_vowel > 0)
|
||||
stressed_syllable = long_vowel;
|
||||
else
|
||||
{
|
||||
// no long vowels or consonant clusters
|
||||
if(vowel_count > 4)
|
||||
stressed_syllable = vowel_count - 3;
|
||||
else
|
||||
stressed_syllable = vowel_count - 1;
|
||||
}
|
||||
}
|
||||
vowel_stress[stressed_syllable] = 4;
|
||||
max_stress = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
/* now guess the complete stress pattern */
|
||||
@@ -1706,7 +1744,7 @@ void AppendPhonemes(Translator *tr, char *string, int size, const char *ph)
|
||||
/* Add new phoneme string "ph" to "string"
|
||||
Keeps count of the number of vowel phonemes in the word, and whether these
|
||||
can be stressed syllables. These values can be used in translation rules
|
||||
*/
|
||||
*/
|
||||
const char *p;
|
||||
unsigned char c;
|
||||
int unstress_mark;
|
||||
@@ -1744,7 +1782,7 @@ void AppendPhonemes(Translator *tr, char *string, int size, const char *ph)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(string != NULL)
|
||||
strcat(string,ph);
|
||||
} /* end of AppendPhonemes */
|
||||
@@ -1839,7 +1877,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
match.points = 1;
|
||||
match.end_type = 0;
|
||||
match.del_fwd = NULL;
|
||||
|
||||
|
||||
pre_ptr = *word;
|
||||
post_ptr = *word + group_length;
|
||||
|
||||
@@ -1905,7 +1943,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
case RULE_CONDITION:
|
||||
/* conditional rule, next byte gives condition number */
|
||||
condition_num = *rule++;
|
||||
|
||||
|
||||
if(condition_num >= 32)
|
||||
{
|
||||
// allow the rule only if the condition number is NOT set
|
||||
@@ -2013,7 +2051,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
else
|
||||
failed = 1;
|
||||
break;
|
||||
|
||||
|
||||
case RULE_NONALPHA:
|
||||
if(!iswalpha(letter_w))
|
||||
{
|
||||
@@ -2384,13 +2422,13 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
memcpy(&best,&match,sizeof(match));
|
||||
total_consumed = consumed;
|
||||
}
|
||||
|
||||
|
||||
if((option_phonemes == 2) && (match.points > 0) && ((word_flags & FLAG_NO_TRACE) == 0))
|
||||
{
|
||||
// show each rule that matches, and it's points score
|
||||
int pts;
|
||||
char decoded_phonemes[80];
|
||||
|
||||
|
||||
pts = match.points;
|
||||
if(group_length > 1)
|
||||
pts += 35; // to account for an extra letter matching
|
||||
@@ -2486,10 +2524,10 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
p = p_start;
|
||||
tr->word_vowel_count = 0;
|
||||
tr->word_stressed_count = 0;
|
||||
|
||||
|
||||
if(end_phonemes != NULL)
|
||||
end_phonemes[0] = 0;
|
||||
|
||||
|
||||
while(((c = *p) != ' ') && (c != 0))
|
||||
{
|
||||
wc_bytes = utf8_in(&wc,p);
|
||||
@@ -2507,7 +2545,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
string[1+wc_bytes] = 0;
|
||||
Lookup(tr, string,buf);
|
||||
if(++digit_count >= 2)
|
||||
{
|
||||
{
|
||||
strcat(buf,str_pause);
|
||||
digit_count=0;
|
||||
}
|
||||
@@ -2534,7 +2572,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
/* there are some 2 byte chains for this initial letter */
|
||||
c2 = p[1];
|
||||
c12 = c + (c2 << 8); /* 2 characters */
|
||||
|
||||
|
||||
g1 = tr->groups2_start[c];
|
||||
for(g=g1; g < (g1+n); g++)
|
||||
{
|
||||
@@ -2559,7 +2597,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!found)
|
||||
{
|
||||
/* alphabetic, single letter chain */
|
||||
@@ -2615,14 +2653,14 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
p[-1] = ix;
|
||||
while((p[0] = p[n]) != ' ') p++;
|
||||
while(n-- > 0) *p++ = ' '; // replacement character must be no longer than original
|
||||
|
||||
|
||||
if(tr->langopts.param[LOPT_DIERESES] && (lookupwchar(diereses_list,letter) > 0))
|
||||
{
|
||||
// vowel with dieresis, replace and continue from this point
|
||||
p = p2;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
phonemes[0] = 0; // delete any phonemes which have been produced so far
|
||||
p = p_start;
|
||||
tr->word_vowel_count = 0;
|
||||
@@ -2681,7 +2719,7 @@ int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, c
|
||||
|
||||
if(match1.phonemes == NULL)
|
||||
match1.phonemes = "";
|
||||
|
||||
|
||||
if(match1.points > 0)
|
||||
{
|
||||
if(word_flags & FLAG_UNPRON_TEST)
|
||||
@@ -2884,7 +2922,7 @@ int TransposeAlphabet(Translator *tr, char *text)
|
||||
if(bits >= 8)
|
||||
{
|
||||
bits -= 8;
|
||||
*p2++ = (acc >> bits);
|
||||
*p2++ = (acc >> bits);
|
||||
}
|
||||
}
|
||||
if(bits > 0)
|
||||
@@ -3202,7 +3240,7 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
|
||||
|
||||
if(flags != NULL)
|
||||
flags[0] |= FLAG_FOUND; // this flag indicates word was found in dictionary
|
||||
|
||||
|
||||
if(option_phonemes == 2)
|
||||
{
|
||||
char ph_decoded[N_WORD_PHONEMES];
|
||||
@@ -3340,9 +3378,9 @@ int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *f
|
||||
if(found == 0)
|
||||
{
|
||||
ph_out[0] = 0;
|
||||
|
||||
|
||||
// try modifications to find a recognised word
|
||||
|
||||
|
||||
if((end_flags & FLAG_SUFX_E_ADDED) && (word[length-1] == 'e'))
|
||||
{
|
||||
// try removing an 'e' which has been added by RemoveEnding
|
||||
@@ -3435,7 +3473,7 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
||||
This routine is language specific. In English it deals with reversing y->i and e-dropping
|
||||
that were done when the suffix was added to the original word.
|
||||
*/
|
||||
|
||||
|
||||
int i;
|
||||
char *word_end;
|
||||
int len_ending;
|
||||
@@ -3443,7 +3481,7 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
||||
const char *p;
|
||||
int len;
|
||||
static char ending[12];
|
||||
|
||||
|
||||
// these lists are language specific, but are only relevent if the 'e' suffix flag is used
|
||||
static const char *add_e_exceptions[] = {
|
||||
"ion", NULL };
|
||||
@@ -3459,8 +3497,12 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
||||
*word_end = 'e';
|
||||
}
|
||||
i = word_end - word;
|
||||
memcpy(word_copy,word,i);
|
||||
word_copy[i] = 0;
|
||||
|
||||
if(word_copy != NULL)
|
||||
{
|
||||
memcpy(word_copy,word,i);
|
||||
word_copy[i] = 0;
|
||||
}
|
||||
|
||||
// look for multibyte characters to increase the number of bytes to remove
|
||||
for(len_ending = i = (end_type & 0x3f); i>0 ;i--) // num.of characters of the suffix
|
||||
@@ -3472,7 +3514,7 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
||||
len_ending++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// remove bytes from the end of the word and replace them by spaces
|
||||
for(i=0; i<len_ending; i++)
|
||||
{
|
||||
@@ -3483,17 +3525,17 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
||||
word_end--; /* now pointing at last character of stem */
|
||||
|
||||
end_flags = (end_type & 0xfff0) | FLAG_SUFX;
|
||||
|
||||
|
||||
/* add an 'e' to the stem if appropriate,
|
||||
if stem ends in vowel+consonant
|
||||
or stem ends in 'c' (add 'e' to soften it) */
|
||||
|
||||
|
||||
if(end_type & SUFX_I)
|
||||
{
|
||||
if(word_end[0] == 'i')
|
||||
word_end[0] = 'y';
|
||||
}
|
||||
|
||||
|
||||
if(end_type & SUFX_E)
|
||||
{
|
||||
if(tr->translator_name == L('n','l'))
|
||||
@@ -3513,7 +3555,7 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
|
||||
if(IsLetter(tr, word_end[-1],LETTERGP_VOWEL2) && IsLetter(tr, word_end[0],1))
|
||||
{
|
||||
// vowel(incl.'y') + hard.consonant
|
||||
|
||||
|
||||
for(i=0; (p = add_e_exceptions[i]) != NULL; i++)
|
||||
{
|
||||
len = strlen(p);
|
||||
|
||||
+146
-124
@@ -21,7 +21,6 @@
|
||||
|
||||
|
||||
#include "wx/wfstream.h"
|
||||
#include "wx/notebook.h"
|
||||
#include "wx/image.h"
|
||||
#include "wx/filename.h"
|
||||
#include "wx/numdlg.h"
|
||||
@@ -74,8 +73,6 @@ extern void VowelChart(int control, char *fname);
|
||||
extern void MakeVowelLists(void);
|
||||
extern void MakeWordFreqList();
|
||||
|
||||
extern const char *dict_name;
|
||||
|
||||
extern wxMenu *speak_menu;
|
||||
extern wxMenu *data_menu;
|
||||
|
||||
@@ -83,15 +80,16 @@ extern wxMenu *data_menu;
|
||||
MyFrame *myframe = NULL;
|
||||
SpectDisplay *currentcanvas = NULL;
|
||||
|
||||
ChildFrProsody *prosodyframe = NULL;
|
||||
ProsodyDisplay *prosodycanvas = NULL;
|
||||
wxNotebook *notebook = NULL;
|
||||
wxNotebook *screenpages = NULL;
|
||||
|
||||
wxProgressDialog *progress;
|
||||
int progress_max;
|
||||
int gui_flag = 0;
|
||||
int frame_x, frame_y, frame_w, frame_h;
|
||||
|
||||
wxList my_children;
|
||||
int adding_page = 0; // fix for wxWidgets (2,8,7) bug, adding first page to a wxNotebook gives emptystring for GetPageTex() in Notebook_Page_Changed event.
|
||||
|
||||
wxFont FONT_SMALL(8,wxSWISS,wxNORMAL,wxNORMAL);
|
||||
wxFont FONT_MEDIUM(9,wxSWISS,wxNORMAL,wxNORMAL);
|
||||
@@ -166,7 +164,7 @@ if(argc > 1)
|
||||
|
||||
if((frame_w == 0) || (frame_h == 0))
|
||||
{
|
||||
frame_w = 1024;
|
||||
frame_w = 800;
|
||||
frame_h = 768;
|
||||
}
|
||||
|
||||
@@ -191,7 +189,7 @@ if(argc > 1)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_CHAR(MyFrame::OnKey)
|
||||
EVT_MENU(MENU_ABOUT, MyFrame::OnAbout)
|
||||
EVT_MENU(MENU_DOCS, MyFrame::OnAbout)
|
||||
@@ -213,7 +211,6 @@ BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
|
||||
EVT_MENU(MENU_SORT_DICTIONARY, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_COMPILE_MBROLA, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_COMPILE_INTONATION, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_CLOSE_ALL, MyFrame::OnQuit)
|
||||
EVT_MENU(MENU_QUIT, MyFrame::OnQuit)
|
||||
EVT_MENU(MENU_SPEAK_TRANSLATE, MyFrame::OnSpeak)
|
||||
EVT_MENU(MENU_SPEAK_RULES, MyFrame::OnSpeak)
|
||||
@@ -238,14 +235,22 @@ BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
|
||||
EVT_MENU(MENU_TEST, MyFrame::OnTools)
|
||||
EVT_MENU(MENU_TEST2, MyFrame::OnTools)
|
||||
|
||||
EVT_MENU(SPECTSEQ_SAVE, MyFrame::PageCmd)
|
||||
EVT_MENU(SPECTSEQ_SAVEAS, MyFrame::PageCmd)
|
||||
EVT_MENU(SPECTSEQ_SAVESELECT, MyFrame::PageCmd)
|
||||
EVT_MENU(SPECTSEQ_CLOSE, MyFrame::PageCmd)
|
||||
EVT_MENU(SPECTSEQ_SAVEPITCH, MyFrame::PageCmd)
|
||||
EVT_MENU(MENU_CLOSE_ALL, MyFrame::PageCmd)
|
||||
|
||||
|
||||
EVT_NOTEBOOK_PAGE_CHANGED(ID_SCREENPAGES, MyFrame::OnPageChanged)
|
||||
EVT_TIMER(1, MyFrame::OnTimer)
|
||||
EVT_SIZE(MyFrame::OnSize)
|
||||
EVT_SASH_DRAGGED(ID_WINDOW_LEFT, MyFrame::OnSashDrag)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
MyFrame::~MyFrame(void)
|
||||
{//====================
|
||||
myframe->Maximize(false);
|
||||
myframe->Show(false);
|
||||
myframe->Iconize(false); // os=Windows, get the non-iconsized size
|
||||
myframe->GetPosition(&frame_x, &frame_y);
|
||||
@@ -254,7 +259,7 @@ MyFrame::~MyFrame(void)
|
||||
|
||||
MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size,
|
||||
const long style):
|
||||
wxMDIParentFrame(parent, id, title, pos, size, style)
|
||||
wxFrame(parent, id, title, pos, size, style)
|
||||
{//===================================================================================================================
|
||||
// Main Frame constructor
|
||||
|
||||
@@ -262,16 +267,7 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c
|
||||
int result;
|
||||
int param;
|
||||
|
||||
// Another window to the left of the client window
|
||||
m_leftWindow = new wxSashLayoutWindow(this, ID_WINDOW_LEFT,
|
||||
wxDefaultPosition, wxSize(298, 30),
|
||||
wxNO_BORDER | wxSW_3D | wxCLIP_CHILDREN);
|
||||
m_leftWindow->SetDefaultSize(wxSize(310, 1000));
|
||||
m_leftWindow->SetOrientation(wxLAYOUT_VERTICAL);
|
||||
m_leftWindow->SetAlignment(wxLAYOUT_LEFT);
|
||||
m_leftWindow->SetSashVisible(wxSASH_RIGHT, TRUE);
|
||||
|
||||
notebook = new wxNotebook(m_leftWindow,-1);
|
||||
notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxSize(312,760));
|
||||
// notebook->AddPage(voicedlg,_T("Voice"),FALSE);
|
||||
formantdlg = new FormantDlg(notebook);
|
||||
notebook->AddPage(formantdlg,_T(" Spect"),FALSE);
|
||||
@@ -281,6 +277,29 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c
|
||||
notebook->AddPage(transldlg,_T("Text"),TRUE);
|
||||
|
||||
|
||||
screenpages = new wxNotebook(this, ID_SCREENPAGES, wxDefaultPosition, wxSize(554,702));
|
||||
|
||||
wxBoxSizer *framesizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
|
||||
framesizer->Add(
|
||||
notebook,
|
||||
0, // make horizontally stretchable
|
||||
wxEXPAND | // make vertically stretchable
|
||||
wxALL, // and make border all around
|
||||
4 ); // set border width
|
||||
|
||||
framesizer->Add(
|
||||
screenpages,
|
||||
1, // make horizontally stretchable
|
||||
wxEXPAND | // make vertically stretchable
|
||||
wxALL, // and make border all around
|
||||
4 ); // set border width
|
||||
|
||||
SetSizer( framesizer ); // use the sizer for layout
|
||||
framesizer->SetSizeHints( this ); // set size hints to honour minimum size
|
||||
SetSize(pos.x, pos.y, size.GetWidth(), size.GetHeight());
|
||||
|
||||
LoadConfig();
|
||||
WavegenInitSound();
|
||||
|
||||
@@ -310,7 +329,7 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c
|
||||
|
||||
for(param=0; param<N_SPEECH_PARAM; param++)
|
||||
param_stack[0].parameter[param] = param_defaults[param];
|
||||
|
||||
|
||||
SetParameter(espeakRATE,option_speed,0);
|
||||
|
||||
SetSpeed(3);
|
||||
@@ -345,6 +364,110 @@ void MyFrame::SetVoiceTitle(char *voice_name)
|
||||
|
||||
|
||||
|
||||
void MyFrame::PageCmd(wxCommandEvent& event)
|
||||
{//=========================================
|
||||
int pagenum;
|
||||
int ix;
|
||||
int n_pages;
|
||||
SpectDisplay *page;
|
||||
|
||||
// if(currentcanvas != NULL)
|
||||
{
|
||||
pagenum = screenpages->GetSelection();
|
||||
|
||||
switch(event.GetId())
|
||||
{
|
||||
case SPECTSEQ_SAVE:
|
||||
currentcanvas->Save(currentcanvas->savepath);
|
||||
break;
|
||||
case SPECTSEQ_SAVEAS:
|
||||
currentcanvas->Save();
|
||||
break;
|
||||
case SPECTSEQ_SAVESELECT:
|
||||
currentcanvas->Save(_T(""), 1);
|
||||
break;
|
||||
case SPECTSEQ_CLOSE:
|
||||
if(screenpages->GetPageText(pagenum) != _T("Prosody"))
|
||||
{
|
||||
currentcanvas->OnActivate(0);
|
||||
}
|
||||
screenpages->DeletePage(pagenum);
|
||||
|
||||
if((n_pages = screenpages->GetPageCount()) > 0)
|
||||
{
|
||||
if(pagenum >= n_pages)
|
||||
pagenum--;
|
||||
page = (SpectDisplay *)screenpages->GetPage(pagenum);
|
||||
|
||||
if(screenpages->GetPageText(pagenum) == _T("Prosody"))
|
||||
{
|
||||
MakeMenu(3, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
page->OnActivate(1);
|
||||
MakeMenu(2, NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MakeMenu(1, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_CLOSE_ALL:
|
||||
n_pages = screenpages->GetPageCount();
|
||||
for(ix=n_pages-1; ix>=0; ix--)
|
||||
{
|
||||
screenpages->DeletePage(ix);
|
||||
}
|
||||
currentcanvas = NULL;
|
||||
MakeMenu(1, NULL);
|
||||
break;
|
||||
case SPECTSEQ_SAVEPITCH:
|
||||
currentcanvas->SavePitchenv(currentcanvas->spectseq->pitchenv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MyFrame::OnPageChanged(wxNotebookEvent& event)
|
||||
{//=================================================
|
||||
int pagenum;
|
||||
wxString title;
|
||||
SpectDisplay *page;
|
||||
|
||||
pagenum = event.GetSelection();
|
||||
|
||||
if(event.GetId() == ID_SCREENPAGES)
|
||||
{
|
||||
title = screenpages->GetPageText(pagenum);
|
||||
|
||||
if((title != _T("Prosody")) && (adding_page != 2))
|
||||
{
|
||||
page = (SpectDisplay *)screenpages->GetPage(pagenum);
|
||||
|
||||
if(page != currentcanvas)
|
||||
{
|
||||
if(currentcanvas != NULL)
|
||||
{
|
||||
currentcanvas->OnActivate(0);
|
||||
}
|
||||
page->OnActivate(1);
|
||||
}
|
||||
MakeMenu(2, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
MakeMenu(3, NULL);
|
||||
}
|
||||
}
|
||||
adding_page = 0; // work around for wxNotebook bug (version 2.8.7)
|
||||
}
|
||||
|
||||
|
||||
void MyFrame::OnKey(wxKeyEvent& event)
|
||||
{
|
||||
int key;
|
||||
@@ -624,7 +747,7 @@ void MyFrame::OnTools(wxCommandEvent& event)
|
||||
case MENU_COMPILE_INTONATION:
|
||||
CompileIntonation();
|
||||
break;
|
||||
|
||||
|
||||
case MENU_COMPILE_DICT_DEBUG:
|
||||
debug_flag =1; // and drop through to next case
|
||||
case MENU_COMPILE_DICT:
|
||||
@@ -729,105 +852,4 @@ void MyFrame::OnSpeak(wxCommandEvent& event)
|
||||
}
|
||||
|
||||
|
||||
void MyFrame::OnSashDrag(wxSashEvent& event)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
|
||||
return;
|
||||
|
||||
GetClientSize(&w, &h);
|
||||
|
||||
switch (event.GetId())
|
||||
{
|
||||
case ID_WINDOW_LEFT:
|
||||
{
|
||||
m_leftWindow->SetDefaultSize(wxSize(event.GetDragRect().width, h));
|
||||
break;
|
||||
}
|
||||
}
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame(this);
|
||||
|
||||
// Leaves bits of itself behind sometimes
|
||||
GetClientWindow()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event))
|
||||
{
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame(this);
|
||||
}
|
||||
|
||||
// Note that SASHTEST_NEW_WINDOW and SASHTEST_ABOUT commands get passed
|
||||
// to the parent window for processing, so no need to
|
||||
// duplicate event handlers here.
|
||||
|
||||
BEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame)
|
||||
EVT_MENU(SPECTSEQ_CLOSE, MyChild::OnQuit)
|
||||
EVT_MENU(SPECTSEQ_SAVE, MyChild::OnSave)
|
||||
EVT_MENU(SPECTSEQ_SAVEAS, MyChild::OnSaveAs)
|
||||
EVT_MENU(SPECTSEQ_SAVESELECT, MyChild::OnSaveSelect)
|
||||
EVT_MENU(SPECTSEQ_SAVEPITCH, MyChild::OnSavePitchenv)
|
||||
|
||||
EVT_ACTIVATE(MyChild::OnActivate)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size,
|
||||
const long style):
|
||||
wxMDIChildFrame(parent, -1, title, pos, size, style)
|
||||
{
|
||||
canvas = NULL;
|
||||
my_children.Append(this);
|
||||
}
|
||||
|
||||
MyChild::~MyChild(void)
|
||||
{
|
||||
canvas = NULL;
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
wxWindow *w;
|
||||
// bug in wxMDIChildFrame, we need to explicitly remove the ChildFrame from the ClientWindow
|
||||
w = myframe->GetClientWindow();
|
||||
w->RemoveChild(this);
|
||||
#endif
|
||||
my_children.DeleteObject(this);
|
||||
}
|
||||
|
||||
//extern void CloseCanvas();
|
||||
|
||||
void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Destroy();
|
||||
|
||||
}
|
||||
|
||||
void MyChild::OnSave(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
canvas->Save(canvas->savepath);
|
||||
}
|
||||
|
||||
void MyChild::OnSaveAs(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
canvas->Save();
|
||||
}
|
||||
|
||||
void MyChild::OnSaveSelect(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
canvas->Save(_T(""),1);
|
||||
}
|
||||
|
||||
void MyChild::OnSavePitchenv(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
canvas->SavePitchenv(canvas->spectseq->pitchenv);
|
||||
}
|
||||
|
||||
void MyChild::OnActivate(wxActivateEvent& event)
|
||||
{
|
||||
if(canvas)
|
||||
canvas->OnActivate(event.GetActive());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -97,7 +97,7 @@ void FormantDlg::OnSpin(wxSpinEvent& event)
|
||||
currentcanvas->SetFocus();
|
||||
}
|
||||
|
||||
FormantDlg::FormantDlg(wxWindow *parent) : wxPanel(parent,-1,wxDefaultPosition,wxSize(400,1000))
|
||||
FormantDlg::FormantDlg(wxWindow *parent) : wxPanel(parent,-1,wxDefaultPosition,wxSize(400,800))
|
||||
{//=============================================================================================
|
||||
int ix;
|
||||
int y;
|
||||
@@ -395,7 +395,7 @@ void FormantDlg::ShowFrame(SpectSeq *spectseq, int frame, int pk, int field)
|
||||
{
|
||||
value.Printf(_T("%3d"),peak->klt_bp);
|
||||
t_klt_bp[ix]->SetValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,12 +469,12 @@ void ByteGraph::DrawSpectrum(wxDC& dc)
|
||||
numframes = seq->numframes;
|
||||
|
||||
if(numframes == 0) return;
|
||||
|
||||
|
||||
GetClientSize(&width,&height);
|
||||
|
||||
if(((length = seq->frames[numframes-1]->time)==0) && (numframes>1))
|
||||
length = seq->frames[numframes-2]->time;
|
||||
|
||||
|
||||
length = length - seq->frames[0]->time;
|
||||
|
||||
yscale = height/3000.0;
|
||||
@@ -518,7 +518,7 @@ void ByteGraph::OnDraw(wxDC &dc)
|
||||
double xscale, yscale;
|
||||
|
||||
if(show_spectrum) DrawSpectrum(dc);
|
||||
|
||||
|
||||
if(npoints==0) return;
|
||||
|
||||
GetClientSize(&width,&height);
|
||||
@@ -559,7 +559,7 @@ void ByteGraph::OnMouse(wxMouseEvent& event)
|
||||
wxPoint pt(event.GetLogicalPosition(dc));
|
||||
t0 = t2 = seq->frames[0]->time;
|
||||
time = (double(pt.x) / spectrum_scale) + t0;
|
||||
|
||||
|
||||
for(ix=1; ix<seq->numframes; ix++)
|
||||
{
|
||||
t1=t2;
|
||||
|
||||
@@ -902,7 +902,6 @@ static void setzeroabc(long int f, long int bw, resonator_ptr rp)
|
||||
/* Let a = 1.0 - b - c */
|
||||
rp->a = 1.0 - rp->b - rp->c;
|
||||
|
||||
/* Now convert to antiresonator coefficients (a'=1/a, b'=b/a, c'=c/a) */
|
||||
/* If f == 0 then rp->a gets set to 0 which makes a'=1/a set a', b' and c' to
|
||||
* INF, causing an audible sound spike when triggered (e.g. apiration with the
|
||||
* nasal register set to f=0, bw=0).
|
||||
|
||||
+17
-12
@@ -2,6 +2,7 @@
|
||||
#include "wx/toolbar.h"
|
||||
#include "wx/laywin.h"
|
||||
#include "wx/progdlg.h"
|
||||
#include "wx/notebook.h"
|
||||
|
||||
typedef unsigned short USHORT;
|
||||
typedef unsigned char UCHAR;
|
||||
@@ -32,44 +33,45 @@ class MyApp: public wxApp
|
||||
};
|
||||
|
||||
// Define a new frame
|
||||
class MyFrame: public wxMDIParentFrame
|
||||
class MyFrame: public wxFrame
|
||||
{
|
||||
public:
|
||||
|
||||
MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
||||
~MyFrame(void);
|
||||
|
||||
void OnSize(wxSizeEvent& event);
|
||||
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnOptions(wxCommandEvent& event);
|
||||
void OnSpeak(wxCommandEvent& event);
|
||||
void OnSpeak(wxCommandEvent& event);
|
||||
void OnTools(wxCommandEvent& event);
|
||||
void OnSashDrag(wxSashEvent& event);
|
||||
void OnKey(wxKeyEvent& event);
|
||||
void OnTimer(wxTimerEvent& event);
|
||||
void LoadWavFile(void);
|
||||
|
||||
void OnNewWindow(wxCommandEvent& event);
|
||||
void OnProsody(wxCommandEvent& event);
|
||||
void PageCmd(wxCommandEvent& event);
|
||||
void SetVoiceTitle(char *voice_name);
|
||||
|
||||
void OnPageChanged(wxNotebookEvent& event);
|
||||
|
||||
protected:
|
||||
wxSashLayoutWindow* m_leftWindow;
|
||||
wxTimer m_timer;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class MyChild: public wxMDIChildFrame
|
||||
|
||||
#ifdef deleted
|
||||
class MyChild: public wxPanel
|
||||
{
|
||||
public:
|
||||
SpectDisplay *canvas;
|
||||
MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
||||
MyChild(wxNotebook *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
||||
~MyChild(void);
|
||||
void OnActivate(wxActivateEvent& event);
|
||||
|
||||
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnSave(wxCommandEvent& event);
|
||||
void OnSaveAs(wxCommandEvent& event);
|
||||
@@ -79,7 +81,7 @@ class MyChild: public wxMDIChildFrame
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
class TranslDlg : public wxPanel
|
||||
@@ -103,6 +105,7 @@ private:
|
||||
};
|
||||
|
||||
extern MyFrame *myframe;
|
||||
extern wxNotebook* screenpages;
|
||||
extern TranslDlg *transldlg;
|
||||
extern wchar_t ipa1[256];
|
||||
|
||||
@@ -171,10 +174,12 @@ enum {
|
||||
SPECTSEQ_SAVEAS,
|
||||
SPECTSEQ_SAVESELECT,
|
||||
SPECTSEQ_SAVEPITCH,
|
||||
SPECTSEQ_VOICEDLG
|
||||
SPECTSEQ_VOICEDLG,
|
||||
|
||||
ID_SCREENPAGES,
|
||||
ID_NOTEBOOK
|
||||
};
|
||||
|
||||
#define ID_WINDOW_LEFT 101
|
||||
|
||||
|
||||
|
||||
|
||||
+101
-90
@@ -24,10 +24,13 @@
|
||||
|
||||
wxMenu *speak_menu;
|
||||
wxMenu *data_menu = NULL;
|
||||
wxMenuBar *menu_bar = NULL;
|
||||
|
||||
|
||||
wxMenuBar *MakeMenu(int type, const char *dict_name)
|
||||
{//=================================================
|
||||
{//===================================================
|
||||
char buf[100];
|
||||
wxMenu *old_menu;
|
||||
wxMenu *file_menu;
|
||||
wxMenu *help_menu;
|
||||
wxMenu *option_menu = NULL;
|
||||
@@ -42,118 +45,126 @@ wxMenuBar *MakeMenu(int type, const char *dict_name)
|
||||
file_menu->Append(MENU_SPECTRUM, _("&Open..."));
|
||||
file_menu->Append(MENU_SPECTRUM2, _("O&pen2..."));
|
||||
// file_menu->Append(MENU_PROSODY, _T("&Prosody window"));
|
||||
if(type==0)
|
||||
if(type<=1)
|
||||
{
|
||||
}
|
||||
else
|
||||
if(type==1)
|
||||
{
|
||||
file_menu->Append(SPECTSEQ_SAVE, _("&Save"));
|
||||
file_menu->Append(SPECTSEQ_SAVEAS, _("Save &As..."));
|
||||
file_menu->Append(SPECTSEQ_SAVESELECT, _("Save Selection"));
|
||||
file_menu->Append(SPECTSEQ_SAVEPITCH, _T("Save Pitch &Envelope"));
|
||||
file_menu->Append(SPECTSEQ_CLOSE, _("&Close"));
|
||||
// file_menu->Append(MENU_CLOSE_ALL, _T("Close &All"));
|
||||
}
|
||||
else
|
||||
if(type==2)
|
||||
{
|
||||
file_menu->Append(SPECTSEQ_SAVE, _("&Save"));
|
||||
file_menu->Append(SPECTSEQ_SAVEAS, _("Save &As..."));
|
||||
// file_menu->Append(SPECTSEQ_SAVEPITCH, _T("Save Pitch &Envelope"));
|
||||
file_menu->Append(SPECTSEQ_SAVESELECT, _("Save Selection"));
|
||||
file_menu->Append(SPECTSEQ_SAVEPITCH, _T("Save Pitch &Envelope"));
|
||||
file_menu->Append(SPECTSEQ_CLOSE, _("&Close"));
|
||||
// file_menu->Append(MENU_CLOSE_ALL, _T("Close &All"));
|
||||
file_menu->Append(MENU_CLOSE_ALL, _T("Close &All"));
|
||||
}
|
||||
else
|
||||
if(type==3)
|
||||
{
|
||||
// file_menu->Append(SPECTSEQ_SAVE, _("&Save"));
|
||||
// file_menu->Append(SPECTSEQ_SAVEAS, _("Save &As..."));
|
||||
file_menu->Append(SPECTSEQ_CLOSE, _("&Close"));
|
||||
file_menu->Append(MENU_CLOSE_ALL, _T("Close &All"));
|
||||
}
|
||||
file_menu->Append(MENU_QUIT, _("&Quit"));
|
||||
|
||||
// SPEAK_MENU
|
||||
speak_menu = new wxMenu;
|
||||
speak_menu->Append(MENU_SPEAK_TRANSLATE, _("&Translate"));
|
||||
speak_menu->Append(MENU_SPEAK_RULES, _("Show &Rules"));
|
||||
speak_menu->Append(MENU_SPEAK_IPA, _("Show &IPA"));
|
||||
speak_menu->Append(MENU_SPEAK_TEXT, _("&Speak"));
|
||||
speak_menu->AppendSeparator();
|
||||
speak_menu->Append(MENU_SPEAK_FILE, _("Speak &file..."));
|
||||
speak_menu->Append(MENU_SPEAK_PAUSE, _("&Pause"));
|
||||
speak_menu->Append(MENU_SPEAK_STOP, _("St&op"));
|
||||
if(type==0)
|
||||
{
|
||||
// Initialization, make all the menus
|
||||
// SPEAK_MENU
|
||||
speak_menu = new wxMenu;
|
||||
speak_menu->Append(MENU_SPEAK_TRANSLATE, _("&Translate"));
|
||||
speak_menu->Append(MENU_SPEAK_RULES, _("Show &Rules"));
|
||||
speak_menu->Append(MENU_SPEAK_IPA, _("Show &IPA"));
|
||||
speak_menu->Append(MENU_SPEAK_TEXT, _("&Speak"));
|
||||
speak_menu->AppendSeparator();
|
||||
speak_menu->Append(MENU_SPEAK_FILE, _("Speak &file..."));
|
||||
speak_menu->Append(MENU_SPEAK_PAUSE, _("&Pause"));
|
||||
speak_menu->Append(MENU_SPEAK_STOP, _("St&op"));
|
||||
|
||||
// VOICE MENU
|
||||
voice_menu = new wxMenu;
|
||||
voice_menu->Append(MENU_SPEAK_VOICE, _("Select &Voice.."));
|
||||
voice_menu->Append(MENU_SPEAK_VOICE_VARIANT, _("Select Voice Va&riant..."));
|
||||
// VOICE MENU
|
||||
voice_menu = new wxMenu;
|
||||
voice_menu->Append(MENU_SPEAK_VOICE, _("Select &Voice.."));
|
||||
voice_menu->Append(MENU_SPEAK_VOICE_VARIANT, _("Select Voice Va&riant..."));
|
||||
|
||||
// DATA MENU
|
||||
data_menu = new wxMenu;
|
||||
data_menu->Append(MENU_COMPILE_PH, _("Compile &phoneme data"));
|
||||
data_menu->Append(MENU_COMPILE_DICT, _("Compile &dictionary"));
|
||||
data_menu->Append(MENU_COMPILE_DICT_DEBUG, _("Compile dictionary (debu&g)"));
|
||||
data_menu->AppendSeparator();
|
||||
data_menu->Append(MENU_COMPILE_MBROLA, _("Compile &mbrola phonemes list..."));
|
||||
data_menu->Append(MENU_COMPILE_INTONATION, _("Compile &intonation data"));
|
||||
data_menu->AppendSeparator();
|
||||
data_menu->Append(MENU_FORMAT_DICTIONARY, _("&Layout *_rules file"));
|
||||
data_menu->Append(MENU_SORT_DICTIONARY, _("&Sort *_rules file"));
|
||||
// DATA MENU
|
||||
data_menu = new wxMenu;
|
||||
data_menu->Append(MENU_COMPILE_PH, _("Compile &phoneme data"));
|
||||
data_menu->Append(MENU_COMPILE_DICT, _("Compile &dictionary"));
|
||||
data_menu->Append(MENU_COMPILE_DICT_DEBUG, _("Compile dictionary (debu&g)"));
|
||||
data_menu->AppendSeparator();
|
||||
data_menu->Append(MENU_COMPILE_MBROLA, _("Compile &mbrola phonemes list..."));
|
||||
data_menu->Append(MENU_COMPILE_INTONATION, _("Compile &intonation data"));
|
||||
data_menu->AppendSeparator();
|
||||
data_menu->Append(MENU_FORMAT_DICTIONARY, _("&Layout *_rules file"));
|
||||
data_menu->Append(MENU_SORT_DICTIONARY, _("&Sort *_rules file"));
|
||||
|
||||
sprintf(buf,"Compile &dictionary '%s'",dict_name);
|
||||
data_menu->SetLabel(MENU_COMPILE_DICT, wxString(buf,wxConvLocal));
|
||||
sprintf(buf,"&Layout '%s_rules' file",dict_name);
|
||||
data_menu->SetLabel(MENU_FORMAT_DICTIONARY, wxString(buf,wxConvLocal));
|
||||
sprintf(buf,"&Sort '%s_rules' file",dict_name);
|
||||
data_menu->SetLabel(MENU_SORT_DICTIONARY, wxString(buf,wxConvLocal));
|
||||
sprintf(buf,"Compile &dictionary '%s'",dict_name);
|
||||
data_menu->SetLabel(MENU_COMPILE_DICT, wxString(buf,wxConvLocal));
|
||||
sprintf(buf,"&Layout '%s_rules' file",dict_name);
|
||||
data_menu->SetLabel(MENU_FORMAT_DICTIONARY, wxString(buf,wxConvLocal));
|
||||
sprintf(buf,"&Sort '%s_rules' file",dict_name);
|
||||
data_menu->SetLabel(MENU_SORT_DICTIONARY, wxString(buf,wxConvLocal));
|
||||
|
||||
// OPTIONS MENU
|
||||
paths_menu = new wxMenu;
|
||||
paths_menu->Append(MENU_PATH0, _("Master phonemes file..."));
|
||||
paths_menu->Append(MENU_PATH1, _("Phoneme data source..."));
|
||||
paths_menu->Append(MENU_PATH2, _("Dictionary data source..."));
|
||||
paths_menu->Append(MENU_PATH3, _("Synthesized sound WAV file..."));
|
||||
paths_menu->AppendSeparator();
|
||||
paths_menu->Append(MENU_PATH4, _("Voice file to modify formant peaks..."));
|
||||
// OPTIONS MENU
|
||||
paths_menu = new wxMenu;
|
||||
paths_menu->Append(MENU_PATH0, _("Master phonemes file..."));
|
||||
paths_menu->Append(MENU_PATH1, _("Phoneme data source..."));
|
||||
paths_menu->Append(MENU_PATH2, _("Dictionary data source..."));
|
||||
paths_menu->Append(MENU_PATH3, _("Synthesized sound WAV file..."));
|
||||
paths_menu->AppendSeparator();
|
||||
paths_menu->Append(MENU_PATH4, _("Voice file to modify formant peaks..."));
|
||||
|
||||
option_menu = new wxMenu;
|
||||
option_menu->Append(MENU_PATHS, _("Set &paths"), paths_menu);
|
||||
option_menu->Append(MENU_OPT_SPEED, _("Speed..."));
|
||||
option_menu->Append(MENU_OPT_PUNCT, _("Speak punctiation"));
|
||||
option_menu->Append(MENU_OPT_SPELL, _("Speak character names"));
|
||||
option_menu = new wxMenu;
|
||||
option_menu->Append(MENU_PATHS, _("Set &paths"), paths_menu);
|
||||
option_menu->Append(MENU_OPT_SPEED, _("Speed..."));
|
||||
option_menu->Append(MENU_OPT_PUNCT, _("Speak punctiation"));
|
||||
option_menu->Append(MENU_OPT_SPELL, _("Speak character names"));
|
||||
|
||||
// TOOLS
|
||||
vowelchart_menu = new wxMenu;
|
||||
vowelchart_menu->Append(MENU_VOWELCHART1, _("From compiled phoneme data"));
|
||||
// vowelchart_menu->Append(MENU_VOWELCHART2, _("From list of formants..."));
|
||||
vowelchart_menu->Append(MENU_VOWELCHART3, _("From directory of vowel files..."));
|
||||
// TOOLS
|
||||
vowelchart_menu = new wxMenu;
|
||||
vowelchart_menu->Append(MENU_VOWELCHART1, _("From compiled phoneme data"));
|
||||
// vowelchart_menu->Append(MENU_VOWELCHART2, _("From list of formants..."));
|
||||
vowelchart_menu->Append(MENU_VOWELCHART3, _("From directory of vowel files..."));
|
||||
|
||||
lexicon_menu = new wxMenu;
|
||||
lexicon_menu->Append(MENU_LEXICON_RU, _("Russian"));
|
||||
lexicon_menu->Append(MENU_LEXICON_BG, _("Bulgarian"));
|
||||
lexicon_menu->Append(MENU_LEXICON_DE, _("German"));
|
||||
lexicon_menu->Append(MENU_LEXICON_IT, _("Italian"));
|
||||
// lexicon_menu->Append(MENU_LEXICON_TEST, _("Test"));
|
||||
lexicon_menu = new wxMenu;
|
||||
lexicon_menu->Append(MENU_LEXICON_RU, _("Russian"));
|
||||
lexicon_menu->Append(MENU_LEXICON_BG, _("Bulgarian"));
|
||||
lexicon_menu->Append(MENU_LEXICON_DE, _("German"));
|
||||
lexicon_menu->Append(MENU_LEXICON_IT, _("Italian"));
|
||||
// lexicon_menu->Append(MENU_LEXICON_TEST, _("Test"));
|
||||
|
||||
tools_menu = new wxMenu;
|
||||
tools_menu->Append(MENU_VOWELCHART, _("Make &Vowels Chart"), vowelchart_menu);
|
||||
// tools_menu->Append(MENU_LOAD_WAV, _T("Analyse WAV file"));
|
||||
tools_menu->Append(MENU_LEXICON, _("Process &Lexicon"), lexicon_menu);
|
||||
tools_menu->Append(MENU_TO_UTF8, _("Convert file to &UTF8..."));
|
||||
tools_menu->Append(MENU_COUNT_WORDS, _("Count word &frequencies..."));
|
||||
tools_menu->Append(MENU_TEST , _("Test (temporary)"));
|
||||
// tools_menu->Append(MENU_TEST2 , _T("Test2"));
|
||||
tools_menu = new wxMenu;
|
||||
tools_menu->Append(MENU_VOWELCHART, _("Make &Vowels Chart"), vowelchart_menu);
|
||||
// tools_menu->Append(MENU_LOAD_WAV, _T("Analyse WAV file"));
|
||||
tools_menu->Append(MENU_LEXICON, _("Process &Lexicon"), lexicon_menu);
|
||||
tools_menu->Append(MENU_TO_UTF8, _("Convert file to &UTF8..."));
|
||||
tools_menu->Append(MENU_COUNT_WORDS, _("Count word &frequencies..."));
|
||||
tools_menu->Append(MENU_TEST , _("Test (temporary)"));
|
||||
// tools_menu->Append(MENU_TEST2 , _T("Test2"));
|
||||
|
||||
// HELP MENU
|
||||
help_menu = new wxMenu;
|
||||
help_menu->Append(MENU_DOCS, _("eSpeak &Documentation"));
|
||||
help_menu->Append(MENU_ABOUT, _("&About"));
|
||||
// HELP MENU
|
||||
help_menu = new wxMenu;
|
||||
help_menu->Append(MENU_DOCS, _("eSpeak &Documentation"));
|
||||
help_menu->Append(MENU_ABOUT, _("&About"));
|
||||
|
||||
|
||||
wxMenuBar *menu_bar = new wxMenuBar;
|
||||
|
||||
menu_bar->Append(file_menu, _("&File"));
|
||||
menu_bar->Append(speak_menu, _("&Speak"));
|
||||
menu_bar->Append(voice_menu, _("&Voice"));
|
||||
menu_bar->Append(option_menu, _("&Options"));
|
||||
menu_bar->Append(tools_menu, _("&Tools"));
|
||||
menu_bar->Append(data_menu, _("&Compile"));
|
||||
menu_bar->Append(help_menu, _("&Help"));
|
||||
menu_bar = new wxMenuBar;
|
||||
|
||||
menu_bar->Append(file_menu, _("&File"));
|
||||
menu_bar->Append(speak_menu, _("&Speak"));
|
||||
menu_bar->Append(voice_menu, _("&Voice"));
|
||||
menu_bar->Append(option_menu, _("&Options"));
|
||||
menu_bar->Append(tools_menu, _("&Tools"));
|
||||
menu_bar->Append(data_menu, _("&Compile"));
|
||||
menu_bar->Append(help_menu, _("&Help"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just replace the File menu
|
||||
old_menu = menu_bar->Replace(0, file_menu, _("&File"));
|
||||
delete old_menu;
|
||||
}
|
||||
return(menu_bar);
|
||||
} // end of MakeMenu
|
||||
|
||||
|
||||
+220
-59
@@ -590,12 +590,13 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
int n_bytes;
|
||||
int letter;
|
||||
int len;
|
||||
int ix;
|
||||
int save_option_phonemes;
|
||||
char *p2;
|
||||
char *pbuf;
|
||||
char capital[20];
|
||||
char ph_buf[60];
|
||||
char ph_buf2[60];
|
||||
char ph_buf[80];
|
||||
char ph_buf2[80];
|
||||
char hexbuf[6];
|
||||
|
||||
ph_buf[0] = 0;
|
||||
@@ -646,22 +647,49 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
|
||||
if(ph_buf[0] == 0)
|
||||
{
|
||||
// character name not found
|
||||
if(iswalpha(letter))
|
||||
Lookup(tr, "_?A", ph_buf);
|
||||
|
||||
if((ph_buf[0]==0) && !iswspace(letter))
|
||||
Lookup(tr, "_??", ph_buf);
|
||||
|
||||
if(ph_buf[0] != 0)
|
||||
if((letter >= 0x2800) && (letter <= 0x28ff))
|
||||
{
|
||||
// speak the hexadecimal number of the character code
|
||||
sprintf(hexbuf,"%x",letter);
|
||||
pbuf = ph_buf;
|
||||
for(p2 = hexbuf; *p2 != 0; p2++)
|
||||
// braille dots symbol
|
||||
Lookup(tr, "_braille", ph_buf);
|
||||
if(ph_buf[0] == 0)
|
||||
{
|
||||
pbuf += strlen(pbuf);
|
||||
*pbuf++ = phonPAUSE_VSHORT;
|
||||
LookupLetter(tr, *p2, 0, pbuf, 1);
|
||||
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(tr, '1'+ix, 0, pbuf, 1);
|
||||
pbuf += strlen(pbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ph_buf[0]== 0)
|
||||
{
|
||||
if(iswalpha(letter))
|
||||
Lookup(tr, "_?A", ph_buf);
|
||||
|
||||
if((ph_buf[0]==0) && !iswspace(letter))
|
||||
Lookup(tr, "_??", ph_buf);
|
||||
|
||||
if(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);
|
||||
*pbuf++ = phonPAUSE_VSHORT;
|
||||
LookupLetter(tr, *p2, 0, pbuf, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -956,27 +984,46 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
|
||||
|
||||
static const char *M_Variant(int value)
|
||||
{//====================================
|
||||
// returns M, or perhaps MA for some cases
|
||||
// returns M, or perhaps MA or MB for some cases
|
||||
|
||||
if((translator->langopts.numbers2 & 0x100) && (value >= 2) && (value <= 4))
|
||||
return("0MA"); // Czech, Slovak
|
||||
else
|
||||
if(((value % 100) < 10) || ((value % 100) > 20)) // but not teens, 10 to 19
|
||||
int teens = 0;
|
||||
|
||||
if(((value % 100) > 10) && ((value % 100) < 20))
|
||||
teens = 1;
|
||||
|
||||
switch((translator->langopts.numbers2 >> 6) & 0x7)
|
||||
{
|
||||
if ((translator->langopts.numbers2 & 0x40) &&
|
||||
((value % 10)>=2) &&
|
||||
((value % 10)<=4))
|
||||
{
|
||||
// for Polish language - two forms of plural!
|
||||
case 1: // lang=ru use singular for xx1 except for x11
|
||||
if((teens == 0) && ((value % 10) == 1))
|
||||
return("1M");
|
||||
break;
|
||||
|
||||
case 2: // lang=cs,sk
|
||||
if((value >= 2) && (value <= 4))
|
||||
return("0MA");
|
||||
}
|
||||
break;
|
||||
|
||||
if((translator->langopts.numbers2 & 0x80) &&
|
||||
((value % 10)==1))
|
||||
case 3: // lang=pl
|
||||
if((teens == 0) && (((value % 10) >= 2) && ((value % 10) <= 4)))
|
||||
return("0MA");
|
||||
break;
|
||||
|
||||
case 4: // lang=lt
|
||||
if((teens == 1) || ((value % 10) == 0))
|
||||
return("0MB");
|
||||
if((value % 10) == 1)
|
||||
return("0MA");
|
||||
break;
|
||||
|
||||
case 5: // lang=bs,hr,sr
|
||||
if(teens == 0)
|
||||
{
|
||||
return("1MA");
|
||||
if((value % 10) == 1)
|
||||
return("1M");
|
||||
if(((value % 10) >= 2) && ((value % 10) <= 4))
|
||||
return("0MA");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return("0M");
|
||||
}
|
||||
@@ -1090,8 +1137,8 @@ static int LookupThousands(Translator *tr, int value, int thousandplex, int thou
|
||||
} // end f LookupThousands
|
||||
|
||||
|
||||
static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
{//========================================================================
|
||||
static int LookupNum2(Translator *tr, int value, const int control, char *ph_out)
|
||||
{//=============================================================================
|
||||
// Lookup a 2 digit number
|
||||
// control bit 0: ordinal number
|
||||
// control bit 1: final tens and units (not number of thousands) (use special form of '1', LANG=de "eins")
|
||||
@@ -1099,11 +1146,13 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
// control bit 3: use feminine form of '2' (for thousands
|
||||
// control bit 4: speak zero tens
|
||||
// control bit 5: variant of ordinal number (lang=hu)
|
||||
// bit 8 followed by decimal fraction
|
||||
|
||||
int found;
|
||||
int ix;
|
||||
int units;
|
||||
int tens;
|
||||
int is_ordinal;
|
||||
int used_and=0;
|
||||
int found_ordinal = 0;
|
||||
int next_phtype;
|
||||
@@ -1128,6 +1177,8 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
ord_type = 'q';
|
||||
}
|
||||
|
||||
is_ordinal = control & 1;
|
||||
|
||||
if((control & 2) && (n_digit_lookup == 2))
|
||||
{
|
||||
// pronunciation of the final 2 digits has already been found
|
||||
@@ -1140,11 +1191,12 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
// is there a special pronunciation for this 2-digit number
|
||||
if(control & 8)
|
||||
{
|
||||
// is there a feminine form?
|
||||
sprintf(string,"_%df",value);
|
||||
found = Lookup(tr, string, ph_digits);
|
||||
}
|
||||
else
|
||||
if(control & 1)
|
||||
if(is_ordinal)
|
||||
{
|
||||
strcpy(ph_ordinal, ph_ordinal2);
|
||||
|
||||
@@ -1182,8 +1234,15 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
|
||||
if(!found)
|
||||
{
|
||||
sprintf(string,"_%d",value);
|
||||
found = Lookup(tr, string, ph_digits);
|
||||
if((is_ordinal) && (tr->langopts.numbers2 & NUM2_NO_TEEN_ORDINALS))
|
||||
{
|
||||
// don't use numbers 10-99 to make ordinals, always use _1Xo etc (lang=pt)
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(string,"_%d",value);
|
||||
found = Lookup(tr, string, ph_digits);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1204,7 +1263,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
else
|
||||
{
|
||||
|
||||
if((control & 1) &&
|
||||
if((is_ordinal) &&
|
||||
((units == 0) || (tr->langopts.numbers & NUM_SWAP_TENS) || (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL)))
|
||||
{
|
||||
sprintf(string,"_%dX%c", tens, ord_type);
|
||||
@@ -1253,7 +1312,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
sprintf(string,"_%df",units);
|
||||
found = Lookup(tr, string, ph_digits);
|
||||
}
|
||||
if((control & 1) && ((tr->langopts.numbers & NUM_SWAP_TENS) == 0))
|
||||
if((is_ordinal) && ((tr->langopts.numbers & NUM_SWAP_TENS) == 0))
|
||||
{
|
||||
// ordinal
|
||||
sprintf(string,"_%d%c",units,ord_type);
|
||||
@@ -1288,7 +1347,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
}
|
||||
}
|
||||
|
||||
if((control & 1) && (found_ordinal == 0) && (ph_ordinal[0] == 0))
|
||||
if((is_ordinal) && (found_ordinal == 0) && (ph_ordinal[0] == 0))
|
||||
{
|
||||
if((value >= 20) && (((value % 10) == 0) || (tr->langopts.numbers & NUM_SWAP_TENS)))
|
||||
Lookup(tr, "_ord20", ph_ordinal);
|
||||
@@ -1300,7 +1359,7 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
{
|
||||
Lookup(tr, "_0and", ph_and);
|
||||
|
||||
if((control & 1) && (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL))
|
||||
if((is_ordinal) && (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL))
|
||||
ph_and[0] = 0;
|
||||
|
||||
if(tr->langopts.numbers & NUM_SWAP_TENS)
|
||||
@@ -1327,6 +1386,22 @@ static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
|
||||
}
|
||||
}
|
||||
|
||||
if(tr->langopts.numbers & NUM_SINGLE_STRESS_L)
|
||||
{
|
||||
// only one primary stress, on the first part (tens)
|
||||
found = 0;
|
||||
for(ix=0; ix < (signed)strlen(ph_out); ix++)
|
||||
{
|
||||
if(ph_out[ix] == phonSTRESS_P)
|
||||
{
|
||||
if(found)
|
||||
ph_out[ix] = phonSTRESS_3;
|
||||
else
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if(tr->langopts.numbers & NUM_SINGLE_STRESS)
|
||||
{
|
||||
// only one primary stress
|
||||
@@ -1352,6 +1427,7 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
// control bit 0, previous thousands
|
||||
// bit 1, ordinal number
|
||||
// bit 5 variant form of ordinal number
|
||||
// bit 8 followed by decimal fraction
|
||||
int found;
|
||||
int hundreds;
|
||||
int tensunits;
|
||||
@@ -1359,6 +1435,7 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
int ix;
|
||||
int exact;
|
||||
int ordinal;
|
||||
int tplex;
|
||||
int say_zero_hundred=0;
|
||||
char string[12]; // for looking up entries in **_list
|
||||
char buf1[100];
|
||||
@@ -1418,10 +1495,16 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
if ((value % 1000) == 0)
|
||||
exact = 1;
|
||||
|
||||
if(LookupThousands(tr, hundreds / 10, thousandplex+1, exact | ordinal, ph_10T) == 0)
|
||||
tplex = thousandplex+1;
|
||||
if(tr->langopts.numbers2 & NUM2_MYRIADS)
|
||||
{
|
||||
tplex = 0;
|
||||
}
|
||||
|
||||
if(LookupThousands(tr, hundreds / 10, tplex, exact | ordinal, ph_10T) == 0)
|
||||
{
|
||||
x = 0;
|
||||
if(tr->langopts.numbers2 & (1 << (thousandplex+1)))
|
||||
if(tr->langopts.numbers2 & (1 << tplex))
|
||||
x = 8; // use variant (feminine) for before thousands and millions
|
||||
LookupNum2(tr, hundreds/10, x, ph_digits);
|
||||
}
|
||||
@@ -1503,17 +1586,24 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
ph_hundred_and[0] = 0;
|
||||
if(tensunits > 0)
|
||||
{
|
||||
if((value > 100) || ((control & 1) && (thousandplex==0)))
|
||||
if((control & 2) && (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL))
|
||||
{
|
||||
if((tr->langopts.numbers & NUM_HUNDRED_AND) || ((tr->langopts.numbers & NUM_HUNDRED_AND_DIGIT) && (tensunits < 10)))
|
||||
// Don't use "and" if we apply ordinal to both hundreds and units
|
||||
}
|
||||
else
|
||||
{
|
||||
if((value > 100) || ((control & 1) && (thousandplex==0)))
|
||||
{
|
||||
if((tr->langopts.numbers & NUM_HUNDRED_AND) || ((tr->langopts.numbers & NUM_HUNDRED_AND_DIGIT) && (tensunits < 10)))
|
||||
{
|
||||
Lookup(tr, "_0and", ph_hundred_and);
|
||||
}
|
||||
}
|
||||
if((tr->langopts.numbers & NUM_THOUSAND_AND) && (hundreds == 0) && ((control & 1) || (ph_thousands[0] != 0)))
|
||||
{
|
||||
Lookup(tr, "_0and", ph_hundred_and);
|
||||
}
|
||||
}
|
||||
if((tr->langopts.numbers & NUM_THOUSAND_AND) && (hundreds == 0) && ((control & 1) || (ph_thousands[0] != 0)))
|
||||
{
|
||||
Lookup(tr, "_0and", ph_hundred_and);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1538,7 +1628,7 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
x = 8; // use variant (feminine) for before thousands and millions
|
||||
}
|
||||
|
||||
if(LookupNum2(tr, tensunits, x, buf2) != 0)
|
||||
if(LookupNum2(tr, tensunits, x | control & 0x100, buf2) != 0)
|
||||
{
|
||||
if(tr->langopts.numbers & NUM_SINGLE_AND)
|
||||
ph_hundred_and[0] = 0; // don't put 'and' after 'hundred' if there's 'and' between tens and units
|
||||
@@ -1561,6 +1651,23 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null
|
||||
} // end of LookupNum3
|
||||
|
||||
|
||||
bool CheckThousandsGroup(char *word, int group_len)
|
||||
{//================================================
|
||||
// Is this a group of 3 digits which looks like a thousands group?
|
||||
int ix;
|
||||
|
||||
if(isdigit(word[group_len]) || isdigit(-1))
|
||||
return(false);
|
||||
|
||||
for(ix=0; ix < group_len; ix++)
|
||||
{
|
||||
if(!isdigit(word[ix]))
|
||||
return(false);
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned int *flags, WORD_TAB *wtab, int control)
|
||||
{//=====================================================================================================================
|
||||
// Number translation with various options
|
||||
@@ -1586,6 +1693,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
int decimal_mode;
|
||||
int suffix_ix;
|
||||
int skipwords = 0;
|
||||
int group_len;
|
||||
char *p;
|
||||
char string[32]; // for looking up entries in **_list
|
||||
char buf1[100];
|
||||
@@ -1608,8 +1716,12 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
n_digits = ix;
|
||||
value = this_value = atoi(word);
|
||||
|
||||
group_len = 3;
|
||||
if(tr->langopts.numbers2 & NUM2_MYRIADS)
|
||||
group_len = 4;
|
||||
|
||||
// is there a previous thousands part (as a previous "word") ?
|
||||
if((n_digits == 3) && (word[-2] == tr->langopts.thousands_sep) && isdigit(word[-3]))
|
||||
if((n_digits == group_len) && (word[-2] == tr->langopts.thousands_sep) && isdigit(word[-3]))
|
||||
{
|
||||
prev_thousands = 1;
|
||||
}
|
||||
@@ -1723,14 +1835,19 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
// a "thousand"/"million" suffix to this one
|
||||
digix = n_digits + thousands_inc;
|
||||
|
||||
while(((wtab[thousandplex+1].flags & FLAG_MULTIPLE_SPACES) == 0) &&
|
||||
isdigit(word[digix]) && isdigit(word[digix+1]) && isdigit(word[digix+2]) && !isdigit(word[digix+3]) && !isdigit(word[digix-1]))
|
||||
while(((wtab[thousandplex+1].flags & FLAG_MULTIPLE_SPACES) == 0) && CheckThousandsGroup(&word[digix], group_len))
|
||||
{
|
||||
if((word[digix] != '0') || (word[digix+1] != '0') || (word[digix+2] != '0'))
|
||||
thousands_exact = 0;
|
||||
for(ix=0; ix<group_len; ix++)
|
||||
{
|
||||
if(word[digix+ix] != '0')
|
||||
{
|
||||
thousands_exact = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
thousandplex++;
|
||||
digix += 3;
|
||||
digix += group_len;
|
||||
if((word[digix] == tr->langopts.thousands_sep) || ((tr->langopts.numbers & NUM_ALLOW_SPACE) && (word[digix] == ' ')))
|
||||
{
|
||||
suffix_ix = digix+2;
|
||||
@@ -1759,14 +1876,15 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
{
|
||||
// this "word" ends with a decimal point
|
||||
Lookup(tr, "_dpt", ph_append);
|
||||
decimal_point = 1;
|
||||
decimal_point = 0x100;
|
||||
}
|
||||
else
|
||||
if(suppress_null == 0)
|
||||
{
|
||||
if(thousands_inc > 0)
|
||||
{
|
||||
if((thousandplex > 0) && (value < 1000))
|
||||
if(thousandplex > 0)
|
||||
// if((thousandplex > 0) && (value < 1000))
|
||||
{
|
||||
if((suppress_null == 0) && (LookupThousands(tr,value,thousandplex, thousands_exact, ph_append)))
|
||||
{
|
||||
@@ -1813,15 +1931,46 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
// if((buf_digit_lookup[0] == 0) && (*p != '0') && (dot_ordinal==0))
|
||||
if((buf_digit_lookup[0] == 0) && (*p != '0'))
|
||||
{
|
||||
// LANG=hu ?
|
||||
// not found, lookup only the last digit (?? but not if dot-ordinal has been found)
|
||||
if(LookupDictList(tr, &p, buf_digit_lookup, flags, FLAG_SUFX, wtab)) // don't match '0', or entries with $only
|
||||
{
|
||||
n_digit_lookup = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(prev_thousands == 0)
|
||||
{
|
||||
if((decimal_point == 0) && (ordinal == 0))
|
||||
{
|
||||
// Look for special pronunciation for this number in isolation (LANG=kl)
|
||||
sprintf(string, "_%dn", value);
|
||||
if(Lookup(tr, string, ph_out))
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(tr->langopts.numbers2 & NUM2_PERCENT_BEFORE)
|
||||
{
|
||||
// LANG=si, say "percent" before the number
|
||||
p2 = word;
|
||||
while((*p2 != ' ') && (*p2 != 0))
|
||||
{
|
||||
p2++;
|
||||
}
|
||||
if(p2[1] == '%')
|
||||
{
|
||||
Lookup(tr, "%", ph_out);
|
||||
ph_out += strlen(ph_out);
|
||||
p2[1] = ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LookupNum3(tr, value, ph_buf, suppress_null, thousandplex, prev_thousands | ordinal);
|
||||
LookupNum3(tr, value, ph_buf, suppress_null, thousandplex, prev_thousands | ordinal | decimal_point);
|
||||
if((thousandplex > 0) && (tr->langopts.numbers2 & 0x200))
|
||||
sprintf(ph_out,"%s%s%s%s",ph_zeros,ph_append,ph_buf2,ph_buf); // say "thousands" before its number
|
||||
else
|
||||
@@ -1889,6 +2038,17 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
|
||||
n_digits += decimal_count;
|
||||
}
|
||||
break;
|
||||
|
||||
case NUM_DFRACTION_7:
|
||||
// alternative form of decimal fraction digits, except the final digit
|
||||
while(decimal_count-- > 1)
|
||||
{
|
||||
sprintf(string,"_%cd", word[n_digits]);
|
||||
if(Lookup(tr, string, buf1) == 0)
|
||||
break;
|
||||
n_digits++;
|
||||
strcat(ph_out, buf1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1944,8 +2104,9 @@ int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *fla
|
||||
return(0); // speak digits individually
|
||||
|
||||
if(tr->langopts.numbers != 0)
|
||||
{
|
||||
return(TranslateNumber_1(tr, word1, ph_out, flags, wtab, control));
|
||||
|
||||
}
|
||||
return(0);
|
||||
} // end of TranslateNumber
|
||||
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ typedef struct {
|
||||
int LookupPhonemeString(const char *string);
|
||||
int PhonemeCode(unsigned int mnem);
|
||||
|
||||
char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme);
|
||||
const char *EncodePhonemes(const char *p, char *outptr, unsigned char *bad_phoneme);
|
||||
void DecodePhonemes(const char *inptr, char *outptr);
|
||||
|
||||
extern const char *WordToString(unsigned int word);
|
||||
|
||||
+14
-12
@@ -63,24 +63,24 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST *plist_out)
|
||||
{
|
||||
if(ix < (n_ph_list2 -1))
|
||||
next = phoneme_tab[ph_list2[ix+1].phcode];
|
||||
|
||||
|
||||
word_end = 0;
|
||||
if((plist2+1)->sourceix || ((next != 0) && (next->type == phPAUSE)))
|
||||
word_end = 1; // this phoneme is the end of a word
|
||||
|
||||
|
||||
// check whether a Voice has specified that we should replace this phoneme
|
||||
for(k=0; k<n_replace_phonemes; k++)
|
||||
{
|
||||
if(plist2->phcode == replace_phonemes[k].old_ph)
|
||||
{
|
||||
replace_flags = replace_phonemes[k].type;
|
||||
|
||||
|
||||
if((replace_flags & 1) && (word_end == 0))
|
||||
continue; // this replacement only occurs at the end of a word
|
||||
|
||||
|
||||
if((replace_flags & 2) && ((plist2->stresslevel & 0x7) > 3))
|
||||
continue; // this replacement doesn't occur in stressed syllables
|
||||
|
||||
|
||||
// substitute the replacement phoneme
|
||||
plist2->phcode = replace_phonemes[k].new_ph;
|
||||
if((plist2->stresslevel > 1) && (phoneme_tab[plist2->phcode]->phflags & phUNSTRESSED))
|
||||
@@ -88,7 +88,7 @@ static int SubstitutePhonemes(Translator *tr, PHONEME_LIST *plist_out)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(plist2->phcode == 0)
|
||||
{
|
||||
continue; // phoneme has been replaced by NULL, so don't copy it
|
||||
@@ -131,7 +131,9 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
PHONEME_LIST ph_list3[N_PHONEME_LIST];
|
||||
|
||||
PHONEME_LIST2 *plist2;
|
||||
WORD_PH_DATA worddata;
|
||||
|
||||
memset(&worddata, 0, sizeof(worddata));
|
||||
plist2 = ph_list2;
|
||||
phlist = phoneme_list;
|
||||
end_sourceix = plist2[n_ph_list2-1].sourceix;
|
||||
@@ -308,7 +310,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
next = phoneme_tab[plist3->phcode]; // this phoneme, i.e. after the insert
|
||||
|
||||
// re-use the previous entry for the inserted phoneme.
|
||||
// That's OK because we don't look backwards from plist3
|
||||
// That's OK because we don't look backwards from plist3 *** but CountVowelPosiion() and isAfterStress does !!!
|
||||
j--;
|
||||
plist3 = plist3_inserted = &ph_list3[j];
|
||||
if(j > 0)
|
||||
@@ -339,7 +341,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
|
||||
if(ph == NULL) continue;
|
||||
|
||||
InterpretPhoneme(tr, 0x100, plist3, &phdata);
|
||||
InterpretPhoneme(tr, 0x100, plist3, &phdata, &worddata);
|
||||
|
||||
if((alternative = phdata.pd_param[pd_INSERTPHONEME]) > 0)
|
||||
{
|
||||
@@ -363,7 +365,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
|
||||
// re-interpret the changed phoneme
|
||||
// But it doesn't obey a second ChangePhoneme()
|
||||
InterpretPhoneme(tr, 0x100, plist3, &phdata);
|
||||
InterpretPhoneme(tr, 0x100, plist3, &phdata, &worddata);
|
||||
}
|
||||
|
||||
if((alternative = phdata.pd_param[pd_CHANGEPHONEME]) > 0)
|
||||
@@ -388,7 +390,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
|
||||
// re-interpret the changed phoneme
|
||||
// But it doesn't obey a second ChangePhoneme()
|
||||
InterpretPhoneme(tr, 0x100, plist3, &phdata);
|
||||
InterpretPhoneme(tr, 0x100, plist3, &phdata, &worddata);
|
||||
}
|
||||
|
||||
if(ph->type == phVOWEL)
|
||||
@@ -478,7 +480,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
else
|
||||
insert_ph = phonPAUSE_VSHORT;
|
||||
}
|
||||
|
||||
|
||||
if((ph->type == phVOWEL) && ((x = tr->langopts.vowel_pause & 0x03) != 0))
|
||||
{
|
||||
// adjacent vowels over a word boundary
|
||||
@@ -487,7 +489,7 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
else
|
||||
insert_ph = phonPAUSE_VSHORT;
|
||||
}
|
||||
|
||||
|
||||
if(((plist3+1)->stresslevel >= 4) && (tr->langopts.vowel_pause & 0x100))
|
||||
{
|
||||
// pause before a words which starts with a stressed vowel
|
||||
|
||||
-466
@@ -1,466 +0,0 @@
|
||||
// NOTE: Copy this file to portaudio.h in order to compile with V18 portaudio
|
||||
|
||||
|
||||
#ifndef PORT_AUDIO_H
|
||||
#define PORT_AUDIO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* $Id: portaudio.h,v 1.5 2002/03/26 18:04:22 philburk Exp $
|
||||
* PortAudio Portable Real-Time Audio Library
|
||||
* PortAudio API Header File
|
||||
* Latest version available at: http://www.audiomulch.com/portaudio/
|
||||
*
|
||||
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files
|
||||
* (the "Software"), to deal in the Software without restriction,
|
||||
* including without limitation the rights to use, copy, modify, merge,
|
||||
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* Any person wishing to distribute modifications to the Software is
|
||||
* requested to send the modifications to the original developer so that
|
||||
* they can be incorporated into the canonical version.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
typedef int PaError;
|
||||
typedef enum {
|
||||
paNoError = 0,
|
||||
|
||||
paHostError = -10000,
|
||||
paInvalidChannelCount,
|
||||
paInvalidSampleRate,
|
||||
paInvalidDeviceId,
|
||||
paInvalidFlag,
|
||||
paSampleFormatNotSupported,
|
||||
paBadIODeviceCombination,
|
||||
paInsufficientMemory,
|
||||
paBufferTooBig,
|
||||
paBufferTooSmall,
|
||||
paNullCallback,
|
||||
paBadStreamPtr,
|
||||
paTimedOut,
|
||||
paInternalError,
|
||||
paDeviceUnavailable
|
||||
} PaErrorNum;
|
||||
|
||||
/*
|
||||
Pa_Initialize() is the library initialisation function - call this before
|
||||
using the library.
|
||||
|
||||
*/
|
||||
|
||||
PaError Pa_Initialize( void );
|
||||
|
||||
/*
|
||||
Pa_Terminate() is the library termination function - call this after
|
||||
using the library.
|
||||
|
||||
*/
|
||||
|
||||
PaError Pa_Terminate( void );
|
||||
|
||||
/*
|
||||
Pa_GetHostError() returns a host specific error code.
|
||||
This can be called after receiving a PortAudio error code of paHostError.
|
||||
|
||||
*/
|
||||
|
||||
long Pa_GetHostError( void );
|
||||
|
||||
/*
|
||||
Pa_GetErrorText() translates the supplied PortAudio error number
|
||||
into a human readable message.
|
||||
|
||||
*/
|
||||
|
||||
const char *Pa_GetErrorText( PaError errnum );
|
||||
|
||||
/*
|
||||
Sample formats
|
||||
|
||||
These are formats used to pass sound data between the callback and the
|
||||
stream. Each device has a "native" format which may be used when optimum
|
||||
efficiency or control over conversion is required.
|
||||
|
||||
Formats marked "always available" are supported (emulated) by all
|
||||
PortAudio implementations.
|
||||
|
||||
The floating point representation (paFloat32) uses +1.0 and -1.0 as the
|
||||
maximum and minimum respectively.
|
||||
|
||||
paUInt8 is an unsigned 8 bit format where 128 is considered "ground"
|
||||
|
||||
*/
|
||||
|
||||
typedef unsigned long PaSampleFormat;
|
||||
#define paFloat32 ((PaSampleFormat) (1<<0)) /*always available*/
|
||||
#define paInt16 ((PaSampleFormat) (1<<1)) /*always available*/
|
||||
#define paInt32 ((PaSampleFormat) (1<<2)) /*always available*/
|
||||
#define paInt24 ((PaSampleFormat) (1<<3))
|
||||
#define paPackedInt24 ((PaSampleFormat) (1<<4))
|
||||
#define paInt8 ((PaSampleFormat) (1<<5))
|
||||
#define paUInt8 ((PaSampleFormat) (1<<6))
|
||||
#define paCustomFormat ((PaSampleFormat) (1<<16))
|
||||
|
||||
/*
|
||||
Device enumeration mechanism.
|
||||
|
||||
Device ids range from 0 to Pa_CountDevices()-1.
|
||||
|
||||
Devices may support input, output or both.
|
||||
|
||||
*/
|
||||
|
||||
typedef int PaDeviceID;
|
||||
#define paNoDevice -1
|
||||
|
||||
int Pa_CountDevices( void );
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int structVersion;
|
||||
const char *name;
|
||||
int maxInputChannels;
|
||||
int maxOutputChannels;
|
||||
/* Number of discrete rates, or -1 if range supported. */
|
||||
int numSampleRates;
|
||||
/* Array of supported sample rates, or {min,max} if range supported. */
|
||||
const double *sampleRates;
|
||||
PaSampleFormat nativeSampleFormats;
|
||||
}
|
||||
PaDeviceInfo;
|
||||
|
||||
/*
|
||||
Pa_GetDefaultInputDeviceID(), Pa_GetDefaultOutputDeviceID() return the
|
||||
default device ids for input and output respectively, or paNoDevice if
|
||||
no device is available.
|
||||
The result can be passed to Pa_OpenStream().
|
||||
|
||||
On the PC, the user can specify a default device by
|
||||
setting an environment variable. For example, to use device #1.
|
||||
|
||||
set PA_RECOMMENDED_OUTPUT_DEVICE=1
|
||||
|
||||
The user should first determine the available device ids by using
|
||||
the supplied application "pa_devs".
|
||||
|
||||
*/
|
||||
|
||||
PaDeviceID Pa_GetDefaultInputDeviceID( void );
|
||||
PaDeviceID Pa_GetDefaultOutputDeviceID( void );
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Pa_GetDeviceInfo() returns a pointer to an immutable PaDeviceInfo structure
|
||||
for the device specified.
|
||||
If the device parameter is out of range the function returns NULL.
|
||||
|
||||
PortAudio manages the memory referenced by the returned pointer, the client
|
||||
must not manipulate or free the memory. The pointer is only guaranteed to be
|
||||
valid between calls to Pa_Initialize() and Pa_Terminate().
|
||||
|
||||
*/
|
||||
|
||||
const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceID device );
|
||||
|
||||
/*
|
||||
PaTimestamp is used to represent a continuous sample clock with arbitrary
|
||||
start time that can be used for syncronization. The type is used for the
|
||||
outTime argument to the PortAudioCallback and as the result of Pa_StreamTime()
|
||||
|
||||
*/
|
||||
|
||||
typedef double PaTimestamp;
|
||||
|
||||
/*
|
||||
PortAudioCallback is implemented by PortAudio clients.
|
||||
|
||||
inputBuffer and outputBuffer are arrays of interleaved samples,
|
||||
the format, packing and number of channels used by the buffers are
|
||||
determined by parameters to Pa_OpenStream() (see below).
|
||||
|
||||
framesPerBuffer is the number of sample frames to be processed by the callback.
|
||||
|
||||
outTime is the time in samples when the buffer(s) processed by
|
||||
this callback will begin being played at the audio output.
|
||||
See also Pa_StreamTime()
|
||||
|
||||
userData is the value of a user supplied pointer passed to Pa_OpenStream()
|
||||
intended for storing synthesis data etc.
|
||||
|
||||
return value:
|
||||
The callback can return a non-zero value to stop the stream. This may be
|
||||
useful in applications such as soundfile players where a specific duration
|
||||
of output is required. However, it is not necessary to utilise this mechanism
|
||||
as StopStream() will also terminate the stream. A callback returning a
|
||||
non-zero value must fill the entire outputBuffer.
|
||||
|
||||
NOTE: None of the other stream functions may be called from within the
|
||||
callback function except for Pa_GetCPULoad().
|
||||
|
||||
*/
|
||||
|
||||
typedef int (PortAudioCallback)(
|
||||
void *inputBuffer, void *outputBuffer,
|
||||
unsigned long framesPerBuffer,
|
||||
PaTimestamp outTime, void *userData );
|
||||
|
||||
|
||||
/*
|
||||
Stream flags
|
||||
|
||||
These flags may be supplied (ored together) in the streamFlags argument to
|
||||
the Pa_OpenStream() function.
|
||||
|
||||
*/
|
||||
|
||||
#define paNoFlag (0)
|
||||
#define paClipOff (1<<0) /* disable default clipping of out of range samples */
|
||||
#define paDitherOff (1<<1) /* disable default dithering */
|
||||
#define paPlatformSpecificFlags (0x00010000)
|
||||
typedef unsigned long PaStreamFlags;
|
||||
|
||||
/*
|
||||
A single PortAudioStream provides multiple channels of real-time
|
||||
input and output audio streaming to a client application.
|
||||
Pointers to PortAudioStream objects are passed between PortAudio functions.
|
||||
*/
|
||||
|
||||
typedef void PortAudioStream;
|
||||
#define PaStream PortAudioStream
|
||||
|
||||
/*
|
||||
Pa_OpenStream() opens a stream for either input, output or both.
|
||||
|
||||
stream is the address of a PortAudioStream pointer which will receive
|
||||
a pointer to the newly opened stream.
|
||||
|
||||
inputDevice is the id of the device used for input (see PaDeviceID above.)
|
||||
inputDevice may be paNoDevice to indicate that an input device is not required.
|
||||
|
||||
numInputChannels is the number of channels of sound to be delivered to the
|
||||
callback. It can range from 1 to the value of maxInputChannels in the
|
||||
PaDeviceInfo record for the device specified by the inputDevice parameter.
|
||||
If inputDevice is paNoDevice numInputChannels is ignored.
|
||||
|
||||
inputSampleFormat is the sample format of inputBuffer provided to the callback
|
||||
function. inputSampleFormat may be any of the formats described by the
|
||||
PaSampleFormat enumeration (see above). PortAudio guarantees support for
|
||||
the device's native formats (nativeSampleFormats in the device info record)
|
||||
and additionally 16 and 32 bit integer and 32 bit floating point formats.
|
||||
Support for other formats is implementation defined.
|
||||
|
||||
inputDriverInfo is a pointer to an optional driver specific data structure
|
||||
containing additional information for device setup or stream processing.
|
||||
inputDriverInfo is never required for correct operation. If not used
|
||||
inputDriverInfo should be NULL.
|
||||
|
||||
outputDevice is the id of the device used for output (see PaDeviceID above.)
|
||||
outputDevice may be paNoDevice to indicate that an output device is not required.
|
||||
|
||||
numOutputChannels is the number of channels of sound to be supplied by the
|
||||
callback. See the definition of numInputChannels above for more details.
|
||||
|
||||
outputSampleFormat is the sample format of the outputBuffer filled by the
|
||||
callback function. See the definition of inputSampleFormat above for more
|
||||
details.
|
||||
|
||||
outputDriverInfo is a pointer to an optional driver specific data structure
|
||||
containing additional information for device setup or stream processing.
|
||||
outputDriverInfo is never required for correct operation. If not used
|
||||
outputDriverInfo should be NULL.
|
||||
|
||||
sampleRate is the desired sampleRate. For full-duplex streams it is the
|
||||
sample rate for both input and output
|
||||
|
||||
framesPerBuffer is the length in sample frames of all internal sample buffers
|
||||
used for communication with platform specific audio routines. Wherever
|
||||
possible this corresponds to the framesPerBuffer parameter passed to the
|
||||
callback function.
|
||||
|
||||
numberOfBuffers is the number of buffers used for multibuffered communication
|
||||
with the platform specific audio routines. If you pass zero, then an optimum
|
||||
value will be chosen for you internally. This parameter is provided only
|
||||
as a guide - and does not imply that an implementation must use multibuffered
|
||||
i/o when reliable double buffering is available (such as SndPlayDoubleBuffer()
|
||||
on the Macintosh.)
|
||||
|
||||
streamFlags may contain a combination of flags ORed together.
|
||||
These flags modify the behaviour of the streaming process. Some flags may only
|
||||
be relevant to certain buffer formats.
|
||||
|
||||
callback is a pointer to a client supplied function that is responsible
|
||||
for processing and filling input and output buffers (see above for details.)
|
||||
|
||||
userData is a client supplied pointer which is passed to the callback
|
||||
function. It could for example, contain a pointer to instance data necessary
|
||||
for processing the audio buffers.
|
||||
|
||||
return value:
|
||||
Upon success Pa_OpenStream() returns PaNoError and places a pointer to a
|
||||
valid PortAudioStream in the stream argument. The stream is inactive (stopped).
|
||||
If a call to Pa_OpenStream() fails a non-zero error code is returned (see
|
||||
PaError above) and the value of stream is invalid.
|
||||
|
||||
*/
|
||||
|
||||
PaError Pa_OpenStream( PortAudioStream** stream,
|
||||
PaDeviceID inputDevice,
|
||||
int numInputChannels,
|
||||
PaSampleFormat inputSampleFormat,
|
||||
void *inputDriverInfo,
|
||||
PaDeviceID outputDevice,
|
||||
int numOutputChannels,
|
||||
PaSampleFormat outputSampleFormat,
|
||||
void *outputDriverInfo,
|
||||
double sampleRate,
|
||||
unsigned long framesPerBuffer,
|
||||
unsigned long numberOfBuffers,
|
||||
PaStreamFlags streamFlags,
|
||||
PortAudioCallback *callback,
|
||||
void *userData );
|
||||
|
||||
|
||||
/*
|
||||
Pa_OpenDefaultStream() is a simplified version of Pa_OpenStream() that opens
|
||||
the default input and/or output devices. Most parameters have identical meaning
|
||||
to their Pa_OpenStream() counterparts, with the following exceptions:
|
||||
|
||||
If either numInputChannels or numOutputChannels is 0 the respective device
|
||||
is not opened. This has the same effect as passing paNoDevice in the device
|
||||
arguments to Pa_OpenStream().
|
||||
|
||||
sampleFormat applies to both the input and output buffers.
|
||||
|
||||
*/
|
||||
|
||||
PaError Pa_OpenDefaultStream( PortAudioStream** stream,
|
||||
int numInputChannels,
|
||||
int numOutputChannels,
|
||||
PaSampleFormat sampleFormat,
|
||||
double sampleRate,
|
||||
unsigned long framesPerBuffer,
|
||||
unsigned long numberOfBuffers,
|
||||
PortAudioCallback *callback,
|
||||
void *userData );
|
||||
|
||||
/*
|
||||
Pa_CloseStream() closes an audio stream, flushing any pending buffers.
|
||||
|
||||
*/
|
||||
|
||||
PaError Pa_CloseStream( PortAudioStream* );
|
||||
|
||||
/*
|
||||
Pa_StartStream() and Pa_StopStream() begin and terminate audio processing.
|
||||
Pa_StopStream() waits until all pending audio buffers have been played.
|
||||
Pa_AbortStream() stops playing immediately without waiting for pending
|
||||
buffers to complete.
|
||||
|
||||
*/
|
||||
|
||||
PaError Pa_StartStream( PortAudioStream *stream );
|
||||
|
||||
PaError Pa_StopStream( PortAudioStream *stream );
|
||||
|
||||
PaError Pa_AbortStream( PortAudioStream *stream );
|
||||
|
||||
/*
|
||||
Pa_StreamActive() returns one (1) when the stream is active (ie playing
|
||||
or recording audio), zero (0) when not playing, or a negative error number
|
||||
if the stream is invalid.
|
||||
The stream is active between calls to Pa_StartStream() and Pa_StopStream(),
|
||||
but may also become inactive if the callback returns a non-zero value.
|
||||
In the latter case, the stream is considered inactive after the last
|
||||
buffer has finished playing.
|
||||
|
||||
*/
|
||||
|
||||
PaError Pa_StreamActive( PortAudioStream *stream );
|
||||
|
||||
/*
|
||||
Pa_StreamTime() returns the current output time in samples for the stream.
|
||||
This time may be used as a time reference (for example synchronizing audio to
|
||||
MIDI).
|
||||
|
||||
*/
|
||||
|
||||
PaTimestamp Pa_StreamTime( PortAudioStream *stream );
|
||||
|
||||
/*
|
||||
Pa_GetCPULoad() returns the CPU Load for the stream.
|
||||
The "CPU Load" is a fraction of total CPU time consumed by the stream's
|
||||
audio processing routines including, but not limited to the client supplied
|
||||
callback.
|
||||
A value of 0.5 would imply that PortAudio and the sound generating
|
||||
callback was consuming roughly 50% of the available CPU time.
|
||||
This function may be called from the callback function or the application.
|
||||
|
||||
*/
|
||||
|
||||
double Pa_GetCPULoad( PortAudioStream* stream );
|
||||
|
||||
/*
|
||||
Pa_GetMinNumBuffers() returns the minimum number of buffers required by
|
||||
the current host based on minimum latency.
|
||||
On the PC, for the DirectSound implementation, latency can be optionally set
|
||||
by user by setting an environment variable.
|
||||
For example, to set latency to 200 msec, put:
|
||||
|
||||
set PA_MIN_LATENCY_MSEC=200
|
||||
|
||||
in the AUTOEXEC.BAT file and reboot.
|
||||
If the environment variable is not set, then the latency will be determined
|
||||
based on the OS. Windows NT has higher latency than Win95.
|
||||
|
||||
*/
|
||||
|
||||
int Pa_GetMinNumBuffers( int framesPerBuffer, double sampleRate );
|
||||
|
||||
/*
|
||||
Pa_Sleep() puts the caller to sleep for at least 'msec' milliseconds.
|
||||
You may sleep longer than the requested time so don't rely on this for
|
||||
accurate musical timing.
|
||||
|
||||
Pa_Sleep() is provided as a convenience for authors of portable code (such as
|
||||
the tests and examples in the PortAudio distribution.)
|
||||
|
||||
*/
|
||||
|
||||
void Pa_Sleep( long msec );
|
||||
|
||||
/*
|
||||
Pa_GetSampleSize() returns the size in bytes of a single sample in the
|
||||
supplied PaSampleFormat, or paSampleFormatNotSupported if the format is
|
||||
no supported.
|
||||
|
||||
*/
|
||||
|
||||
PaError Pa_GetSampleSize( PaSampleFormat format );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* PORT_AUDIO_H */
|
||||
+38
-79
@@ -31,7 +31,6 @@
|
||||
#include "translate.h"
|
||||
|
||||
extern MyFrame *myframe;
|
||||
extern ChildFrProsody *prosodyframe;
|
||||
extern ProsodyDisplay *prosodycanvas;
|
||||
|
||||
wxMenu *menu_prosody;
|
||||
@@ -60,6 +59,7 @@ ProsodyDisplay::ProsodyDisplay(wxWindow *parent, const wxPoint& pos, const wxSiz
|
||||
scalex = 0.5;
|
||||
scaley = double(LINESEP*6)/150.0;
|
||||
selected_ph = -1;
|
||||
SetBackgroundColour(wxColour(245,245,245));
|
||||
} // end of ProsodyDisplay::ProsodyDisplay
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ void ProsodyDisplay::RefreshLine(int line)
|
||||
int ProsodyDisplay::GetWidth(PHONEME_LIST *p)
|
||||
{//========================================
|
||||
int w;
|
||||
|
||||
|
||||
if(p->ph == NULL)
|
||||
return(0);
|
||||
|
||||
@@ -279,7 +279,7 @@ void ProsodyDisplay::OnKey(wxKeyEvent& event)
|
||||
{//========================================
|
||||
PHONEME_LIST *p;
|
||||
int display=1;
|
||||
|
||||
|
||||
if(selected_ph < 0)
|
||||
selected_ph = 0;
|
||||
|
||||
@@ -301,7 +301,7 @@ void ProsodyDisplay::OnKey(wxKeyEvent& event)
|
||||
if(selected_ph < (numph-2))
|
||||
selected_ph++;
|
||||
break;
|
||||
|
||||
|
||||
case WXK_UP:
|
||||
if(event.ControlDown())
|
||||
ChangePh(-1,2);
|
||||
@@ -360,7 +360,7 @@ void ProsodyDisplay::DrawEnv(wxDC& dc, int x1, int y1, int width, PHONEME_LIST *
|
||||
PHONEME_DATA phdata_tone;
|
||||
|
||||
if(width <= 0) return;
|
||||
|
||||
|
||||
if((pitchr = ph->pitch2 - ph->pitch1) < 0)
|
||||
{
|
||||
pitchr = -pitchr;
|
||||
@@ -425,6 +425,7 @@ void ProsodyDisplay::DrawPitchline(wxDC& dc, int line, int x1, int x2)
|
||||
|
||||
y = LINEBASE+LINESEP;
|
||||
dc.SetPen(*wxLIGHT_GREY_PEN);
|
||||
// dc.SetPen(*wxCYAN_PEN);
|
||||
for(ix=0; ix<5; ix++)
|
||||
{
|
||||
dc.DrawLine(0,offy-y,linewidth,offy-y);
|
||||
@@ -520,6 +521,12 @@ void ProsodyDisplay::OnDraw(wxDC& dc)
|
||||
|
||||
int line, start, end;
|
||||
|
||||
GetClientSize(&x1, &y1);
|
||||
if(x1 != linewidth)
|
||||
{
|
||||
LayoutData(NULL, 0);
|
||||
}
|
||||
|
||||
wxRegionIterator upd(GetUpdateRegion()); // get the update rect list
|
||||
|
||||
while (upd)
|
||||
@@ -549,15 +556,18 @@ void ProsodyDisplay::LayoutData(PHONEME_LIST *ph_list, int n_ph)
|
||||
int xpos;
|
||||
int w;
|
||||
int ix;
|
||||
int height;
|
||||
PHONEME_LIST *p;
|
||||
|
||||
|
||||
|
||||
numph = n_ph;
|
||||
phlist = ph_list;
|
||||
if(ph_list != NULL)
|
||||
{
|
||||
numph = n_ph;
|
||||
phlist = ph_list;
|
||||
}
|
||||
|
||||
num_lines = 0;
|
||||
linetab[0] = 1;
|
||||
GetClientSize(&linewidth, &height);
|
||||
xpos = linewidth;
|
||||
|
||||
// could improve this to do 'wordwrap' - only split on word boundary
|
||||
@@ -584,86 +594,35 @@ void ProsodyDisplay::LayoutData(PHONEME_LIST *ph_list, int n_ph)
|
||||
} // end of ProsodyDisplay::LayoutData
|
||||
|
||||
|
||||
extern int adding_page;
|
||||
|
||||
void MyFrame::OnProsody(wxCommandEvent& WXUNUSED(event))
|
||||
{//=====================================================
|
||||
|
||||
// Open the Prosody display window
|
||||
// Make another frame, containing a canvas
|
||||
int width, height;
|
||||
int ix, npages;
|
||||
|
||||
int h, w, w2;
|
||||
|
||||
if(prosodyframe != NULL)
|
||||
if(prosodycanvas != NULL)
|
||||
{
|
||||
// The Prosody window is already open
|
||||
prosodyframe->Activate();
|
||||
|
||||
// ?? select the prosody page ??
|
||||
npages = screenpages->GetPageCount();
|
||||
for(ix=0; ix<npages; ix++)
|
||||
{
|
||||
if(screenpages->GetPage(ix) == (wxWindow*)prosodycanvas)
|
||||
{
|
||||
screenpages->ChangeSelection(ix);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
m_leftWindow->GetSize(&w2, &h);
|
||||
GetClientSize(&w, &h);
|
||||
prosodyframe = new ChildFrProsody(myframe, _T(""),
|
||||
wxPoint(0, 100), wxSize(w-w2, 420),
|
||||
wxDEFAULT_FRAME_STYLE |
|
||||
wxNO_FULL_REPAINT_ON_RESIZE);
|
||||
|
||||
prosodyframe->SetTitle(_T("Prosody"));
|
||||
|
||||
// Give it a status line
|
||||
prosodyframe->CreateStatusBar();
|
||||
|
||||
int width, height;
|
||||
wxMDIClientWindow *clientwin = (wxMDIClientWindow *)this->GetClientWindow();
|
||||
clientwin->GetClientSize(&width, &height);
|
||||
|
||||
#ifdef deleted
|
||||
wxPanel *panel = new wxPanel(prosodyframe,-1,wxPoint(0,0), wxSize(width,50));
|
||||
ProsodyDisplay *canvas = new ProsodyDisplay(prosodyframe, wxPoint(0, 50), wxSize(width-2, height-50));
|
||||
#else
|
||||
ProsodyDisplay *canvas = new ProsodyDisplay(prosodyframe, wxPoint(0, 50), wxSize(width-10, height));
|
||||
#endif
|
||||
|
||||
prosodycanvas = canvas;
|
||||
|
||||
// Associate the menu bar with the frame
|
||||
prosodyframe->SetMenuBar(MakeMenu(2,translator->dictionary_name));
|
||||
prosodyframe->prosodycanvas = canvas;
|
||||
prosodyframe->Show(TRUE);
|
||||
|
||||
screenpages->GetClientSize(&width, &height);
|
||||
prosodycanvas = new ProsodyDisplay(screenpages, wxPoint(0, 50), wxSize(width-10, height));
|
||||
adding_page = 2; // work around for wxNotebook bug (version 2.8.7)
|
||||
screenpages->AddPage(prosodycanvas, _T("Prosody"), true);
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(ChildFrProsody, wxMDIChildFrame)
|
||||
EVT_MENU(SPECTSEQ_CLOSE, ChildFrProsody::OnQuit)
|
||||
|
||||
// EVT_ACTIVATE(ChildFrProsody::OnActivate)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
extern wxList my_children;
|
||||
|
||||
ChildFrProsody::ChildFrProsody(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size,
|
||||
const long style):
|
||||
wxMDIChildFrame(parent, -1, title, pos, size, style)
|
||||
{
|
||||
my_children.Append(this);
|
||||
}
|
||||
|
||||
ChildFrProsody::~ChildFrProsody(void)
|
||||
{
|
||||
wxWindow *w;
|
||||
my_children.DeleteObject(this);
|
||||
prosodycanvas = NULL;
|
||||
prosodyframe = NULL;
|
||||
|
||||
#ifndef PLATFORM_WINDOWS
|
||||
// bug in wxMDIChildFrame, we need to explicitly remove the ChildFrame from the ClientWindow
|
||||
w = myframe->GetClientWindow();
|
||||
w->RemoveChild(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChildFrProsody::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
Close(TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-16
@@ -15,7 +15,7 @@ class ProsodyDisplay: public wxScrolledWindow
|
||||
public:
|
||||
ProsodyDisplay(wxWindow *parent, const wxPoint& pos, const wxSize& size);
|
||||
~ProsodyDisplay();
|
||||
|
||||
|
||||
virtual void OnDraw(wxDC& dc);
|
||||
void OnMouse(wxMouseEvent& event);
|
||||
void OnKey(wxKeyEvent& event);
|
||||
@@ -32,7 +32,7 @@ class ProsodyDisplay: public wxScrolledWindow
|
||||
int GetWidth(PHONEME_LIST *p);
|
||||
void ChangePh(int pitch1, int pitch2);
|
||||
void SelectPh(int index);
|
||||
|
||||
|
||||
int linewidth; // height for drawing pitch
|
||||
double scalex; // scale length values
|
||||
double scaley; // scale pitch values
|
||||
@@ -47,18 +47,4 @@ class ProsodyDisplay: public wxScrolledWindow
|
||||
}; // end class ProsodyDisplay
|
||||
|
||||
|
||||
class ChildFrProsody: public wxMDIChildFrame
|
||||
{
|
||||
public:
|
||||
ProsodyDisplay *prosodycanvas;
|
||||
ChildFrProsody(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
||||
~ChildFrProsody(void);
|
||||
void OnActivate(wxActivateEvent& event);
|
||||
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnSave(wxCommandEvent& event);
|
||||
void OnSaveAs(wxCommandEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
+8
-10
@@ -69,12 +69,6 @@ static int ssml_ignore_l_angle = 0;
|
||||
//static const char *tone_punct_on = "\0016T"; // add reverberation, lower pitch
|
||||
//static const char *tone_punct_off = "\001T\001P";
|
||||
|
||||
// ignore these characters
|
||||
static const unsigned short chars_ignore[] = {
|
||||
0x200c, // zero width non-joiner
|
||||
0x200d, // zero width joiner
|
||||
0 };
|
||||
|
||||
// punctuations symbols that can end a clause
|
||||
static const unsigned short punct_chars[] = {',','.','?','!',':',';',
|
||||
0x2013, // en-dash
|
||||
@@ -1597,7 +1591,7 @@ static void SetProsodyParameter(int param_type, wchar_t *attr1, PARAM_STACK *sp)
|
||||
static int ReplaceKeyName(char *outbuf, int index, int &outix)
|
||||
{//===========================================================
|
||||
// Replace some key-names by single characters, so they can be pronounced in different languages
|
||||
MNEM_TAB keynames[] = {
|
||||
static MNEM_TAB keynames[] = {
|
||||
{"space ",0xe020},
|
||||
{"tab ", 0xe009},
|
||||
{"underscore ", 0xe05f},
|
||||
@@ -2392,10 +2386,14 @@ f_input = f_in; // for GetC etc
|
||||
c2 = ' ';
|
||||
}
|
||||
|
||||
if(lookupwchar(chars_ignore,c1))
|
||||
if((j = lookupwchar2(tr->chars_ignore,c1)) != 0)
|
||||
{
|
||||
// ignore this character (eg. zero-width-non-joiner U+200C)
|
||||
continue;
|
||||
if(j == 1)
|
||||
{
|
||||
// ignore this character (eg. zero-width-non-joiner U+200C)
|
||||
continue;
|
||||
}
|
||||
c1 = j; // replace the character
|
||||
}
|
||||
|
||||
if(c1 == 0xf0b)
|
||||
|
||||
@@ -136,6 +136,8 @@ static int speed3 = 118;
|
||||
|
||||
//#define TEST_SPEED
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
|
||||
void SetSpeed(int control)
|
||||
{//=======================
|
||||
int x;
|
||||
@@ -312,6 +314,147 @@ printf("%3d: speedf %d %d %d pause=%d %d wav=%d lenmod=%d %d\n",wpm,speed1,
|
||||
#endif
|
||||
} // end of SetSpeed
|
||||
|
||||
#else // not using sonic speed-up
|
||||
|
||||
void SetSpeed(int control)
|
||||
{//=======================
|
||||
// This is the earlier version of SetSpeed() before sonic speed-up was added
|
||||
int x;
|
||||
int s1;
|
||||
int wpm;
|
||||
int wpm2;
|
||||
|
||||
speed.loud_consonants = 0;
|
||||
speed.min_sample_len = 450;
|
||||
speed.lenmod_factor = 110; // controls the effect of FRFLAG_LEN_MOD reduce length change
|
||||
speed.lenmod2_factor = 100;
|
||||
|
||||
wpm = embedded_value[EMBED_S];
|
||||
if(control == 2)
|
||||
wpm = embedded_value[EMBED_S2];
|
||||
|
||||
#ifdef TEST_SPEED
|
||||
if(wpm > 1000)
|
||||
{
|
||||
// TESTING
|
||||
test = wpm / 1000;
|
||||
wpm = wpm % 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(voice->speed_percent > 0)
|
||||
{
|
||||
wpm = (wpm * voice->speed_percent)/100;
|
||||
}
|
||||
if(wpm > 450)
|
||||
wpm = 450;
|
||||
|
||||
if(wpm > 360)
|
||||
{
|
||||
speed.loud_consonants = (wpm - 360) / 8;
|
||||
}
|
||||
|
||||
wpm2 = wpm;
|
||||
if(wpm > 359) wpm2 = 359;
|
||||
if(wpm < 80) wpm2 = 80;
|
||||
x = speed_lookup[wpm2-80];
|
||||
|
||||
if(wpm >= 380)
|
||||
x = 7;
|
||||
if(wpm >= 400)
|
||||
x = 6;
|
||||
|
||||
if(control & 1)
|
||||
{
|
||||
// set speed factors for different syllable positions within a word
|
||||
// these are used in CalcLengths()
|
||||
speed1 = (x * voice->speedf1)/256;
|
||||
speed2 = (x * voice->speedf2)/256;
|
||||
speed3 = (x * voice->speedf3)/256;
|
||||
|
||||
if(x <= 7)
|
||||
{
|
||||
speed1 = x;
|
||||
speed2 = speed3 = x - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if(control & 2)
|
||||
{
|
||||
// these are used in synthesis file
|
||||
|
||||
if(wpm > 350)
|
||||
{
|
||||
speed.lenmod_factor = 85 - (wpm - 350) / 3;
|
||||
speed.lenmod2_factor = 60 - (wpm - 350) / 8;
|
||||
}
|
||||
else
|
||||
if(wpm > 250)
|
||||
{
|
||||
speed.lenmod_factor = 110 - (wpm - 250)/4;
|
||||
speed.lenmod2_factor = 110 - (wpm - 250)/2;
|
||||
}
|
||||
|
||||
s1 = (x * voice->speedf1)/256;
|
||||
|
||||
if(wpm >= 170)
|
||||
speed.wav_factor = 110 + (150*s1)/128; // reduced speed adjustment, used for playing recorded sounds
|
||||
else
|
||||
speed.wav_factor = 128 + (128*s1)/130; // = 215 at 170 wpm
|
||||
|
||||
if(wpm >= 350)
|
||||
{
|
||||
speed.wav_factor = wav_factor_350[wpm-350];
|
||||
}
|
||||
|
||||
if(wpm >= 390)
|
||||
{
|
||||
speed.min_sample_len = 450 - (wpm - 400)/2;
|
||||
if(wpm > 440)
|
||||
speed.min_sample_len = 420 - (wpm - 440);
|
||||
}
|
||||
|
||||
speed.pause_factor = (256 * s1)/115; // full speed adjustment, used for pause length
|
||||
speed.clause_pause_factor = 0;
|
||||
|
||||
if(wpm > 430)
|
||||
{
|
||||
speed.pause_factor = 12;
|
||||
// speed.clause_pause_factor = 15;
|
||||
}
|
||||
else
|
||||
if(wpm > 400)
|
||||
{
|
||||
speed.pause_factor = 13;
|
||||
// speed.clause_pause_factor = 15;
|
||||
}
|
||||
else
|
||||
if(wpm > 374)
|
||||
{
|
||||
speed.pause_factor = 14;
|
||||
}
|
||||
else
|
||||
if(wpm > 350)
|
||||
{
|
||||
speed.pause_factor = pause_factor_350[wpm - 350];
|
||||
}
|
||||
|
||||
if(speed.clause_pause_factor == 0)
|
||||
{
|
||||
// restrict the reduction of pauses between clauses
|
||||
if((speed.clause_pause_factor = speed.pause_factor) < 16)
|
||||
speed.clause_pause_factor = 16;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST_SPEED
|
||||
//if(control==3)
|
||||
printf("%3d: speedf %d %d %d pause=%d %d wav=%d lenmod=%d %d\n",wpm,speed1,speed2,speed3, speed.pause_factor,speed.clause_pause_factor, speed.wav_factor,speed.lenmod_factor,speed.lenmod2_factor);
|
||||
#endif
|
||||
} // end of SetSpeed
|
||||
|
||||
#endif // of INCLUDE_SONIC
|
||||
|
||||
|
||||
#ifdef deleted
|
||||
void SetAmplitude(int amp)
|
||||
|
||||
@@ -20,11 +20,15 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "speech.h"
|
||||
#include "sonic.h"
|
||||
#ifdef INCLUDE_SONIC
|
||||
|
||||
struct sonicStreamStruct {
|
||||
short *inputBuffer;
|
||||
@@ -965,3 +969,4 @@ int sonicChangeShortSpeed(
|
||||
sonicDestroyStream(stream);
|
||||
return numSamples;
|
||||
}
|
||||
#endif // INCLUDE_SONIC
|
||||
|
||||
+2
-2
@@ -575,7 +575,7 @@ void MarkerEvent(int type, unsigned int char_position, int value, int value2, un
|
||||
if((type == espeakEVENT_MARK) || (type == espeakEVENT_PLAY))
|
||||
ep->id.name = &namedata[value];
|
||||
else
|
||||
#ifdef deleted
|
||||
//#ifdef deleted
|
||||
// temporarily removed, don't introduce until after eSpeak version 1.46.02
|
||||
if(type == espeakEVENT_PHONEME)
|
||||
{
|
||||
@@ -585,7 +585,7 @@ void MarkerEvent(int type, unsigned int char_position, int value, int value2, un
|
||||
p[1] = value2;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
//#endif
|
||||
{
|
||||
ep->id.number = value;
|
||||
}
|
||||
|
||||
+11
-3
@@ -1,7 +1,7 @@
|
||||
#ifndef SPEAK_LIB_H
|
||||
#define SPEAK_LIB_H
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 to 2010 by Jonathan Duddington *
|
||||
* Copyright (C) 2005 to 2012 by Jonathan Duddington *
|
||||
* email: jonsd@users.sourceforge.net *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -34,7 +34,7 @@
|
||||
#define ESPEAK_API
|
||||
#endif
|
||||
|
||||
#define ESPEAK_API_REVISION 6
|
||||
#define ESPEAK_API_REVISION 7
|
||||
/*
|
||||
Revision 2
|
||||
Added parameter "options" to eSpeakInitialize()
|
||||
@@ -50,6 +50,11 @@ Revision 5
|
||||
|
||||
Revision 6
|
||||
Added macros: espeakRATE_MINIMUM, espeakRATE_MAXIMUM, espeakRATE_NORMAL
|
||||
|
||||
Revision 7 24.Dec.2011
|
||||
Changed espeak_EVENT structure to add id.string[] for phoneme mnemonics.
|
||||
Added espeakINITIALIZE_PHONEME_IPA option for espeak_Initialize() to report phonemes as IPA names.
|
||||
|
||||
*/
|
||||
/********************/
|
||||
/* Initialization */
|
||||
@@ -84,8 +89,9 @@ typedef struct {
|
||||
int sample; // sample id (internal use)
|
||||
void* user_data; // pointer supplied by the calling program
|
||||
union {
|
||||
int number; // used for WORD and SENTENCE events. For PHONEME events this is the phoneme mnemonic.
|
||||
int number; // used for WORD and SENTENCE events.
|
||||
const char *name; // used for MARK and PLAY events. UTF8 string
|
||||
char string[8]; // used for phoneme names (UTF8). Terminated by a zero byte unless the name needs the full 8 bytes.
|
||||
} id;
|
||||
} espeak_EVENT;
|
||||
/*
|
||||
@@ -164,6 +170,7 @@ typedef enum {
|
||||
} espeak_ERROR;
|
||||
|
||||
#define espeakINITIALIZE_PHONEME_EVENTS 0x0001
|
||||
#define espeakINITIALIZE_PHONEME_IPA 0x0002
|
||||
#define espeakINITIALIZE_DONT_EXIT 0x8000
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -178,6 +185,7 @@ ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output, int buflength, cons
|
||||
path: The directory which contains the espeak-data directory, or NULL for the default location.
|
||||
|
||||
options: bit 0: 1=allow espeakEVENT_PHONEME events.
|
||||
bit 1: 1= espeakEVENT_PHONEME events give IPA phoneme names, not eSpeak phoneme names
|
||||
bit 15: 1=don't exit if espeak_data is not found (used for --help)
|
||||
|
||||
Returns: sample rate in Hz, or -1 (EE_INTERNAL_ERROR).
|
||||
|
||||
+2
-2
@@ -121,7 +121,7 @@ typedef struct {
|
||||
PEAKS7 peak_data[7];
|
||||
unsigned char data[1]; /* firstly harmonic data, then f3,f4,f5 data */
|
||||
} CYCLE; /* VARIABLE LENGTH Structure */
|
||||
|
||||
|
||||
extern int SPC2_size_cycle(CYCLE *cy);
|
||||
//==============================================================================================
|
||||
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
void CopyPeaks(SpectFrame *sf);
|
||||
void ToggleMarker(int n);
|
||||
void ApplyVoiceMods();
|
||||
|
||||
|
||||
void MakeWaveF(int peaks, PitchEnvelope &pitch, int amplitude, int duration);
|
||||
void MakeHtab(int numh, int *htab, int pitch);
|
||||
double GetRms(int amp);
|
||||
|
||||
+18
-57
@@ -42,9 +42,6 @@
|
||||
extern MyFrame *frame ;
|
||||
#define SCROLLUNITS 20
|
||||
|
||||
#define N_CANVASLIST 50
|
||||
static int canvaslistix=0;
|
||||
static SpectDisplay *canvaslist[N_CANVASLIST];
|
||||
SpectSeq *clipboard_spect=NULL;
|
||||
wxMenu *menu_spectdisplay=NULL;
|
||||
|
||||
@@ -77,37 +74,14 @@ SpectDisplay::SpectDisplay(wxWindow *parent, const wxPoint& pos, const wxSize& s
|
||||
pk_num = 1;
|
||||
|
||||
SetExtent();
|
||||
|
||||
if(canvaslistix < N_CANVASLIST-1)
|
||||
canvaslist[canvaslistix++] = this;
|
||||
// WavegenInitPkData(0);
|
||||
|
||||
} // end of SpectDisplay::SpectDisplay
|
||||
|
||||
|
||||
|
||||
SpectDisplay::~SpectDisplay()
|
||||
{//==========================
|
||||
// delete this from the canvaslist
|
||||
int ix;
|
||||
|
||||
for(ix=0; ix<canvaslistix; ix++)
|
||||
{
|
||||
if(canvaslist[ix] == this)
|
||||
{
|
||||
for(ix=ix+1; ix<canvaslistix; ix++)
|
||||
canvaslist[ix-1] = canvaslist[ix];
|
||||
canvaslistix--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(currentcanvas==this)
|
||||
{
|
||||
if(canvaslistix > 0)
|
||||
currentcanvas = canvaslist[0];
|
||||
else
|
||||
currentcanvas = NULL;
|
||||
}
|
||||
// ?? change currentcanvas
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +148,7 @@ void SpectDisplay::OnActivate(int active)
|
||||
{
|
||||
formantdlg->GetValues(spectseq, sframe);
|
||||
ReadDialogValues();
|
||||
currentcanvas = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +184,7 @@ int GetNumeric(wxTextCtrl *t)
|
||||
void SpectDisplay::WriteDialogLength()
|
||||
{//===================================
|
||||
wxString string;
|
||||
|
||||
|
||||
string.Printf(_T("%d mS"),int(spectseq->GetKeyedLength()+0.5));
|
||||
formantdlg->t_orig_seq->SetLabel(string);
|
||||
}
|
||||
@@ -220,7 +195,7 @@ void SpectDisplay::WriteDialogValues()
|
||||
//{===============================
|
||||
{
|
||||
wxString string;
|
||||
|
||||
|
||||
SetSpinCtrl(formantdlg->t_amplitude,spectseq->amplitude);
|
||||
|
||||
string.Printf(_T("%d - %d Hz %d mS"),
|
||||
@@ -229,7 +204,7 @@ void SpectDisplay::WriteDialogValues()
|
||||
|
||||
pitchgraph->SetData(128,spectseq->pitchenv.env);
|
||||
voicedlg->SetFromSpect(spectseq);
|
||||
|
||||
|
||||
WriteDialogLength();
|
||||
}
|
||||
|
||||
@@ -456,15 +431,13 @@ void SpectDisplay::SavePitchenv(PitchEnvelope &pitch)
|
||||
} // end of SpectDisplay::SavePitchenv
|
||||
|
||||
|
||||
// WX_DECLARE_LIST(MyChild,ChildList);
|
||||
// WX_DEFINE_LIST(ChildList);
|
||||
|
||||
|
||||
void SpectDisplay::PlayChild(int number, PitchEnvelope pitchenv)
|
||||
{//=========================================================
|
||||
#ifdef deleted
|
||||
SpectSeq *seq;
|
||||
|
||||
|
||||
if(number >= canvaslistix) return;
|
||||
|
||||
if((seq = canvaslist[number]->spectseq) == NULL)
|
||||
@@ -472,6 +445,7 @@ void SpectDisplay::PlayChild(int number, PitchEnvelope pitchenv)
|
||||
|
||||
ReadDialogValues();
|
||||
seq->MakeWave(0,seq->numframes-1,pitchenv);
|
||||
#endif
|
||||
} // end of PlayChild
|
||||
|
||||
|
||||
@@ -481,7 +455,7 @@ void SpectDisplay::SetKeyframe(SpectFrame *sf, int yes)
|
||||
|
||||
sf->keyframe = yes;
|
||||
pitchgraph->Refresh();
|
||||
|
||||
|
||||
WriteDialogLength();
|
||||
}
|
||||
|
||||
@@ -731,7 +705,7 @@ void SpectDisplay::OnKey(wxKeyEvent& event)
|
||||
spectseq->bass_reduction ^= 1;
|
||||
Refresh();
|
||||
break;
|
||||
|
||||
|
||||
case 0x1043: // CTRL-C
|
||||
spectseq->ClipboardCopy();
|
||||
break;
|
||||
@@ -923,6 +897,7 @@ void SpectDisplay::OnMouse(wxMouseEvent& event)
|
||||
int frame;
|
||||
int ix;
|
||||
|
||||
SetFocus();
|
||||
if(event.RightDown())
|
||||
{
|
||||
PopupMenu(menu_spectdisplay);
|
||||
@@ -935,7 +910,7 @@ void SpectDisplay::OnMouse(wxMouseEvent& event)
|
||||
wxPoint pt(event.GetLogicalPosition(dc));
|
||||
|
||||
if(spectseq->numframes==0) return;
|
||||
|
||||
|
||||
frame = (int)(pt.y/(FRAME_HEIGHT*zoomy));
|
||||
|
||||
if(!event.ControlDown())
|
||||
@@ -1018,30 +993,16 @@ void MyFrame::OnNewWindow(wxCommandEvent& event)
|
||||
else
|
||||
path_spectload2 = path.GetPath();
|
||||
|
||||
// Make another frame, containing a canvas
|
||||
|
||||
|
||||
GetClientSize(&width, &height);
|
||||
MyChild *subframe = new MyChild(myframe, _T("Spectrum"),
|
||||
wxPoint(10, 0), wxSize(500, height),
|
||||
wxDEFAULT_FRAME_STYLE |
|
||||
wxNO_FULL_REPAINT_ON_RESIZE);
|
||||
|
||||
subframe->SetTitle(leaf);
|
||||
|
||||
// Give it a status line
|
||||
subframe->CreateStatusBar();
|
||||
|
||||
subframe->GetClientSize(&width, &height);
|
||||
SpectDisplay *canvas = new SpectDisplay(subframe, wxPoint(0, 0), wxSize(width, height), spectseq);
|
||||
SpectDisplay *canvas = new SpectDisplay(screenpages, wxDefaultPosition, wxSize(width, height), spectseq);
|
||||
screenpages->AddPage(canvas, leaf, true);
|
||||
canvas->savepath = filename;
|
||||
currentcanvas = canvas;
|
||||
|
||||
// Associate the menu bar with the frame
|
||||
subframe->SetMenuBar(MakeMenu(1,translator->dictionary_name));
|
||||
subframe->canvas = canvas;
|
||||
subframe->Show(TRUE);
|
||||
|
||||
currentcanvas = canvas;
|
||||
}
|
||||
|
||||
|
||||
void InitSpectrumDisplay()
|
||||
{//=======================
|
||||
wxMenu *menu_markers = new wxMenu;
|
||||
|
||||
+3
-2
@@ -25,6 +25,7 @@
|
||||
// conditional compilation options
|
||||
#define INCLUDE_KLATT
|
||||
#define INCLUDE_MBROLA
|
||||
#define INCLUDE_SONIC
|
||||
|
||||
#if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
|
||||
#define ARCH_BIG
|
||||
@@ -50,7 +51,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef _ESPEAKEDIT
|
||||
#define USE_PORTAUDIO
|
||||
// USE_PORTAUDIO or USE_PULSEAUDIO are now defined in the makefile
|
||||
#define USE_ASYNC
|
||||
#define LOG_FRAMES // write keyframe info to log-espeakedit
|
||||
#endif
|
||||
@@ -63,7 +64,7 @@
|
||||
typedef unsigned short USHORT;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef double DOUBLEX;
|
||||
|
||||
typedef unsigned long long64; // use this for conversion between pointers and integers
|
||||
|
||||
|
||||
|
||||
|
||||
+12
-12
@@ -77,7 +77,7 @@ HINSTANCE hinstDllMBR = NULL;
|
||||
BOOL load_MBR()
|
||||
{
|
||||
if(hinstDllMBR != NULL)
|
||||
return TRUE; // already loaded
|
||||
return TRUE; // already loaded
|
||||
|
||||
if ((hinstDllMBR=LoadLibraryA("mbrola.dll")) == 0)
|
||||
return FALSE;
|
||||
@@ -150,14 +150,14 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
|
||||
}
|
||||
}
|
||||
}
|
||||
close_MBR();
|
||||
close_MBR();
|
||||
#endif
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
if(load_MBR() == FALSE) // load mbrola.dll
|
||||
{
|
||||
fprintf(stderr, "Can't load mbrola.dll\n");
|
||||
return(EE_INTERNAL_ERROR);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(init_MBR(path) != 0) // initialise the required mbrola voice
|
||||
@@ -169,14 +169,14 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
|
||||
sprintf(path,"%s/mbrola_ph/%s",path_home,phtrans);
|
||||
size = GetFileLength(path);
|
||||
if((f_in = fopen(path,"rb")) == NULL) {
|
||||
close_MBR();
|
||||
close_MBR();
|
||||
return(EE_NOT_FOUND);
|
||||
}
|
||||
|
||||
if((mbrola_tab = (MBROLA_TAB *)realloc(mbrola_tab,size)) == NULL)
|
||||
{
|
||||
fclose(f_in);
|
||||
close_MBR();
|
||||
close_MBR();
|
||||
return(EE_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int
|
||||
fclose(f_in);
|
||||
|
||||
setVolumeRatio_MBR((float)(mbrola_control & 0xff) /16.0f);
|
||||
// srate = getFreq_MBR();
|
||||
// srate = getFreq_MBR();
|
||||
samplerate = srate;
|
||||
if(srate == 22050)
|
||||
SetParameter(espeakVOICETYPE,0,0);
|
||||
@@ -543,7 +543,7 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
|
||||
if(released == 0)
|
||||
p->synthflags |= SFLAG_NEXT_PAUSE;
|
||||
InterpretPhoneme(NULL, 0, p, &phdata);
|
||||
InterpretPhoneme(NULL, 0, p, &phdata, NULL);
|
||||
len = DoSample3(&phdata, 0, -1);
|
||||
|
||||
len = (len * 1000)/samplerate; // convert to mS
|
||||
@@ -556,7 +556,7 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
|
||||
case phFRICATIVE:
|
||||
len = 0;
|
||||
InterpretPhoneme(NULL, 0, p, &phdata);
|
||||
InterpretPhoneme(NULL, 0, p, &phdata, NULL);
|
||||
if(p->synthflags & SFLAG_LENGTHEN)
|
||||
len = DoSample3(&phdata, p->length, -1); // play it twice for [s:] etc.
|
||||
len += DoSample3(&phdata, p->length, -1);
|
||||
@@ -568,7 +568,7 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
if(next->type != phVOWEL)
|
||||
{
|
||||
memset(&fmtp, 0, sizeof(fmtp));
|
||||
InterpretPhoneme(NULL, 0, p, &phdata);
|
||||
InterpretPhoneme(NULL, 0, p, &phdata, NULL);
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
len = DoSpect2(p->ph, 0, &fmtp, p, -1);
|
||||
// len = DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,-1);
|
||||
@@ -601,7 +601,7 @@ int MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, int resume, FILE *f_mbr
|
||||
|
||||
if(pause)
|
||||
{
|
||||
len += PauseLength(pause,0);
|
||||
len += PauseLength(pause,0);
|
||||
ptr += sprintf(ptr,"_ \t%d\n",PauseLength(pause,0));
|
||||
pause = 0;
|
||||
}
|
||||
@@ -655,7 +655,7 @@ int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
int again = MbrolaTranslate(phoneme_list, *n_ph, resume, f_mbrola);
|
||||
if (!again)
|
||||
*n_ph = 0;
|
||||
return again;
|
||||
return again;
|
||||
}
|
||||
|
||||
|
||||
@@ -710,7 +710,7 @@ void MbrolaReset(void)
|
||||
|
||||
espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int srate)
|
||||
{
|
||||
return(EE_INTERNAL_ERROR);
|
||||
return(EE_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
|
||||
+146
-61
@@ -35,8 +35,8 @@
|
||||
#include "translate.h"
|
||||
#include "wave.h"
|
||||
|
||||
const char *version_string = "1.46.02 06.Jan.12";
|
||||
const int version_phdata = 0x014600;
|
||||
const char *version_string = "1.46.29 23.Nov.12";
|
||||
const int version_phdata = 0x014624;
|
||||
|
||||
int option_device_number = -1;
|
||||
FILE *f_logespeak = NULL;
|
||||
@@ -80,7 +80,7 @@ static char *ReadPhFile(void *ptr, const char *fname, int *size)
|
||||
|
||||
sprintf(buf,"%s%c%s",path_home,PATHSEP,fname);
|
||||
length = GetFileLength(buf);
|
||||
|
||||
|
||||
if((f_in = fopen(buf,"rb")) == NULL)
|
||||
{
|
||||
fprintf(stderr,"Can't read data file: '%s'\n",buf);
|
||||
@@ -89,7 +89,7 @@ static char *ReadPhFile(void *ptr, const char *fname, int *size)
|
||||
|
||||
if(ptr != NULL)
|
||||
Free(ptr);
|
||||
|
||||
|
||||
if((p = Alloc(length)) == NULL)
|
||||
{
|
||||
fclose(f_in);
|
||||
@@ -230,7 +230,7 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params,
|
||||
SPECT_SEQK *seqk, *seqk2;
|
||||
frame_t *frame;
|
||||
static frameref_t frames_buf[N_SEQ_FRAMES];
|
||||
|
||||
|
||||
seq = (SPECT_SEQ *)(&phondata_ptr[fmt_params->fmt_addr]);
|
||||
seqk = (SPECT_SEQK *)seq;
|
||||
nf = seq->n_frames;
|
||||
@@ -268,7 +268,7 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params,
|
||||
nf -= seq_break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// do we need to modify a frame for blending with a consonant?
|
||||
if((this_ph->type == phVOWEL) && (fmt_params->fmt2_addr == 0) && (fmt_params->use_vowelin))
|
||||
{
|
||||
@@ -286,7 +286,7 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params,
|
||||
// add these spectra to the main sequence
|
||||
seq2 = (SPECT_SEQ *)(&phondata_ptr[fmt_params->fmt2_addr]);
|
||||
seqk2 = (SPECT_SEQK *)seq2;
|
||||
|
||||
|
||||
// first frame of the addition just sets the length of the last frame of the main seq
|
||||
nf--;
|
||||
for(ix=0; ix<seq2->n_frames; ix++)
|
||||
@@ -306,7 +306,7 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params,
|
||||
}
|
||||
wavefile_ix = 0;
|
||||
}
|
||||
|
||||
|
||||
if(length1 > 0)
|
||||
{
|
||||
if(which==2)
|
||||
@@ -324,7 +324,7 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params,
|
||||
|
||||
|
||||
length_factor = (length_std * 256)/ length1;
|
||||
|
||||
|
||||
for(ix=0; ix<nf1; ix++)
|
||||
{
|
||||
frames[ix].length = (frames[ix].length * length_factor)/256;
|
||||
@@ -362,7 +362,7 @@ frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*n_frames = nf;
|
||||
return(frames);
|
||||
} // end of LookupSpect
|
||||
@@ -562,7 +562,7 @@ static bool StressCondition(Translator *tr, PHONEME_LIST *plist, int condition,
|
||||
// change phoneme. Don't change phonemes which are given for the word in the dictionary.
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
if((tr->langopts.param[LOPT_REDUCE] & 0x2) && (stress_level >= pl->wordstress))
|
||||
{
|
||||
// treat the most stressed syllable in an unstressed word as stressed
|
||||
@@ -607,69 +607,107 @@ static int CountVowelPosition(PHONEME_LIST *plist)
|
||||
} // end of CoundVowelPosition
|
||||
|
||||
|
||||
static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist, int instn)
|
||||
{//========================================================================================
|
||||
static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist, USHORT *p_prog, WORD_PH_DATA *worddata)
|
||||
{//========================================================================================================================
|
||||
int which;
|
||||
unsigned int data;
|
||||
int instn;
|
||||
int instn2;
|
||||
int count;
|
||||
PHONEME_TAB *ph;
|
||||
PHONEME_LIST *plist_this;
|
||||
static int ph_position[8] = {0, 1, 2, 3, 2, 0, 1, 3}; // prevPh, thisPh, nextPh, next2Ph, nextPhW, prevPhW, nextVowel, (other conditions)
|
||||
|
||||
// instruction: 2xxx, 3xxx
|
||||
|
||||
// bits 8-10 = 0 to 6, which phoneme
|
||||
// bits 8-10 = 0 to 5, which phoneme, =6 the 'which' information is in the next instruction.
|
||||
// bit 11 = 0, bits 0-7 are a phoneme code
|
||||
// bit 11 = 1, bits 5-7 type of data, bits 0-4 data value
|
||||
|
||||
// bits 8-10 = 7, other conditions
|
||||
|
||||
|
||||
instn = (*p_prog) & 0xfff;
|
||||
data = instn & 0xff;
|
||||
instn2 = instn >> 8;
|
||||
|
||||
if(instn2 < 14)
|
||||
{
|
||||
plist_this = plist;
|
||||
which = (instn2) % 7;
|
||||
|
||||
if(which==6)
|
||||
{
|
||||
// the 'which' code is in the next instruction
|
||||
p_prog++;
|
||||
which = (*p_prog);
|
||||
}
|
||||
|
||||
if(which==4)
|
||||
{
|
||||
// nextPh not word boundary
|
||||
// nextPhW not word boundary
|
||||
if(plist[1].sourceix)
|
||||
return(false);
|
||||
}
|
||||
if(which==5)
|
||||
{
|
||||
// prevPh, not word boundary
|
||||
// prevPhW, not word boundary
|
||||
if(plist[0].sourceix)
|
||||
return(false);
|
||||
}
|
||||
if(which==6)
|
||||
{
|
||||
{
|
||||
// next2PhW, not word boundary
|
||||
if(plist[1].sourceix || plist[2].sourceix)
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
switch(which)
|
||||
{
|
||||
case 0: // prevPh
|
||||
case 5: // prevPhW
|
||||
plist--;
|
||||
break;
|
||||
|
||||
case 1: // thisPh
|
||||
break;
|
||||
|
||||
case 2: // nextPh
|
||||
case 4: // nextPhW
|
||||
plist++;
|
||||
break;
|
||||
|
||||
case 3: // next2Ph
|
||||
case 6: // next2PhW
|
||||
plist += 2;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
// nextVowel, not word boundary
|
||||
for(which=2;;which++)
|
||||
for(which=1;;which++)
|
||||
{
|
||||
if(plist[which-1].sourceix)
|
||||
if(plist[which].sourceix)
|
||||
return(false);
|
||||
if(phoneme_tab[plist[which-1].phcode]->type == phVOWEL)
|
||||
if(phoneme_tab[plist[which].phcode]->type == phVOWEL)
|
||||
{
|
||||
plist = &plist[which];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
which = ph_position[which];
|
||||
}
|
||||
break;
|
||||
|
||||
plist_this = plist;
|
||||
plist = &plist[which-1];
|
||||
case 8: // prevVowel in this word
|
||||
if((worddata==NULL) || (worddata->prev_vowel.ph == NULL))
|
||||
return(false); // no previous vowel
|
||||
plist = &(worddata->prev_vowel);
|
||||
break;
|
||||
}
|
||||
|
||||
if(which == 0)
|
||||
if((which == 0) || (which == 5))
|
||||
{
|
||||
if(plist->phcode == 1)
|
||||
{
|
||||
// This is a NULL phoneme, a phoneme has been deleted so look at the previous phoneme
|
||||
plist = &plist[-1];
|
||||
plist--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -739,7 +777,7 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist,
|
||||
plist--;
|
||||
if((plist->stresslevel & 0xf) >= 4)
|
||||
return(true);
|
||||
|
||||
|
||||
} while (plist->sourceix == 0);
|
||||
break;
|
||||
|
||||
@@ -814,8 +852,8 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist,
|
||||
} // end of InterpretCondition
|
||||
|
||||
|
||||
static void SwitchVowelType(PHONEME_LIST *plist, PHONEME_DATA *phdata, USHORT **p_prog, int instn_type)
|
||||
{//=====================================================================================================
|
||||
static void SwitchOnVowelType(PHONEME_LIST *plist, PHONEME_DATA *phdata, USHORT **p_prog, int instn_type)
|
||||
{//========================================================================================================
|
||||
USHORT *prog;
|
||||
int voweltype;
|
||||
signed char x;
|
||||
@@ -843,36 +881,63 @@ static void SwitchVowelType(PHONEME_LIST *plist, PHONEME_DATA *phdata, USHORT **
|
||||
} // end of SwitchVowelType
|
||||
|
||||
|
||||
static int NumInstnWords(USHORT *prog)
|
||||
{//===================================
|
||||
int NumInstnWords(USHORT *prog)
|
||||
{//============================
|
||||
int instn;
|
||||
int instn2;
|
||||
int instn_type;
|
||||
static char n_words[11] = {1,1,1,1,1,1,1,1,1,2,4};
|
||||
int n;
|
||||
int type2;
|
||||
static const char n_words[16] = {0,1,0,0,1,1,0,1,1,2,4,0,0,0,0,0};
|
||||
|
||||
instn = *prog;
|
||||
instn_type = instn >> 12;
|
||||
if(instn_type < 11)
|
||||
return(n_words[instn_type]);
|
||||
if((n = n_words[instn_type]) > 0)
|
||||
return(n);
|
||||
|
||||
// 11 to 15, 2 words
|
||||
instn2 = prog[2];
|
||||
if((instn2 >> 12) == 0xf)
|
||||
switch(instn_type)
|
||||
{
|
||||
// addWav(), 2 more words
|
||||
return(4);
|
||||
case 0:
|
||||
if(((instn & 0xf00) >> 8) == i_IPA_NAME)
|
||||
{
|
||||
n = ((instn & 0xff) + 1) / 2;
|
||||
return(n+1);
|
||||
}
|
||||
return(1);;
|
||||
|
||||
case 6:
|
||||
type2 = (instn & 0xf00) >> 9;
|
||||
if((type2 == 5) || (type2 == 6))
|
||||
return(12); // switch on vowel type
|
||||
return(1);
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
// a condition, check for a 2-word instruction
|
||||
if(((n = instn & 0x0f00) == 0x600) || (n == 0x0d00))
|
||||
return(2);
|
||||
return(1);
|
||||
|
||||
default:
|
||||
// instn_type 11 to 15, 2 words
|
||||
instn2 = prog[2];
|
||||
if((instn2 >> 12) == 0xf)
|
||||
{
|
||||
// This instruction is followed by addWav(), 2 more words
|
||||
return(4);
|
||||
}
|
||||
if(instn2 == i_CONTINUE)
|
||||
{
|
||||
return(3);
|
||||
}
|
||||
return(2);
|
||||
}
|
||||
if(instn2 == i_CONTINUE)
|
||||
{
|
||||
return(3);
|
||||
}
|
||||
return(2);
|
||||
} // end of NumInstnWords
|
||||
|
||||
|
||||
|
||||
void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_DATA *phdata)
|
||||
{//==========================================================================================
|
||||
void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_DATA *phdata, WORD_PH_DATA *worddata)
|
||||
{//===================================================================================================================
|
||||
// control:
|
||||
//bit 0: PreVoicing
|
||||
//bit 8: change phonemes
|
||||
@@ -882,6 +947,7 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
int instn2;
|
||||
int or_flag;
|
||||
bool truth;
|
||||
bool truth2;
|
||||
int data;
|
||||
int end_flag;
|
||||
int ix;
|
||||
@@ -893,6 +959,12 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
|
||||
ph = plist->ph;
|
||||
|
||||
if((worddata != NULL) && (plist->sourceix))
|
||||
{
|
||||
// start of a word, reset word data
|
||||
worddata->prev_vowel.ph = NULL;
|
||||
}
|
||||
|
||||
memset(phdata, 0, sizeof(PHONEME_DATA));
|
||||
phdata->pd_param[i_SET_LENGTH] = ph->std_length;
|
||||
phdata->pd_param[i_LENGTH_MOD] = ph->length_mod;
|
||||
@@ -901,13 +973,13 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
return;
|
||||
|
||||
end_flag = 0;
|
||||
|
||||
|
||||
for(prog = &phoneme_index[ph->program]; end_flag != 1; prog++)
|
||||
{
|
||||
instn = *prog;
|
||||
instn2 = (instn >> 8) & 0xf;
|
||||
or_flag = 0;
|
||||
|
||||
|
||||
switch(instn >> 12)
|
||||
{
|
||||
case 0: // 0xxx
|
||||
@@ -975,7 +1047,7 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
if(instn2 < 8)
|
||||
{
|
||||
// ChangeIf
|
||||
if(StressCondition(tr, plist, instn2 & 7, 1))
|
||||
if(StressCondition(tr, plist, instn2 & 7, 1) == true)
|
||||
{
|
||||
phdata->pd_param[i_CHANGE_PHONEME] = instn & 0xff;
|
||||
end_flag = 1; // change phoneme, exit
|
||||
@@ -991,12 +1063,20 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
while((instn & 0xe000) == 0x2000)
|
||||
{
|
||||
// process a sequence of conditions, using boolean accumulator
|
||||
truth2 = InterpretCondition(tr, control, plist, prog, worddata);
|
||||
prog += NumInstnWords(prog);
|
||||
if(*prog == i_NOT)
|
||||
{
|
||||
truth2 = truth2 ^ 1;
|
||||
prog++;
|
||||
}
|
||||
|
||||
if(or_flag)
|
||||
truth = (truth || InterpretCondition(tr, control, plist, instn & 0xfff));
|
||||
truth = truth || truth2;
|
||||
else
|
||||
truth = (truth && InterpretCondition(tr, control, plist, instn & 0xfff));
|
||||
truth = truth && truth2;
|
||||
or_flag = instn & 0x1000;
|
||||
instn = *(++prog);
|
||||
instn = *prog;
|
||||
}
|
||||
|
||||
if(truth == false)
|
||||
@@ -1010,7 +1090,7 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
// instruction after a condition is not JUMP_FALSE, so skip the instruction.
|
||||
prog += NumInstnWords(prog);
|
||||
if((prog[0] & 0xfe00) == 0x6000)
|
||||
prog++; // and skip ELSE jump
|
||||
prog++; // and skip ELSE jump
|
||||
}
|
||||
}
|
||||
prog--;
|
||||
@@ -1029,11 +1109,11 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
break;
|
||||
|
||||
case 5: // NexttVowelStarts
|
||||
SwitchVowelType(plist, phdata, &prog, 2);
|
||||
SwitchOnVowelType(plist, phdata, &prog, 2);
|
||||
break;
|
||||
|
||||
case 6: // PrevVowelTypeEndings
|
||||
SwitchVowelType(plist, phdata, &prog, 3);
|
||||
SwitchOnVowelType(plist, phdata, &prog, 3);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -1130,6 +1210,11 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
}
|
||||
}
|
||||
|
||||
if((worddata != NULL) && (plist->type == phVOWEL))
|
||||
{
|
||||
memcpy(&worddata->prev_vowel, &plist[0], sizeof(PHONEME_LIST));
|
||||
}
|
||||
|
||||
} // end of InterpretPhoneme
|
||||
|
||||
|
||||
@@ -1150,5 +1235,5 @@ void InterpretPhoneme2(int phcode, PHONEME_DATA *phdata)
|
||||
plist[1].ph = phoneme_tab[phcode];
|
||||
plist[2].sourceix = 1;
|
||||
|
||||
InterpretPhoneme(NULL, 0, &plist[1], phdata);
|
||||
InterpretPhoneme(NULL, 0, &plist[1], phdata, NULL);
|
||||
} // end of InterpretPhoneme2
|
||||
|
||||
+59
-46
@@ -142,7 +142,7 @@ static void EndPitch(int voice_break)
|
||||
|
||||
static void DoAmplitude(int amp, unsigned char *amp_env)
|
||||
{//=====================================================
|
||||
long *q;
|
||||
long64 *q;
|
||||
|
||||
last_amp_cmd = wcmdq_tail;
|
||||
amp_length = 0; // total length of vowel with this amplitude envelope
|
||||
@@ -150,7 +150,7 @@ static void DoAmplitude(int amp, unsigned char *amp_env)
|
||||
q = wcmdq[wcmdq_tail];
|
||||
q[0] = WCMD_AMPLITUDE;
|
||||
q[1] = 0; // fill in later from amp_length
|
||||
q[2] = (long)amp_env;
|
||||
q[2] = (long64)amp_env;
|
||||
q[3] = amp;
|
||||
WcmdqInc();
|
||||
} // end of DoAmplitude
|
||||
@@ -159,7 +159,7 @@ static void DoAmplitude(int amp, unsigned char *amp_env)
|
||||
|
||||
static void DoPitch(unsigned char *env, int pitch1, int pitch2)
|
||||
{//============================================================
|
||||
long *q;
|
||||
long64 *q;
|
||||
|
||||
EndPitch(0);
|
||||
|
||||
@@ -179,7 +179,7 @@ static void DoPitch(unsigned char *env, int pitch1, int pitch2)
|
||||
q = wcmdq[wcmdq_tail];
|
||||
q[0] = WCMD_PITCH;
|
||||
q[1] = 0; // length, fill in later from pitch_length
|
||||
q[2] = (long)env;
|
||||
q[2] = (long64)env;
|
||||
q[3] = (pitch1 << 16) + pitch2;
|
||||
WcmdqInc();
|
||||
} // end of DoPitch
|
||||
@@ -248,7 +248,7 @@ static int DoSample2(int index, int which, int std_length, int control, int leng
|
||||
int min_length;
|
||||
int x;
|
||||
int len4;
|
||||
long *q;
|
||||
long64 *q;
|
||||
unsigned char *p;
|
||||
|
||||
index = index & 0x7fffff;
|
||||
@@ -336,7 +336,7 @@ static int DoSample2(int index, int which, int std_length, int control, int leng
|
||||
q = wcmdq[wcmdq_tail];
|
||||
q[0] = WCMD_WAVE2;
|
||||
q[1] = length | (wav_length << 16); // length in samples
|
||||
q[2] = long(&wavefile_data[index]);
|
||||
q[2] = long64(&wavefile_data[index]);
|
||||
q[3] = wav_scale + (amp << 8);
|
||||
WcmdqInc();
|
||||
return(length);
|
||||
@@ -357,7 +357,7 @@ static int DoSample2(int index, int which, int std_length, int control, int leng
|
||||
q = wcmdq[wcmdq_tail];
|
||||
q[0] = WCMD_WAVE;
|
||||
q[1] = x; // length in samples
|
||||
q[2] = long(&wavefile_data[index]);
|
||||
q[2] = long64(&wavefile_data[index]);
|
||||
q[3] = wav_scale + (amp << 8);
|
||||
WcmdqInc();
|
||||
|
||||
@@ -372,7 +372,7 @@ static int DoSample2(int index, int which, int std_length, int control, int leng
|
||||
q = wcmdq[wcmdq_tail];
|
||||
q[0] = WCMD_WAVE;
|
||||
q[1] = len4*2; // length in samples
|
||||
q[2] = long(&wavefile_data[index+x]);
|
||||
q[2] = long64(&wavefile_data[index+x]);
|
||||
q[3] = wav_scale + (amp << 8);
|
||||
WcmdqInc();
|
||||
|
||||
@@ -388,7 +388,7 @@ static int DoSample2(int index, int which, int std_length, int control, int leng
|
||||
q = wcmdq[wcmdq_tail];
|
||||
q[0] = WCMD_WAVE;
|
||||
q[1] = length; // length in samples
|
||||
q[2] = long(&wavefile_data[index+x]);
|
||||
q[2] = long64(&wavefile_data[index+x]);
|
||||
q[3] = wav_scale + (amp << 8);
|
||||
WcmdqInc();
|
||||
}
|
||||
@@ -483,7 +483,7 @@ static void set_frame_rms(frame_t *fr, int new_rms)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(fr->rms == 0) return; // check for divide by zero
|
||||
x = (new_rms * 64)/fr->rms;
|
||||
if(x >= 200) x = 199;
|
||||
@@ -507,7 +507,7 @@ static void formants_reduce_hf(frame_t *fr, int level)
|
||||
|
||||
if(voice->klattv[0])
|
||||
return;
|
||||
|
||||
|
||||
for(ix=2; ix < 8; ix++)
|
||||
{
|
||||
x = fr->fheight[ix] * level;
|
||||
@@ -594,7 +594,7 @@ static void AdjustFormants(frame_t *fr, int target, int min, int max, int f1_adj
|
||||
fr->ffreq[1] += x;
|
||||
fr->ffreq[0] += x;
|
||||
}
|
||||
formants_reduce_hf(fr,hf_reduce);
|
||||
formants_reduce_hf(fr,hf_reduce);
|
||||
}
|
||||
|
||||
|
||||
@@ -717,7 +717,7 @@ if(voice->klattv[0])
|
||||
fr = CopyFrame(seq[n_frames-1].frame,0);
|
||||
seq[n_frames-1].frame = fr;
|
||||
rms = RMS_GLOTTAL1;
|
||||
|
||||
|
||||
// degree of glottal-stop effect depends on closeness of vowel (indicated by f1 freq)
|
||||
modn_flags = 0x400 + (VowelCloseness(fr) << 8);
|
||||
}
|
||||
@@ -726,7 +726,7 @@ if(voice->klattv[0])
|
||||
fr = DuplicateLastFrame(seq,n_frames++,len);
|
||||
if(len > 36)
|
||||
seq_len_adjust += (len - 36);
|
||||
|
||||
|
||||
if(f2 != 0)
|
||||
{
|
||||
AdjustFormants(fr, f2, f2_min, f2_max, f1, f3_adj, f3_amp, flags);
|
||||
@@ -741,7 +741,7 @@ if(voice->klattv[0])
|
||||
{
|
||||
fr = CopyFrame(seq[ix].frame,0);
|
||||
seq[ix].frame = fr;
|
||||
|
||||
|
||||
for(formant=1; formant<=5; formant++)
|
||||
{
|
||||
int x;
|
||||
@@ -775,7 +775,7 @@ static void SmoothSpect(void)
|
||||
{//==========================
|
||||
// Limit the rate of frequence change of formants, to reduce chirping
|
||||
|
||||
long *q;
|
||||
long64 *q;
|
||||
frame_t *frame;
|
||||
frame_t *frame2;
|
||||
frame_t *frame1;
|
||||
@@ -817,7 +817,7 @@ static void SmoothSpect(void)
|
||||
frame1 = (frame_t *)q[3];
|
||||
if(frame1 == frame)
|
||||
{
|
||||
q[3] = (long)frame2;
|
||||
q[3] = (long64)frame2;
|
||||
frame1 = frame2;
|
||||
}
|
||||
else
|
||||
@@ -865,7 +865,7 @@ static void SmoothSpect(void)
|
||||
modified = 1;
|
||||
}
|
||||
frame2->ffreq[pk] = frame1->ffreq[pk] + allowed;
|
||||
q[2] = (long)frame2;
|
||||
q[2] = (long64)frame2;
|
||||
}
|
||||
else
|
||||
if(diff < -allowed)
|
||||
@@ -876,7 +876,7 @@ static void SmoothSpect(void)
|
||||
modified = 1;
|
||||
}
|
||||
frame2->ffreq[pk] = frame1->ffreq[pk] - allowed;
|
||||
q[2] = (long)frame2;
|
||||
q[2] = (long64)frame2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -907,7 +907,7 @@ static void SmoothSpect(void)
|
||||
{
|
||||
if(frame1 == frame)
|
||||
{
|
||||
q[2] = (long)frame2;
|
||||
q[2] = (long64)frame2;
|
||||
frame1 = frame2;
|
||||
}
|
||||
else
|
||||
@@ -949,7 +949,7 @@ static void SmoothSpect(void)
|
||||
modified = 1;
|
||||
}
|
||||
frame2->ffreq[pk] = frame1->ffreq[pk] + allowed;
|
||||
q[3] = (long)frame2;
|
||||
q[3] = (long64)frame2;
|
||||
}
|
||||
else
|
||||
if(diff < -allowed)
|
||||
@@ -960,7 +960,7 @@ static void SmoothSpect(void)
|
||||
modified = 1;
|
||||
}
|
||||
frame2->ffreq[pk] = frame1->ffreq[pk] - allowed;
|
||||
q[3] = (long)frame2;
|
||||
q[3] = (long64)frame2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -997,7 +997,7 @@ int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_L
|
||||
frame_t *frame2;
|
||||
frame_t *fr;
|
||||
int ix;
|
||||
long *q;
|
||||
long64 *q;
|
||||
int len;
|
||||
int frame_length;
|
||||
int length_factor;
|
||||
@@ -1083,7 +1083,7 @@ if(which==1)
|
||||
&& !(last_frame->frflags & FRFLAG_BREAK))
|
||||
{
|
||||
// last frame of previous sequence was zero-length, replace with first of this sequence
|
||||
wcmdq[last_wcmdq][3] = (long)frame1;
|
||||
wcmdq[last_wcmdq][3] = (long64)frame1;
|
||||
|
||||
if(last_frame->frflags & FRFLAG_BREAK_LF)
|
||||
{
|
||||
@@ -1095,7 +1095,7 @@ if(which==1)
|
||||
fr->ffreq[ix] = last_frame->ffreq[ix];
|
||||
fr->fheight[ix] = last_frame->fheight[ix];
|
||||
}
|
||||
wcmdq[last_wcmdq][3] = (long)fr;
|
||||
wcmdq[last_wcmdq][3] = (long64)fr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1180,9 +1180,9 @@ if(which==1)
|
||||
q = wcmdq[wcmdq_tail];
|
||||
q[0] = wcmd_spect;
|
||||
q[1] = len + (modulation << 16);
|
||||
q[2] = long(frame1);
|
||||
q[3] = long(frame2);
|
||||
|
||||
q[2] = (long64)frame1;
|
||||
q[3] = (long64)frame2;
|
||||
|
||||
WcmdqInc();
|
||||
}
|
||||
last_frame = frame1 = frame2;
|
||||
@@ -1237,6 +1237,7 @@ void DoPhonemeMarker(int type, int char_posn, int length, char *name)
|
||||
} // end of DoMarker
|
||||
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
void DoSonicSpeed(int value)
|
||||
{//=========================
|
||||
// value, multiplier * 1024
|
||||
@@ -1244,6 +1245,7 @@ void DoSonicSpeed(int value)
|
||||
wcmdq[wcmdq_tail][1] = value;
|
||||
WcmdqInc();
|
||||
} // end of DoSonicSpeed
|
||||
#endif
|
||||
|
||||
|
||||
void DoVoiceChange(voice_t *v)
|
||||
@@ -1254,7 +1256,7 @@ void DoVoiceChange(voice_t *v)
|
||||
v2 = (voice_t *)malloc(sizeof(voice_t));
|
||||
memcpy(v2,v,sizeof(voice_t));
|
||||
wcmdq[wcmdq_tail][0] = WCMD_VOICE;
|
||||
wcmdq[wcmdq_tail][1] = (long)(v2);
|
||||
wcmdq[wcmdq_tail][2] = (long64)v2;
|
||||
WcmdqInc();
|
||||
}
|
||||
|
||||
@@ -1291,7 +1293,7 @@ void DoEmbedded(int *embix, int sourceix)
|
||||
DoPause(10,0); // ensure a break in the speech
|
||||
wcmdq[wcmdq_tail][0] = WCMD_WAVE;
|
||||
wcmdq[wcmdq_tail][1] = soundicon_tab[value].length;
|
||||
wcmdq[wcmdq_tail][2] = (long)soundicon_tab[value].data + 44; // skip WAV header
|
||||
wcmdq[wcmdq_tail][2] = (long64)soundicon_tab[value].data + 44; // skip WAV header
|
||||
wcmdq[wcmdq_tail][3] = 0x1500; // 16 bit data, amp=21
|
||||
WcmdqInc();
|
||||
}
|
||||
@@ -1337,6 +1339,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
unsigned char *amp_env;
|
||||
PHONEME_TAB *ph;
|
||||
int use_ipa=0;
|
||||
int done_phoneme_marker;
|
||||
char phoneme_name[16];
|
||||
static int sourceix=0;
|
||||
|
||||
@@ -1345,6 +1348,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
PHONEME_DATA phdata_next;
|
||||
PHONEME_DATA phdata_tone;
|
||||
FMT_PARAMS fmtp;
|
||||
static WORD_PH_DATA worddata;
|
||||
|
||||
if(option_quiet)
|
||||
return(0);
|
||||
@@ -1369,6 +1373,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
syllable_centre = -1;
|
||||
last_pitch_cmd = -1;
|
||||
memset(vowel_transition,0,sizeof(vowel_transition));
|
||||
memset(&worddata, 0, sizeof(worddata));
|
||||
DoPause(0,0); // isolate from the previous clause
|
||||
}
|
||||
|
||||
@@ -1424,11 +1429,19 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
if(p->prepause > 0)
|
||||
DoPause(p->prepause,1);
|
||||
|
||||
if(option_phoneme_events && (p->type != phVOWEL) && (p->ph->code != phonEND_WORD))
|
||||
done_phoneme_marker = 0;
|
||||
if(option_phoneme_events && (p->ph->code != phonEND_WORD))
|
||||
{
|
||||
// Note, for vowels, do the phoneme event after the vowel-start
|
||||
WritePhMnemonic(phoneme_name, p->ph, p, use_ipa);
|
||||
DoPhonemeMarker(espeakEVENT_PHONEME, sourceix, 0, phoneme_name);
|
||||
if((p->type == phVOWEL) && (prev->type==phLIQUID || prev->type==phNASAL))
|
||||
{
|
||||
// For vowels following a liquid or nasal, do the phoneme event after the vowel-start
|
||||
}
|
||||
else
|
||||
{
|
||||
WritePhMnemonic(phoneme_name, p->ph, p, use_ipa);
|
||||
DoPhonemeMarker(espeakEVENT_PHONEME, sourceix, 0, phoneme_name);
|
||||
done_phoneme_marker = 1;
|
||||
}
|
||||
}
|
||||
|
||||
switch(p->type)
|
||||
@@ -1452,13 +1465,13 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
if(released == 0)
|
||||
p->synthflags |= SFLAG_NEXT_PAUSE;
|
||||
|
||||
InterpretPhoneme(NULL, 0, p, &phdata);
|
||||
InterpretPhoneme(NULL, 0, p, &phdata, &worddata);
|
||||
phdata.pd_control |= pd_DONTLENGTHEN;
|
||||
DoSample3(&phdata, 0, 0);
|
||||
break;
|
||||
|
||||
case phFRICATIVE:
|
||||
InterpretPhoneme(NULL, 0, p, &phdata);
|
||||
InterpretPhoneme(NULL, 0, p, &phdata, &worddata);
|
||||
|
||||
if(p->synthflags & SFLAG_LENGTHEN)
|
||||
{
|
||||
@@ -1498,7 +1511,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
if((prev->type==phVOWEL) || (prev->ph->phflags & phVOWEL2) || (ph->phflags & phPREVOICE))
|
||||
{
|
||||
// a period of voicing before the release
|
||||
InterpretPhoneme(NULL, 0x01, p, &phdata);
|
||||
InterpretPhoneme(NULL, 0x01, p, &phdata, &worddata);
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
fmtp.fmt_amp = phdata.sound_param[pd_FMT];
|
||||
|
||||
@@ -1526,7 +1539,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
{
|
||||
p->synthflags |= SFLAG_NEXT_PAUSE;
|
||||
}
|
||||
InterpretPhoneme(NULL,0, p, &phdata);
|
||||
InterpretPhoneme(NULL,0, p, &phdata, &worddata);
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
fmtp.fmt_amp = phdata.sound_param[pd_FMT];
|
||||
fmtp.wav_addr = phdata.sound_addr[pd_ADDWAV];
|
||||
@@ -1571,7 +1584,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
{
|
||||
p->synthflags |= SFLAG_NEXT_PAUSE;
|
||||
}
|
||||
InterpretPhoneme(NULL,0, p, &phdata);
|
||||
InterpretPhoneme(NULL,0, p, &phdata, &worddata);
|
||||
memset(&fmtp, 0, sizeof(fmtp));
|
||||
fmtp.std_length = phdata.pd_param[i_SET_LENGTH]*2;
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
@@ -1597,7 +1610,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
last_frame = NULL;
|
||||
}
|
||||
|
||||
InterpretPhoneme(NULL,0, p, &phdata);
|
||||
InterpretPhoneme(NULL,0, p, &phdata, &worddata);
|
||||
fmtp.std_length = phdata.pd_param[i_SET_LENGTH]*2;
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
fmtp.fmt_amp = phdata.sound_param[pd_FMT];
|
||||
@@ -1642,7 +1655,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
{
|
||||
StartSyllable();
|
||||
}
|
||||
InterpretPhoneme(NULL, 0, p, &phdata);
|
||||
InterpretPhoneme(NULL, 0, p, &phdata, &worddata);
|
||||
fmtp.std_length = phdata.pd_param[i_SET_LENGTH]*2;
|
||||
fmtp.fmt_addr = phdata.sound_addr[pd_FMT];
|
||||
fmtp.fmt_amp = phdata.sound_param[pd_FMT];
|
||||
@@ -1658,7 +1671,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
|
||||
memset(&fmtp, 0, sizeof(fmtp));
|
||||
|
||||
InterpretPhoneme(NULL, 0, p, &phdata);
|
||||
InterpretPhoneme(NULL, 0, p, &phdata, &worddata);
|
||||
fmtp.std_length = phdata.pd_param[i_SET_LENGTH] * 2;
|
||||
|
||||
if(((fmtp.fmt_addr = phdata.sound_addr[pd_VWLSTART]) != 0) && ((phdata.pd_control & pd_FORNEXTPH) == 0))
|
||||
@@ -1670,7 +1683,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
if(prev->type != phPAUSE)
|
||||
{
|
||||
// check the previous phoneme
|
||||
InterpretPhoneme(NULL, 0, prev, &phdata_prev);
|
||||
InterpretPhoneme(NULL, 0, prev, &phdata_prev, NULL);
|
||||
if((fmtp.fmt_addr = phdata_prev.sound_addr[pd_VWLSTART]) != 0)
|
||||
{
|
||||
// a vowel start has been specified by the Vowel program
|
||||
@@ -1733,7 +1746,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
DoSpect2(ph, 1, &fmtp, p, modulation);
|
||||
}
|
||||
|
||||
if(option_phoneme_events)
|
||||
if((option_phoneme_events) && (done_phoneme_marker == 0))
|
||||
{
|
||||
WritePhMnemonic(phoneme_name, p->ph, p, use_ipa);
|
||||
DoPhonemeMarker(espeakEVENT_PHONEME, sourceix, 0, phoneme_name);
|
||||
@@ -1752,7 +1765,7 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
|
||||
if(next->type != phPAUSE)
|
||||
{
|
||||
fmtp.fmt2_lenadj = 0;
|
||||
InterpretPhoneme(NULL, 0, next, &phdata_next);
|
||||
InterpretPhoneme(NULL, 0, next, &phdata_next, NULL);
|
||||
|
||||
fmtp.use_vowelin = 1;
|
||||
fmtp.transition0 = phdata_next.vowel_transition[2]; // always do vowel_transition, even if ph_VWLEND ?? consider [N]
|
||||
@@ -1928,7 +1941,7 @@ int SpeakNextClause(FILE *f_in, const void *text_in, int control)
|
||||
if(option_phonemes > 0)
|
||||
{
|
||||
fprintf(f_trans,"%s\n",translator->phon_out);
|
||||
|
||||
|
||||
if(!iswalpha(0x010d))
|
||||
{
|
||||
// check that c-caron is recognized as an alphabetic character
|
||||
|
||||
+7
-2
@@ -265,11 +265,15 @@ typedef struct {
|
||||
int std_length;
|
||||
} FMT_PARAMS;
|
||||
|
||||
typedef struct {
|
||||
PHONEME_LIST prev_vowel;
|
||||
} WORD_PH_DATA;
|
||||
|
||||
// instructions
|
||||
|
||||
#define i_RETURN 0x0001
|
||||
#define i_CONTINUE 0x0002
|
||||
#define i_NOT 0x0003
|
||||
|
||||
// Group 0 instrcutions with 8 bit operand. These values go into bits 8-15 of the instruction
|
||||
#define i_CHANGE_PHONEME 0x01
|
||||
@@ -417,7 +421,7 @@ typedef struct {
|
||||
unsigned char split_tail_start;
|
||||
unsigned char split_tail_end;
|
||||
unsigned char split_tune;
|
||||
|
||||
|
||||
unsigned char spare[8];
|
||||
int spare2; // the struct length should be a multiple of 4 bytes
|
||||
} TUNE;
|
||||
@@ -462,7 +466,7 @@ extern unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1];
|
||||
#define N_WCMDQ 170
|
||||
#define MIN_WCMDQ 25 // need this many free entries before adding new phoneme
|
||||
|
||||
extern long wcmdq[N_WCMDQ][4];
|
||||
extern long64 wcmdq[N_WCMDQ][4];
|
||||
extern int wcmdq_head;
|
||||
extern int wcmdq_tail;
|
||||
|
||||
@@ -567,6 +571,7 @@ int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_L
|
||||
int PauseLength(int pause, int control);
|
||||
int LookupPhonemeTable(const char *name);
|
||||
unsigned char *GetEnvelope(int index);
|
||||
int NumInstnWords(USHORT *prog);
|
||||
|
||||
void InitBreath(void);
|
||||
|
||||
|
||||
+103
-16
@@ -111,6 +111,20 @@ static void SetLetterBitsRange(Translator *tr, int group, int first, int last)
|
||||
}
|
||||
}
|
||||
|
||||
// ignore these characters
|
||||
static const unsigned short chars_ignore_default[] = {
|
||||
0xad, 1, // soft hyphtn
|
||||
0x200c, 1, // zero width non-joiner
|
||||
0x200d, 1, // zero width joiner
|
||||
0, 0 };
|
||||
|
||||
// alternatively, ignore characters but allow zero-width-non-joiner (lang-fa)
|
||||
static const unsigned short chars_ignore_zwnj_hyphen[] = {
|
||||
0xad, 1, // soft hyphen
|
||||
0x200c, '-', // zero width non-joiner, replace with hyphen
|
||||
0x200d, 1, // zero width joiner
|
||||
0, 0 };
|
||||
|
||||
|
||||
static Translator* NewTranslator(void)
|
||||
{//===================================
|
||||
@@ -122,6 +136,7 @@ static Translator* NewTranslator(void)
|
||||
static const wchar_t punct_in_word[2] = {'\'', 0}; // allow hyphen within words
|
||||
static const unsigned char default_tunes[6] = {0, 1, 2, 3, 0, 0};
|
||||
|
||||
|
||||
tr = (Translator *)Alloc(sizeof(Translator));
|
||||
if(tr == NULL)
|
||||
return(NULL);
|
||||
@@ -155,6 +170,7 @@ static Translator* NewTranslator(void)
|
||||
|
||||
tr->char_plus_apostrophe = empty_wstring;
|
||||
tr->punct_within_word = punct_in_word;
|
||||
tr->chars_ignore = chars_ignore_default;
|
||||
|
||||
for(ix=0; ix<8; ix++)
|
||||
{
|
||||
@@ -295,12 +311,12 @@ static void SetCyrillicLetters(Translator *tr)
|
||||
tr->letter_bits_offset = OFFSET_CYRILLIC;
|
||||
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
|
||||
SetLetterBits(tr,LETTERGP_A,(char *)ru_vowels);
|
||||
SetLetterBits(tr,1,ru_soft);
|
||||
SetLetterBits(tr,2,(char *)ru_consonants);
|
||||
SetLetterBits(tr,3,ru_hard);
|
||||
SetLetterBits(tr,4,ru_nothard);
|
||||
SetLetterBits(tr,5,ru_voiced);
|
||||
SetLetterBits(tr,6,ru_ivowels);
|
||||
SetLetterBits(tr,LETTERGP_B,ru_soft);
|
||||
SetLetterBits(tr,LETTERGP_C,(char *)ru_consonants);
|
||||
SetLetterBits(tr,LETTERGP_H,ru_hard);
|
||||
SetLetterBits(tr,LETTERGP_F,ru_nothard);
|
||||
SetLetterBits(tr,LETTERGP_G,ru_voiced);
|
||||
SetLetterBits(tr,LETTERGP_Y,ru_ivowels);
|
||||
SetLetterBits(tr,LETTERGP_VOWEL2,(char *)ru_vowels);
|
||||
} // end of SetCyrillicLetters
|
||||
|
||||
@@ -308,22 +324,23 @@ static void SetCyrillicLetters(Translator *tr)
|
||||
void SetIndicLetters(Translator *tr)
|
||||
{//=================================
|
||||
// Set letter types for Indic scripts, Devanagari, Tamill, etc
|
||||
static const char dev_consonants2[] = {0x02,0x03,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f};
|
||||
static const char dev_consonants2[] = {0x02,0x03,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,0x7b,0x7c,0x7e,0x7f,0};
|
||||
static const char dev_vowels2[] = {0x60,0x61, 0x55,0x56,0x57,0x62,0x63,0}; // non-consecutive vowels and vowel-signs
|
||||
|
||||
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
|
||||
SetLetterBitsRange(tr,LETTERGP_A,0x04,0x14); // vowel letters
|
||||
SetLetterBitsRange(tr,LETTERGP_A,0x3e,0x4d); // + vowel signs, and virama
|
||||
SetLetterBitsRange(tr,LETTERGP_A,0x55,0x57); // + vowel signs
|
||||
SetLetterBits(tr,LETTERGP_A, dev_vowels2); // + extra vowels and vowel signs
|
||||
|
||||
SetLetterBitsRange(tr,LETTERGP_B,0x3e,0x4d); // vowel signs, and virama
|
||||
SetLetterBitsRange(tr,LETTERGP_B,0x55,0x57); // + vowel signs
|
||||
SetLetterBits(tr,LETTERGP_B, dev_vowels2); // + extra vowels and vowel signs
|
||||
|
||||
SetLetterBitsRange(tr,LETTERGP_C,0x15,0x39); // the main consonant range
|
||||
SetLetterBits(tr,LETTERGP_C,dev_consonants2); // + additional consonants
|
||||
|
||||
SetLetterBitsRange(tr,LETTERGP_Y,0x04,0x14); // vowel letters
|
||||
SetLetterBitsRange(tr,LETTERGP_Y,0x3e,0x4c); // + vowel signs
|
||||
SetLetterBitsRange(tr,LETTERGP_Y,0x55,0x57); // + vowel signs
|
||||
SetLetterBits(tr,LETTERGP_Y, dev_vowels2); // + extra vowels and vowel signs
|
||||
|
||||
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
|
||||
tr->langopts.suffix_add_e = tr->letter_bits_offset + 0x4d; //virama
|
||||
@@ -649,6 +666,8 @@ Translator *SelectTranslator(const char *name)
|
||||
tr->letter_bits_offset = OFFSET_ARABIC;
|
||||
tr->langopts.numbers = NUM_AND_UNITS | NUM_HUNDRED_AND;
|
||||
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
|
||||
|
||||
tr->chars_ignore = chars_ignore_zwnj_hyphen; // replace ZWNJ by hyphen
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -711,6 +730,12 @@ Translator *SelectTranslator(const char *name)
|
||||
{
|
||||
tr->letter_bits_offset = OFFSET_GURMUKHI;
|
||||
}
|
||||
if(name2 == L('n','e'))
|
||||
{
|
||||
tr->langopts.break_numbers = 0x2aaaa8;
|
||||
tr->langopts.max_digits = 22;
|
||||
tr->langopts.numbers2 |= NUM2_ENGLISH_NUMERALS;
|
||||
}
|
||||
SetIndicLetters(tr);
|
||||
}
|
||||
break;
|
||||
@@ -738,7 +763,7 @@ Translator *SelectTranslator(const char *name)
|
||||
tr->langopts.accents = 1;
|
||||
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_DECIMAL_COMMA | NUM_THOUS_SPACE | NUM_DFRACTION_2 | NUM_ROMAN_CAPITALS;
|
||||
tr->langopts.numbers2 = 0x4a; // variant numbers before thousands,milliards
|
||||
tr->langopts.numbers2 = 0xa + NUM2_THOUSANDS_VAR5; // variant numbers before thousands,milliards
|
||||
tr->langopts.replace_chars = replace_cyrillic_latin;
|
||||
|
||||
SetLetterVowel(tr,'y');
|
||||
@@ -892,7 +917,39 @@ SetLengthMods(tr,3); // all equal
|
||||
tr->letter_bits_offset = OFFSET_GEORGIAN;
|
||||
// tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
|
||||
tr->langopts.max_initial_consonants = 7;
|
||||
tr->langopts.numbers = NUM_VIGESIMAL | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED |NUM_OMIT_1_THOUSAND | NUM_DFRACTION_5;
|
||||
tr->langopts.numbers = NUM_VIGESIMAL | NUM_AND_UNITS | NUM_OMIT_1_HUNDRED |NUM_OMIT_1_THOUSAND | NUM_DFRACTION_5 | NUM_ROMAN;
|
||||
}
|
||||
break;
|
||||
|
||||
case L('k','k'): // Kazakh
|
||||
{
|
||||
static const unsigned char stress_amps_tr[8] = {18,16, 20,21, 20,21, 21,20 };
|
||||
static const short stress_lengths_tr[8] = {190,180, 230,230, 0,0, 250,250};
|
||||
|
||||
tr->letter_bits_offset = OFFSET_CYRILLIC;
|
||||
memset(tr->letter_bits,0,sizeof(tr->letter_bits));
|
||||
SetLetterBits(tr,LETTERGP_A,(char *)ru_vowels);
|
||||
SetLetterBits(tr,LETTERGP_C,(char *)ru_consonants);
|
||||
SetLetterBits(tr,LETTERGP_VOWEL2,(char *)ru_vowels);
|
||||
|
||||
SetupTranslator(tr,stress_lengths_tr,stress_amps_tr);
|
||||
|
||||
tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
|
||||
tr->langopts.stress_flags = S_NO_AUTO_2 + S_NO_EOC_LENGTHEN; //no automatic secondary stress, don't lengthen at end-of-clause
|
||||
tr->langopts.lengthen_tonic = 0;
|
||||
tr->langopts.param[LOPT_SUFFIX] = 1;
|
||||
|
||||
tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_DFRACTION_6 ;
|
||||
tr->langopts.max_initial_consonants = 2;
|
||||
SetLengthMods(tr,3); // all equal
|
||||
}
|
||||
break;
|
||||
|
||||
case L('k','l'): // Greenlandic
|
||||
{
|
||||
tr->langopts.stress_rule = 12;
|
||||
tr->langopts.stress_flags = S_NO_AUTO_2;
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_SWAP_TENS | NUM_HUNDRED_AND | NUM_OMIT_1_HUNDRED | NUM_ORDINAL_DOT | NUM_1900 | NUM_ROMAN | NUM_ROMAN_CAPITALS | NUM_ROMAN_ORDINAL;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -934,6 +991,9 @@ SetLengthMods(tr,3); // all equal
|
||||
tr->langopts.stress_rule = 8; // ?? 1st syllable if it is heavy, else 2nd syllable
|
||||
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
|
||||
tr->langopts.numbers = NUM_OMIT_1_HUNDRED;
|
||||
tr->langopts.numbers2 = NUM2_MYRIADS;
|
||||
tr->langopts.break_numbers = 0x1111110;
|
||||
tr->langopts.max_digits = 20;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -965,6 +1025,20 @@ SetLengthMods(tr,3); // all equal
|
||||
}
|
||||
break;
|
||||
|
||||
case L('l','t'): // Lithuanian
|
||||
{
|
||||
tr->charset_a0 = charsets[4]; // ISO-8859-4
|
||||
tr->langopts.stress_rule = STRESSPOSN_2R;
|
||||
tr->langopts.stress_flags = 0x20;
|
||||
tr->langopts.unstressed_wd1 = 0;
|
||||
tr->langopts.unstressed_wd2 = 2;
|
||||
tr->langopts.param[LOPT_DIERESES] = 1;
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_DFRACTION_4 | NUM_ORDINAL_DOT;
|
||||
tr->langopts.numbers2 = NUM2_THOUSANDS_VAR4;
|
||||
tr->langopts.max_roman = 5000;
|
||||
}
|
||||
break;
|
||||
|
||||
case L('l','v'): // latvian
|
||||
{
|
||||
static const unsigned char stress_amps_lv[8] = {17,13, 20,20, 20,22, 22,21 };
|
||||
@@ -1059,7 +1133,7 @@ SetLengthMods(tr,3); // all equal
|
||||
tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x9;
|
||||
tr->langopts.max_initial_consonants = 7; // for example: wchrzczony :)
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_ALLOW_SPACE | NUM_DFRACTION_2;
|
||||
tr->langopts.numbers2 = 0x40;
|
||||
tr->langopts.numbers2 = NUM2_THOUSANDS_VAR3;
|
||||
tr->langopts.param[LOPT_COMBINE_WORDS] = 4 + 0x100; // combine 'nie' (marked with $alt2) with some 1-syllable (and 2-syllable) words (marked with $alt)
|
||||
SetLetterVowel(tr,'y');
|
||||
}
|
||||
@@ -1076,6 +1150,7 @@ SetLengthMods(tr,3); // all equal
|
||||
tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
|
||||
tr->langopts.stress_flags = 0x6 | 0x10 | 0x2000 | 0x20000;
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_DFRACTION_2 | NUM_HUNDRED_AND | NUM_AND_UNITS | NUM_ROMAN;
|
||||
tr->langopts.numbers2 = NUM2_MULTIPLE_ORDINAL | NUM2_NO_TEEN_ORDINALS;
|
||||
SetLetterVowel(tr,'y');
|
||||
ResetLetterBits(tr,0x2);
|
||||
SetLetterBits(tr,1,"bcdfgjkmnpqstvxz"); // B hard consonants, excluding h,l,r,w,y
|
||||
@@ -1130,7 +1205,7 @@ SetLengthMods(tr,3); // all equal
|
||||
tr->langopts.param[LOPT_COMBINE_WORDS] = 4; // combine some prepositions with the following word
|
||||
|
||||
tr->langopts.numbers = NUM_OMIT_1_HUNDRED | NUM_DFRACTION_2 | NUM_ROMAN;
|
||||
tr->langopts.numbers2 = 0x100;
|
||||
tr->langopts.numbers2 = NUM2_THOUSANDS_VAR2;
|
||||
tr->langopts.thousands_sep = STRESSPOSN_1L; //no thousands separator
|
||||
tr->langopts.decimal_sep = ',';
|
||||
|
||||
@@ -1166,7 +1241,9 @@ SetLengthMods(tr,3); // all equal
|
||||
|
||||
tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
|
||||
tr->langopts.suffix_add_e = tr->letter_bits_offset + 0x4a; //virama
|
||||
tr->langopts.numbers = NUM_OMIT_1_THOUSAND ;
|
||||
tr->langopts.numbers = NUM_OMIT_1_THOUSAND | NUM_SINGLE_STRESS_L | NUM_DFRACTION_7;
|
||||
tr->langopts.numbers2 = NUM2_PERCENT_BEFORE;
|
||||
tr->langopts.break_numbers = 0x14aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1318,6 +1395,16 @@ SetLengthMods(tr,3); // all equal
|
||||
}
|
||||
break;
|
||||
|
||||
case L('t','t'): // Tatar
|
||||
{
|
||||
SetCyrillicLetters(tr);
|
||||
SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
|
||||
tr->langopts.stress_rule = STRESSPOSN_1R; // stress on final syllable
|
||||
tr->langopts.stress_flags = 0x20; //no automatic secondary stress
|
||||
tr->langopts.numbers = NUM_SINGLE_STRESS | NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED | NUM_OMIT_1_THOUSAND | NUM_DFRACTION_4;
|
||||
}
|
||||
break;
|
||||
|
||||
case L('u','k'): // Ukrainian
|
||||
{
|
||||
SetCyrillicLetters(tr);
|
||||
@@ -1438,7 +1525,7 @@ static void Translator_Russian(Translator *tr)
|
||||
tr->langopts.stress_flags = 0x0020; // waas 0x1010
|
||||
|
||||
tr->langopts.numbers = NUM_DECIMAL_COMMA | NUM_OMIT_1_HUNDRED;
|
||||
tr->langopts.numbers2 = 0xc2; // variant numbers before thousands
|
||||
tr->langopts.numbers2 = 0x2 + NUM2_THOUSANDS_VAR1; // variant numbers before thousands
|
||||
tr->langopts.phoneme_change = 1;
|
||||
tr->langopts.testing = 2;
|
||||
|
||||
|
||||
+178
-97
@@ -372,7 +372,7 @@ int IsAlpha(unsigned int c)
|
||||
{//========================
|
||||
// Replacement for iswalph() which also checks for some in-word symbols
|
||||
|
||||
const unsigned short extra_indic_alphas[] = {
|
||||
static const unsigned short extra_indic_alphas[] = {
|
||||
0xa70,0xa71, // Gurmukhi: tippi, addak
|
||||
0 };
|
||||
|
||||
@@ -392,6 +392,9 @@ int IsAlpha(unsigned int c)
|
||||
return(0);
|
||||
}
|
||||
|
||||
if(c == 0x0605)
|
||||
return(1);
|
||||
|
||||
if((c >= 0x64b) && (c <= 0x65e))
|
||||
return(1); // arabic vowel marks
|
||||
|
||||
@@ -407,6 +410,9 @@ int IsAlpha(unsigned int c)
|
||||
if((c >= 0x1100) && (c <= 0x11ff))
|
||||
return(1); //Korean jamo
|
||||
|
||||
if((c >= 0x2800) && (c <= 0x28ff))
|
||||
return(1); // braille
|
||||
|
||||
if((c > 0x3040) && (c <= 0xa700))
|
||||
return(1); // Chinese/Japanese. Should never get here, but Mac OS 10.4's iswalpha seems to be broken, so just make sure
|
||||
|
||||
@@ -464,6 +470,22 @@ int lookupwchar(const unsigned short *list,int c)
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int lookupwchar2(const unsigned short *list,int c)
|
||||
{//==============================================
|
||||
// Replace character c by another character.
|
||||
// Returns 0 = not found, 1 = delete character
|
||||
int ix;
|
||||
|
||||
for(ix=0; list[ix] != 0; ix+=2)
|
||||
{
|
||||
if(list[ix] == c)
|
||||
return(list[ix+1]);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int IsBracket(int c)
|
||||
{//=================
|
||||
if((c >= 0x2014) && (c <= 0x201f))
|
||||
@@ -526,7 +548,7 @@ int utf8_nbytes(const char *buf)
|
||||
|
||||
int utf8_in2(int *c, const char *buf, int backwards)
|
||||
{//=================================================
|
||||
// Read a unicode characater from a UTF8 string
|
||||
// Read a unicode characater from a UTF8 string
|
||||
// Returns the number of UTF8 bytes used.
|
||||
// backwards: set if we are moving backwards through the UTF8 string
|
||||
int c1;
|
||||
@@ -570,7 +592,7 @@ int utf8_in2(int *c, const char *buf, int backwards)
|
||||
|
||||
int utf8_in(int *c, const char *buf)
|
||||
{//=================================
|
||||
// Read a unicode characater from a UTF8 string
|
||||
// Read a unicode characater from a UTF8 string
|
||||
// Returns the number of UTF8 bytes used.
|
||||
return(utf8_in2(c,buf,0));
|
||||
}
|
||||
@@ -797,24 +819,28 @@ int TranslateWord(Translator *tr, char *word_start, int next_pause, WORD_TAB *wt
|
||||
unsigned int dictionary_flags[2];
|
||||
unsigned int dictionary_flags2[2];
|
||||
int end_type=0;
|
||||
int end_type1=0;
|
||||
int prefix_type=0;
|
||||
int prefix_stress;
|
||||
char *wordx;
|
||||
char phonemes[N_WORD_PHONEMES];
|
||||
char phonemes2[N_WORD_PHONEMES];
|
||||
char prefix_phonemes[N_WORD_PHONEMES];
|
||||
char unpron_phonemes[N_WORD_PHONEMES];
|
||||
char end_phonemes[N_WORD_PHONEMES];
|
||||
char end_phonemes2[N_WORD_PHONEMES];
|
||||
char word_copy[N_WORD_BYTES];
|
||||
char word_copy2[N_WORD_BYTES];
|
||||
int word_copy_length;
|
||||
char prefix_chars[0x3f + 2];
|
||||
char prefix_chars[0x3f + 2];
|
||||
int found=0;
|
||||
int end_flags;
|
||||
int end_flags;
|
||||
char c_temp; // save a character byte while we temporarily replace it with space
|
||||
int first_char;
|
||||
int last_char = 0;
|
||||
int add_plural_suffix = 0;
|
||||
int prefix_flags = 0;
|
||||
int more_suffixes;
|
||||
int confirm_prefix;
|
||||
int spell_word;
|
||||
int stress_bits;
|
||||
@@ -974,17 +1000,24 @@ if((wmark > 0) && (wmark < 8))
|
||||
// the word has $abbrev flag, but no pronunciation specified. Speak as individual letters
|
||||
spell_word = 1;
|
||||
}
|
||||
|
||||
|
||||
if(!found && iswdigit(first_char))
|
||||
{
|
||||
Lookup(tr,"_0lang",word_phonemes);
|
||||
if(word_phonemes[0] == phonSWITCH)
|
||||
return(0);
|
||||
|
||||
if((tr->langopts.numbers2 & NUM2_ENGLISH_NUMERALS) && !(wtab->flags & FLAG_CHAR_REPLACED))
|
||||
{
|
||||
// for this language, speak English numerals (0-9) with the English voice
|
||||
sprintf(word_phonemes,"%c",phonSWITCH);
|
||||
return(0);
|
||||
}
|
||||
|
||||
found = TranslateNumber(tr, word1, phonemes, dictionary_flags, wtab, 0);
|
||||
}
|
||||
|
||||
if(!found & ((wflags & FLAG_UPPERS) != FLAG_FIRST_UPPER))
|
||||
if(!found && ((wflags & FLAG_UPPERS) != FLAG_FIRST_UPPER))
|
||||
{
|
||||
// either all upper or all lower case
|
||||
|
||||
@@ -1128,7 +1161,6 @@ if((wmark > 0) && (wmark < 8))
|
||||
if(confirm_prefix && !(end_type & SUFX_B))
|
||||
{
|
||||
int end2;
|
||||
char phonemes2[N_WORD_PHONEMES];
|
||||
char end_phonemes2[N_WORD_PHONEMES];
|
||||
|
||||
// remove any standard suffix and confirm that the prefix is still recognised
|
||||
@@ -1183,7 +1215,7 @@ if((wmark > 0) && (wmark < 8))
|
||||
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
|
||||
@@ -1247,93 +1279,121 @@ if((wmark > 0) && (wmark < 8))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if((end_type != 0) && !(end_type & SUFX_P))
|
||||
{
|
||||
char phonemes2[N_WORD_PHONEMES];
|
||||
strcpy(phonemes2,phonemes);
|
||||
end_type1 = end_type;
|
||||
strcpy(phonemes2,phonemes);
|
||||
|
||||
// The word has a standard ending, re-translate without this ending
|
||||
end_flags = RemoveEnding(tr, wordx, end_type, word_copy);
|
||||
more_suffixes = 1;
|
||||
|
||||
phonemes[0] = 0;
|
||||
while(more_suffixes)
|
||||
{
|
||||
more_suffixes = 0;
|
||||
phonemes[0] = 0;
|
||||
|
||||
if(prefix_phonemes[0] != 0)
|
||||
{
|
||||
// lookup the stem without the prefix removed
|
||||
wordx[-1] = c_temp;
|
||||
found = LookupDictList(tr, &word1, phonemes, dictionary_flags2, end_flags, wtab); // include prefix, but not suffix
|
||||
wordx[-1] = ' ';
|
||||
if(phonemes[0] == phonSWITCH)
|
||||
{
|
||||
// change to another language in order to translate this word
|
||||
memcpy(wordx,word_copy,strlen(word_copy));
|
||||
strcpy(word_phonemes,phonemes);
|
||||
return(0);
|
||||
}
|
||||
if(dictionary_flags[0]==0)
|
||||
{
|
||||
dictionary_flags[0] = dictionary_flags2[0];
|
||||
dictionary_flags[1] = dictionary_flags2[1];
|
||||
}
|
||||
if(found)
|
||||
prefix_phonemes[0] = 0; // matched whole word, don't need prefix now
|
||||
if(prefix_phonemes[0] != 0)
|
||||
{
|
||||
// lookup the stem without the prefix removed
|
||||
wordx[-1] = c_temp;
|
||||
found = LookupDictList(tr, &word1, phonemes, dictionary_flags2, end_flags, wtab); // include prefix, but not suffix
|
||||
wordx[-1] = ' ';
|
||||
if(phonemes[0] == phonSWITCH)
|
||||
{
|
||||
// change to another language in order to translate this word
|
||||
memcpy(wordx,word_copy,strlen(word_copy));
|
||||
strcpy(word_phonemes,phonemes);
|
||||
return(0);
|
||||
}
|
||||
if(dictionary_flags[0]==0)
|
||||
{
|
||||
dictionary_flags[0] = dictionary_flags2[0];
|
||||
dictionary_flags[1] = dictionary_flags2[1];
|
||||
}
|
||||
if(found)
|
||||
prefix_phonemes[0] = 0; // matched whole word, don't need prefix now
|
||||
|
||||
if((found==0) && (dictionary_flags2[0] != 0))
|
||||
prefix_flags = 1;
|
||||
}
|
||||
if(found == 0)
|
||||
{
|
||||
found = LookupDictList(tr, &wordx, phonemes, dictionary_flags2, end_flags, wtab); // without prefix and suffix
|
||||
if(phonemes[0] == phonSWITCH)
|
||||
{
|
||||
// change to another language in order to translate this word
|
||||
memcpy(wordx,word_copy,strlen(word_copy));
|
||||
strcpy(word_phonemes,phonemes);
|
||||
return(0);
|
||||
}
|
||||
if((found==0) && (dictionary_flags2[0] != 0))
|
||||
prefix_flags = 1;
|
||||
}
|
||||
if(found == 0)
|
||||
{
|
||||
found = LookupDictList(tr, &wordx, phonemes, dictionary_flags2, end_flags, wtab); // without prefix and suffix
|
||||
if(phonemes[0] == phonSWITCH)
|
||||
{
|
||||
// change to another language in order to translate this word
|
||||
memcpy(wordx,word_copy,strlen(word_copy));
|
||||
strcpy(word_phonemes,phonemes);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if(dictionary_flags2[0] & FLAG_ABBREV)
|
||||
{
|
||||
// Removing the suffix leaves a word which should be spoken as individual letters
|
||||
// Not yet implemented
|
||||
}
|
||||
if(dictionary_flags[0]==0)
|
||||
{
|
||||
dictionary_flags[0] = dictionary_flags2[0];
|
||||
dictionary_flags[1] = dictionary_flags2[1];
|
||||
}
|
||||
}
|
||||
if(found == 0)
|
||||
{
|
||||
if(end_type & SUFX_Q)
|
||||
{
|
||||
// don't retranslate, use the original lookup result
|
||||
strcpy(phonemes,phonemes2);
|
||||
if(dictionary_flags2[0] & FLAG_ABBREV)
|
||||
{
|
||||
// Removing the suffix leaves a word which should be spoken as individual letters
|
||||
// Not yet implemented
|
||||
}
|
||||
if(dictionary_flags[0]==0)
|
||||
{
|
||||
dictionary_flags[0] = dictionary_flags2[0];
|
||||
dictionary_flags[1] = dictionary_flags2[1];
|
||||
}
|
||||
}
|
||||
if(found == 0)
|
||||
{
|
||||
if(end_type & SUFX_Q)
|
||||
{
|
||||
// don't retranslate, use the original lookup result
|
||||
strcpy(phonemes,phonemes2);
|
||||
|
||||
// language specific changes
|
||||
ApplySpecialAttribute(tr,phonemes,dictionary_flags[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(end_flags & FLAG_SUFX)
|
||||
wflags |= FLAG_SUFFIX_REMOVED;
|
||||
if(end_type & SUFX_A)
|
||||
wflags |= FLAG_SUFFIX_VOWEL;
|
||||
// language specific changes
|
||||
ApplySpecialAttribute(tr,phonemes,dictionary_flags[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(end_flags & FLAG_SUFX)
|
||||
wflags |= FLAG_SUFFIX_REMOVED;
|
||||
if(end_type & SUFX_A)
|
||||
wflags |= FLAG_SUFFIX_VOWEL;
|
||||
|
||||
TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, NULL, wflags, dictionary_flags);
|
||||
if(end_type & SUFX_M)
|
||||
{
|
||||
// allow more suffixes before this suffix
|
||||
strcpy(end_phonemes2, end_phonemes);
|
||||
end_type = TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, end_phonemes, wflags, dictionary_flags);
|
||||
strcat(end_phonemes, end_phonemes2); // add the phonemes for the previous suffixes after this one
|
||||
|
||||
if(phonemes[0] == phonSWITCH)
|
||||
{
|
||||
// change to another language in order to translate this word
|
||||
strcpy(word_phonemes,phonemes);
|
||||
memcpy(wordx,word_copy,strlen(word_copy));
|
||||
wordx[-1] = c_temp;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if((end_type != 0) && !(end_type & SUFX_P))
|
||||
{
|
||||
// there is another suffix
|
||||
end_flags = RemoveEnding(tr, wordx, end_type, NULL);
|
||||
more_suffixes = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// don't remove any previous suffix
|
||||
TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, NULL, wflags, dictionary_flags);
|
||||
end_type = 0;
|
||||
}
|
||||
|
||||
if((end_type & SUFX_T) == 0)
|
||||
if(phonemes[0] == phonSWITCH)
|
||||
{
|
||||
// change to another language in order to translate this word
|
||||
strcpy(word_phonemes,phonemes);
|
||||
memcpy(wordx,word_copy,strlen(word_copy));
|
||||
wordx[-1] = c_temp;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((end_type1 & SUFX_T) == 0)
|
||||
{
|
||||
// the default is to add the suffix and then determine the word's stress pattern
|
||||
AppendPhonemes(tr,phonemes, N_WORD_PHONEMES, end_phonemes);
|
||||
@@ -1341,6 +1401,10 @@ if(dictionary_flags2[0] & FLAG_ABBREV)
|
||||
}
|
||||
memcpy(wordx,word_copy,strlen(word_copy));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
wordx[-1] = c_temp;
|
||||
}
|
||||
}
|
||||
@@ -1482,7 +1546,7 @@ if(dictionary_flags2[0] & FLAG_ABBREV)
|
||||
|
||||
// dictionary flags for this word give a clue about which alternative pronunciations of
|
||||
// following words to use.
|
||||
if(end_type & SUFX_F)
|
||||
if(end_type1 & SUFX_F)
|
||||
{
|
||||
// expect a verb form, with or without -s suffix
|
||||
tr->expect_verb = 2;
|
||||
@@ -1830,7 +1894,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((sylimit & 0x200) && ((wtab+1)->flags & FLAG_LAST_WORD))
|
||||
{
|
||||
// not if the next word is end-of-sentence
|
||||
@@ -2050,7 +2114,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
else
|
||||
if(ph_code == phonX1)
|
||||
{
|
||||
// a language specific action
|
||||
// a language specific action
|
||||
if(tr->langopts.param[LOPT_IT_DOUBLING])
|
||||
{
|
||||
flags |= FLAG_DOUBLING;
|
||||
@@ -2096,7 +2160,7 @@ static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pa
|
||||
{
|
||||
if(first_phoneme && tr->langopts.param[LOPT_IT_DOUBLING])
|
||||
{
|
||||
if(((tr->prev_dict_flags & FLAG_DOUBLING) && (tr->langopts.param[LOPT_IT_DOUBLING] & 1)) ||
|
||||
if(((tr->prev_dict_flags & FLAG_DOUBLING) && (tr->langopts.param[LOPT_IT_DOUBLING] & 1)) ||
|
||||
(tr->end_stressed_vowel && (tr->langopts.param[LOPT_IT_DOUBLING] & 2)))
|
||||
{
|
||||
// italian, double the initial consonant if the previous word ends with a
|
||||
@@ -2223,7 +2287,7 @@ static int EmbeddedCommand(unsigned int &source_index)
|
||||
|
||||
|
||||
|
||||
static int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in, int *insert)
|
||||
static int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in, int *insert, int *wordflags)
|
||||
{//=========================================================================================
|
||||
int ix;
|
||||
unsigned int word;
|
||||
@@ -2285,12 +2349,14 @@ static int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in,
|
||||
|
||||
if(upper_case)
|
||||
new_c = towupper(new_c);
|
||||
|
||||
*wordflags |= FLAG_CHAR_REPLACED;
|
||||
return(new_c);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static int TranslateChar(Translator *tr, char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert)
|
||||
static int TranslateChar(Translator *tr, char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert, int *wordflags)
|
||||
{//================================================================================================================
|
||||
// To allow language specific examination and replacement of characters
|
||||
|
||||
@@ -2368,7 +2434,7 @@ static int TranslateChar(Translator *tr, char *ptr, int prev_in, unsigned int c,
|
||||
}
|
||||
break;
|
||||
}
|
||||
return(SubstituteChar(tr,c,next_in,insert));
|
||||
return(SubstituteChar(tr, c, next_in, insert, wordflags));
|
||||
}
|
||||
|
||||
|
||||
@@ -2659,7 +2725,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
|
||||
}
|
||||
#endif
|
||||
if((c == 0x92) || (c == 0xb4) || (c == 0x2019) || (c == 0x2032))
|
||||
c = '\''; // 'microsoft' quote or sexed closing single quote, or prime - possibly used as apostrophe
|
||||
c = '\''; // 'microsoft' quote or sexed closing single quote, or prime - possibly used as apostrophe
|
||||
|
||||
if(((c == 0x2018) || (c == '?')) && IsAlpha(prev_out) && IsAlpha(next_in))
|
||||
{
|
||||
@@ -2680,7 +2746,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
|
||||
word_flags |= FLAG_COMMA_AFTER;
|
||||
}
|
||||
|
||||
c = TranslateChar(tr, &source[source_index], prev_in,c, next_in, &char_inserted); // optional language specific function
|
||||
c = TranslateChar(tr, &source[source_index], prev_in,c, next_in, &char_inserted, &word_flags); // optional language specific function
|
||||
if(c == 8)
|
||||
continue; // ignore this character
|
||||
|
||||
@@ -2724,7 +2790,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
|
||||
{
|
||||
if((next_in == '\002') || ((next_in == '[') && option_phoneme_input))
|
||||
{
|
||||
// "[\002" is used internally to start phoneme mode
|
||||
// "[\002" is used internally to start phoneme mode
|
||||
phoneme_mode = FLAG_PHONEMES;
|
||||
source_index++;
|
||||
continue;
|
||||
@@ -2766,6 +2832,20 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
|
||||
|
||||
letter_count++;
|
||||
|
||||
if(tr->letter_bits_offset > 0)
|
||||
{
|
||||
if(((c < 0x250) && (prev_out >= tr->letter_bits_offset)) ||
|
||||
((c >= tr->letter_bits_offset) && (letter_count > 1) && (prev_out < 0x250)))
|
||||
{
|
||||
// Don't mix native and Latin characters in the same word
|
||||
// Break into separate words
|
||||
c = ' ';
|
||||
space_inserted = 1;
|
||||
word_flags |= FLAG_HYPHEN_AFTER;
|
||||
next_word_flags |= FLAG_HYPHEN;
|
||||
}
|
||||
}
|
||||
|
||||
if(iswupper(c))
|
||||
{
|
||||
c = towlower2(c);
|
||||
@@ -2829,7 +2909,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
|
||||
if(!IsSpace(prev_in) && IsAlpha(next_in))
|
||||
{
|
||||
if(prev_out != ' ')
|
||||
{
|
||||
{
|
||||
// previous 'word' not yet ended (not alpha or numeric), start new word now.
|
||||
c = ' ';
|
||||
space_inserted = 1;
|
||||
@@ -3065,7 +3145,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
|
||||
if((word_count==0) && (embedded_count > 0))
|
||||
{
|
||||
// add a null 'word' to carry the embedded command flag
|
||||
embedded_list[embedded_ix-1] |= 0x80;
|
||||
embedded_list[embedded_ix-1] |= 0x80;
|
||||
words[word_count].flags |= FLAG_EMBEDDED;
|
||||
word_count = 1;
|
||||
}
|
||||
@@ -3081,7 +3161,7 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
|
||||
ix--; // the last word is a bracket, mark the previous word as last
|
||||
words[ix].flags |= FLAG_LAST_WORD;
|
||||
|
||||
// FLAG_NOSPACE check to avoid recognizing .mr -mr
|
||||
// FLAG_NOSPACE check to avoid recognizing .mr -mr
|
||||
if((terminator & CLAUSE_DOT) && !(words[word_count-1].flags & FLAG_NOSPACE))
|
||||
words[word_count-1].flags |= FLAG_HAS_DOT;
|
||||
}
|
||||
@@ -3161,7 +3241,8 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre
|
||||
break;
|
||||
|
||||
*pn++ = c;
|
||||
if((--nx > 0) && (tr->langopts.break_numbers & (1 << nx)))
|
||||
nx--;
|
||||
if((nx > 0) && (tr->langopts.break_numbers & (1 << nx)))
|
||||
{
|
||||
memcpy(&num_wtab[nw++], &words[ix], sizeof(WORD_TAB)); // copy the 'words' entry for each word of numbers
|
||||
|
||||
|
||||
+33
-14
@@ -18,7 +18,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#define L(c1,c2) (c1<<8)+c2 // combine two characters into an integer for translator name
|
||||
#define L(c1,c2) (c1<<8)+c2 // combine two characters into an integer for translator name
|
||||
|
||||
#define CTRL_EMBEDDED 0x01 // control character at the start of an embedded command
|
||||
#define REPLACED_E 'E' // 'e' replaced by silent e
|
||||
@@ -29,7 +29,7 @@
|
||||
#define N_RULE_GROUP2 120 // max num of two-letter rule chains
|
||||
#define N_HASH_DICT 1024
|
||||
#define N_CHARSETS 20
|
||||
#define N_LETTER_GROUPS 26
|
||||
#define N_LETTER_GROUPS 95 // maximum is 127-32
|
||||
|
||||
|
||||
/* dictionary flags, word 1 */
|
||||
@@ -52,7 +52,7 @@
|
||||
#define FLAG_STEM 0x40000 // must have a suffix
|
||||
|
||||
#define FLAG_DOUBLING 0x80000 // doubles the following consonant
|
||||
#define BITNUM_FLAG_ALT 19 // bit number of FLAG_ALT_TRANS - 1
|
||||
#define BITNUM_FLAG_ALT 19 // bit number of FLAG_ALT_TRANS - 1
|
||||
#define FLAG_ALT_TRANS 0x100000 // language specific
|
||||
#define FLAG_ALT2_TRANS 0x200000 // language specific
|
||||
#define FLAG_ALT3_TRANS 0x400000 // language specific
|
||||
@@ -110,6 +110,7 @@
|
||||
#define FLAG_MULTIPLE_SPACES 0x40000 // word is preceded by multiple spaces, newline, or tab
|
||||
#define FLAG_INDIVIDUAL_DIGITS 0x80000 // speak number as individual digits
|
||||
#define FLAG_DELETE_WORD 0x100000 // don't speak this word, it has been spoken as part of the previous word
|
||||
#define FLAG_CHAR_REPLACED 0x200000 // characters have been replaced by .replace in the *_rules
|
||||
|
||||
#define FLAG_SUFFIX_VOWEL 0x08000000 // remember an initial vowel from the suffix
|
||||
#define FLAG_NO_TRACE 0x10000000 // passed to TranslateRules() to suppress dictionary lookup printout
|
||||
@@ -128,6 +129,7 @@
|
||||
#define SUFX_T 0x10000 // don't affect the stress position in the stem
|
||||
#define SUFX_B 0x20000 // break, this character breaks the word into stem and suffix (used with SUFX_P)
|
||||
#define SUFX_A 0x40000 // remember that the suffix starts with a vowel
|
||||
#define SUFX_M 0x80000 // bit 19, allow multiple suffixes
|
||||
|
||||
#define SUFX_UNPRON 0x8000 // used to return $unpron flag from *_rules
|
||||
|
||||
@@ -234,7 +236,7 @@ typedef struct {
|
||||
int end_type;
|
||||
char *del_fwd;
|
||||
} MatchRecord;
|
||||
|
||||
|
||||
|
||||
// used to mark words with the source[] buffer
|
||||
typedef struct{
|
||||
@@ -376,7 +378,7 @@ typedef struct {
|
||||
// bit20= hyphenated words, 2nd part is unstressed
|
||||
// bit21= don't lengthen vowels at end-of-clause
|
||||
|
||||
int stress_flags;
|
||||
int stress_flags;
|
||||
int unstressed_wd1; // stress for $u word of 1 syllable
|
||||
int unstressed_wd2; // stress for $u word of >1 syllable
|
||||
int param[N_LOPTS];
|
||||
@@ -401,6 +403,7 @@ typedef struct {
|
||||
#define NUM_DFRACTION_4 0x8000
|
||||
#define NUM_DFRACTION_5 0xa000
|
||||
#define NUM_DFRACTION_6 0xc000
|
||||
#define NUM_DFRACTION_7 0xe000 // lang=si, alternative form of number for decimal fraction digits (except the last)
|
||||
#define NUM_ORDINAL_DOT 0x10000
|
||||
#define NUM_NOPAUSE 0x20000
|
||||
#define NUM_AND_HUNDRED 0x40000
|
||||
@@ -413,6 +416,7 @@ typedef struct {
|
||||
#define NUM_ROMAN_CAPITALS 0x2000000
|
||||
#define NUM_ROMAN_AFTER 0x4000000
|
||||
#define NUM_ROMAN_ORDINAL 0x8000000
|
||||
#define NUM_SINGLE_STRESS_L 0x10000000
|
||||
|
||||
// bits0-1=which numbers routine to use.
|
||||
// bit2= thousands separator must be space
|
||||
@@ -441,15 +445,28 @@ typedef struct {
|
||||
// bit25= Roman numbers only if upper case
|
||||
// bit26= say "roman" after the number, not before
|
||||
// bit27= Roman numbers are ordinal numbers
|
||||
// bit28= only one primary stress in tens+units (on the tens)
|
||||
int numbers;
|
||||
|
||||
#define NUM2_THOUSANDS_VAR1 0x40
|
||||
#define NUM2_THOUSANDS_VAR2 0x80
|
||||
#define NUM2_THOUSANDS_VAR3 0xc0
|
||||
#define NUM2_THOUSANDS_VAR4 0x100
|
||||
#define NUM2_THOUSANDS_VAR5 0x140
|
||||
|
||||
#define NUM2_MULTIPLE_ORDINAL 0x1000
|
||||
#define NUM2_NO_TEEN_ORDINALS 0x2000
|
||||
#define NUM2_MYRIADS 0x4000
|
||||
#define NUM2_ENGLISH_NUMERALS 0x8000
|
||||
#define NUM2_PERCENT_BEFORE 0x10000
|
||||
// bits 1-4 use variant form of numbers before thousands,millions,etc.
|
||||
// bit6=(LANG=pl) two forms of plural, M or MA
|
||||
// bit7=(LANG-ru) use MB for 1 thousand, million, etc
|
||||
// bit8=(LANG=cs,sk) two forms of plural, M or MA
|
||||
// bits 6-8 use different forms of thousand, million, etc (M MA MB)
|
||||
// bit9=(LANG=rw) say "thousand" and "million" before its number, not after
|
||||
// bit12=(LANG=el,es) use ordinal form of hundreds and tens as well as units
|
||||
// bit13=(LANG=pt) don't use 11-19 numbers to make ordinals
|
||||
// bit14=(LANG=ko) use myriads (groups of 4 digits) not thousands (groups of 3)
|
||||
// bit15=(LANG=ne) speak (non-replaced) English numerals in English
|
||||
// bit16=(LANG=si) say "%" before the number
|
||||
int numbers2;
|
||||
|
||||
#define BREAK_THOUSANDS 0x49249248
|
||||
@@ -517,6 +534,7 @@ typedef struct
|
||||
const unsigned short *charset_a0; // unicodes for characters 0xa0 to oxff
|
||||
const wchar_t *char_plus_apostrophe; // single chars + apostrophe treated as words
|
||||
const wchar_t *punct_within_word; // allow these punctuation characters within words
|
||||
const unsigned short *chars_ignore;
|
||||
|
||||
// holds properties of characters: vowel, consonant, etc for pronunciation rules
|
||||
unsigned char letter_bits[256];
|
||||
@@ -535,18 +553,18 @@ typedef struct
|
||||
|
||||
// groups1 and groups2 are indexes into data_dictrules, set up by InitGroups()
|
||||
// the two-letter rules for each letter must be consecutive in the language_rules source
|
||||
|
||||
|
||||
char *groups1[256]; // translation rule lists, index by single letter
|
||||
char *groups3[128]; // index by offset letter
|
||||
char *groups2[N_RULE_GROUP2]; // translation rule lists, indexed by two-letter pairs
|
||||
unsigned int groups2_name[N_RULE_GROUP2]; // the two letter pairs for groups2[]
|
||||
int n_groups2; // number of groups2[] entries used
|
||||
|
||||
|
||||
unsigned char groups2_count[256]; // number of 2 letter groups for this initial letter
|
||||
unsigned char groups2_start[256]; // index into groups2
|
||||
const short *frequent_pairs; // list of frequent pairs of letters, for use in compressed *_list
|
||||
|
||||
|
||||
|
||||
|
||||
int expect_verb;
|
||||
int expect_past; // expect past tense
|
||||
int expect_verb_s;
|
||||
@@ -556,7 +574,7 @@ typedef struct
|
||||
|
||||
int word_vowel_count; // number of vowels so far
|
||||
int word_stressed_count; // number of vowels so far which could be stressed
|
||||
|
||||
|
||||
int clause_upper_count; // number of upper case letters in the clause
|
||||
int clause_lower_count; // number of lower case letters in the clause
|
||||
|
||||
@@ -629,6 +647,7 @@ int utf8_in2(int *c, const char *buf, int backwards);
|
||||
int utf8_out(unsigned int c, char *buf);
|
||||
int utf8_nbytes(const char *buf);
|
||||
int lookupwchar(const unsigned short *list,int c);
|
||||
int lookupwchar2(const unsigned short *list,int c);
|
||||
int Eof(void);
|
||||
char *strchr_w(const char *s, int c);
|
||||
int IsBracket(int c);
|
||||
@@ -677,7 +696,7 @@ void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *t
|
||||
int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type, char *voice_change);
|
||||
|
||||
void SetVoiceStack(espeak_VOICE *v, const char *variant_name);
|
||||
void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_DATA *phdata);
|
||||
void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_DATA *phdata, WORD_PH_DATA *worddata);
|
||||
void InterpretPhoneme2(int phcode, PHONEME_DATA *phdata);
|
||||
char *WritePhMnemonic(char *phon_out, PHONEME_TAB *ph, PHONEME_LIST *plist, int use_ipa);
|
||||
|
||||
|
||||
+6
-8
@@ -325,12 +325,12 @@ void TranslDlg::SpeakFile(void)
|
||||
wxFileName fname;
|
||||
FILE *f_text;
|
||||
char buf[200];
|
||||
|
||||
|
||||
fname = wxFileName(path_speaktext);
|
||||
|
||||
file = wxFileSelector(_T("Text file to speak"),fname.GetPath(),fname.GetName(),_T(""),_T("*"),wxOPEN);
|
||||
if(file == wxEmptyString) return;
|
||||
|
||||
|
||||
strcpy(buf,file.mb_str(wxConvLocal));
|
||||
f_text = fopen(buf,"r");
|
||||
if(f_text == NULL)
|
||||
@@ -338,9 +338,9 @@ void TranslDlg::SpeakFile(void)
|
||||
wxLogError(_T("Failed to read: ")+file);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
path_speaktext = file;
|
||||
|
||||
|
||||
InitText(0);
|
||||
SpeakNextClause(f_text,NULL,0);
|
||||
return;
|
||||
@@ -465,11 +465,9 @@ void TranslDlg::OnCommand(wxCommandEvent& event)
|
||||
|
||||
case T_PROCESS:
|
||||
case MENU_SPEAK_TEXT:
|
||||
if(prosodycanvas == NULL)
|
||||
{
|
||||
myframe->OnProsody(event);
|
||||
}
|
||||
myframe->OnProsody(event);
|
||||
prosodycanvas->LayoutData(ph_list,n_ph_list);
|
||||
myframe->Refresh();
|
||||
option_phoneme_events = espeakINITIALIZE_PHONEME_EVENTS;
|
||||
option_log_frames = 1;
|
||||
MakeWave2(ph_list,n_ph_list);
|
||||
|
||||
+3
-28
@@ -525,42 +525,17 @@ static void FindVowelFmt(int prog_start, int length)
|
||||
prog_end = prog_start + length;
|
||||
n_vowelfmt_addr = 0;
|
||||
|
||||
for(prog = &phoneme_index[prog_start]; prog < &phoneme_index[prog_end]; prog++)
|
||||
for(prog = &phoneme_index[prog_start]; prog < &phoneme_index[prog_end]; prog += NumInstnWords(prog))
|
||||
{
|
||||
instn = *prog;
|
||||
|
||||
switch(instn >> 12)
|
||||
if((instn >> 12) == 11)
|
||||
{
|
||||
case 2:
|
||||
case 3:
|
||||
// conditions
|
||||
while((instn & 0xe000) == 0x2000)
|
||||
{
|
||||
instn = *(++prog);
|
||||
}
|
||||
prog--;
|
||||
break;
|
||||
|
||||
case 10: // Vowelin, Vowelout
|
||||
prog += 3;
|
||||
break;
|
||||
|
||||
case 9:
|
||||
case 12: // WAV
|
||||
case 13: // VowelStart
|
||||
case 14: // VowelEnd
|
||||
case 15: // addWav
|
||||
prog++;
|
||||
break;
|
||||
|
||||
case 11: // FMT
|
||||
// FMT instruction
|
||||
if(n_vowelfmt_addr < N_VOWELFMT_ADDR)
|
||||
{
|
||||
vowelfmt_addr[n_vowelfmt_addr++] = ((instn & 0xf) << 18) + (prog[1] << 2);
|
||||
}
|
||||
prog++;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // end of FindVowelFmt
|
||||
|
||||
+26
-8
@@ -34,9 +34,10 @@
|
||||
#include "phoneme.h"
|
||||
#include "synthesize.h"
|
||||
#include "voice.h"
|
||||
#include "sonic.h"
|
||||
|
||||
//#undef INCLUDE_KLATT
|
||||
#ifdef INCLUDE_SONIC
|
||||
#include "sonic.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_PORTAUDIO
|
||||
#include "portaudio.h"
|
||||
@@ -130,7 +131,7 @@ unsigned char *out_end;
|
||||
int outbuf_size = 0;
|
||||
|
||||
// the queue of operations passed to wavegen from sythesize
|
||||
long wcmdq[N_WCMDQ][4];
|
||||
long64 wcmdq[N_WCMDQ][4];
|
||||
int wcmdq_head=0;
|
||||
int wcmdq_tail=0;
|
||||
|
||||
@@ -150,8 +151,10 @@ static PortAudioStream *pa_stream=NULL;
|
||||
static PaStream *pa_stream=NULL;
|
||||
#endif
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
static sonicStream sonicSpeedupStream = NULL;
|
||||
double sonicSpeed = 1.0;
|
||||
#endif
|
||||
|
||||
// 1st index=roughness
|
||||
// 2nd index=modulation_type
|
||||
@@ -295,11 +298,15 @@ void WcmdqStop()
|
||||
{//=============
|
||||
wcmdq_head = 0;
|
||||
wcmdq_tail = 0;
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
if(sonicSpeedupStream != NULL)
|
||||
{
|
||||
sonicDestroyStream(sonicSpeedupStream);
|
||||
sonicSpeedupStream = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_PORTAUDIO
|
||||
Pa_AbortStream(pa_stream);
|
||||
#endif
|
||||
@@ -1868,7 +1875,7 @@ int WavegenFill2(int fill_zeros)
|
||||
// return: 0 output buffer has been filled
|
||||
// return: 1 input command queue is now empty
|
||||
|
||||
long *q;
|
||||
long64 *q;
|
||||
int length;
|
||||
int result;
|
||||
int marker_type;
|
||||
@@ -1912,14 +1919,18 @@ int WavegenFill2(int fill_zeros)
|
||||
}
|
||||
wdata.n_mix_wavefile = 0;
|
||||
wdata.amplitude_fmt = 100;
|
||||
#ifdef INCLUDE_KLATT
|
||||
KlattReset(1);
|
||||
#endif
|
||||
result = PlaySilence(length,resume);
|
||||
break;
|
||||
|
||||
case WCMD_WAVE:
|
||||
echo_complete = echo_length;
|
||||
wdata.n_mix_wavefile = 0;
|
||||
#ifdef INCLUDE_KLATT
|
||||
KlattReset(1);
|
||||
#endif
|
||||
result = PlayWave(length,resume,(unsigned char*)q[2], q[3] & 0xff, q[3] >> 8);
|
||||
break;
|
||||
|
||||
@@ -1972,8 +1983,8 @@ int WavegenFill2(int fill_zeros)
|
||||
break;
|
||||
|
||||
case WCMD_VOICE:
|
||||
WavegenSetVoice((voice_t *)q[1]);
|
||||
free((voice_t *)q[1]);
|
||||
WavegenSetVoice((voice_t *)q[2]);
|
||||
free((voice_t *)q[2]);
|
||||
break;
|
||||
|
||||
case WCMD_EMBEDDED:
|
||||
@@ -1989,9 +2000,11 @@ int WavegenFill2(int fill_zeros)
|
||||
wdata.amplitude_fmt = 100; // percentage, but value=0 means 100%
|
||||
break;
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
case WCMD_SONIC_SPEED:
|
||||
sonicSpeed = (double)q[1] / 1024;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
if(result==0)
|
||||
@@ -2009,6 +2022,7 @@ int WavegenFill2(int fill_zeros)
|
||||
} // end of WavegenFill2
|
||||
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
/* Speed up the audio samples with libsonic. */
|
||||
static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text)
|
||||
{//==============================================================================
|
||||
@@ -2035,6 +2049,7 @@ static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text
|
||||
}
|
||||
return sonicReadShortFromStream(sonicSpeedupStream, outbuf, length_out);
|
||||
} // end of SpeedUp
|
||||
#endif
|
||||
|
||||
|
||||
/* Call WavegenFill2, and then speed up the output samples. */
|
||||
@@ -2042,16 +2057,18 @@ int WavegenFill(int fill_zeros)
|
||||
{//============================
|
||||
int finished;
|
||||
unsigned char *p_start;
|
||||
int length;
|
||||
int max_length;
|
||||
|
||||
p_start = out_ptr;
|
||||
|
||||
// fill_zeros is ignored. It is now done in the portaudio callback
|
||||
finished = WavegenFill2(0);
|
||||
|
||||
#ifdef INCLUDE_SONIC
|
||||
if(sonicSpeed > 1.0)
|
||||
{
|
||||
int length;
|
||||
int max_length;
|
||||
|
||||
max_length = (out_end - p_start);
|
||||
length = 2*SpeedUp((short *)p_start, (out_ptr-p_start)/2, max_length/2, finished);
|
||||
out_ptr = p_start + length;
|
||||
@@ -2059,6 +2076,7 @@ int WavegenFill(int fill_zeros)
|
||||
if(length >= max_length)
|
||||
finished = 0; // there may be more data to flush
|
||||
}
|
||||
#endif
|
||||
return finished;
|
||||
} // end of WavegenFill
|
||||
|
||||
|
||||
Reference in New Issue
Block a user