espeakedit: Prosody window now shows the FMT() or WAV() filename and the standard length of the selected phoneme. Added the ability to produce speech at different sample rates. To use rates other than the default 22050Hz, the phoneme data must be recompiled. This needs the "sox" program to be available. (sox.sourceforge.net). espeakedit: Added menu option to compile the phoneme data at a specified sample rate (rather than the default 22050Hz). phondata: Includes the value of the sample rate at which the data was compiled. Language changes: pt. git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@302 d46cf337-b52f-0410-862d-fd96e6ae7743master
@@ -103,7 +103,7 @@ p Q r R s s; t T | |||
ts v x z | |||
Dictionary en_dict 2013-02-13 | |||
Dictionary en_dict 2013-02-20 | |||
0 0# 3 3: @ @- @2 @5 | |||
@L a a# A: A@ aa aI aI3 | |||
@@ -377,7 +377,7 @@ S s; S; t t; tS ts tS; | |||
ts; v w x z Z Z; | |||
Dictionary pt_dict 2013-02-14 | |||
Dictionary pt_dict 2013-02-19 | |||
& &/ &U~ &~ @ @- a A | |||
aI aU e E eI EI eU EU | |||
@@ -489,13 +489,13 @@ p Q r R s S t tS | |||
v w z Z | |||
Dictionary vi_dict 2013-02-10 | |||
Dictionary vi_dict 2013-02-16 | |||
@ @: @:I @:U @I @U a a: | |||
a:I a:U aI aU e E eU EU | |||
i i@ iU o O o# O# o& | |||
o@ OI oI u u@ uI y y@ | |||
yI | |||
i i@ iE iU o O o# O# | |||
o& o@ OI oI u u@ uI y | |||
y@ yI | |||
b c cr d D f g h | |||
j J J^ k kh l m n |
@@ -1022,6 +1022,7 @@ concerto k@ntS'e@toU | |||
conches k0ntSI#z | |||
concierge k0nsI'e@Z | |||
concise k0#ns'aIs | |||
conclave $1 | |||
conduct $1 | |||
conduct $verb | |||
cone koUn | |||
@@ -1136,6 +1137,7 @@ deli dElI | |||
deliberate dI2lIb@r@t | |||
delicate dElI2k@t | |||
delimit dI2lImIt // delimited | |||
delivery $alt2 | |||
demolish dI2m0lIS | |||
demon di:m@n | |||
demoness di:m@nEs |
@@ -1771,6 +1771,7 @@ | |||
di (ox d%aI | |||
_) di (s@ dI2 | |||
_) di (sa@ ,dI | |||
_) di (sarm dI2 | |||
_) disa (p ,dIs@ | |||
di (sast dI2 | |||
di (sbe@ ,dI | |||
@@ -2467,6 +2468,7 @@ | |||
er (ve 3: | |||
s) er (van 3: | |||
ery (_ @r%i | |||
?3 ery (_++$w_alt2 @rI | |||
?3 @@AC) ery (_ e@ri | |||
ery (A 3j | |||
_v) ery ErI2 | |||
@@ -2745,6 +2747,8 @@ | |||
gue (_ g | |||
gu (e g | |||
_) gu (i g | |||
_) gui (dA gaI | |||
guide (@ gaId | |||
_) g (yn g | |||
o) g (y_ g | |||
g (ynous_ =dZ | |||
@@ -3262,7 +3266,7 @@ | |||
inter (est Intr | |||
interfer Int@f'i@3 | |||
_) int (erio+ %Int | |||
_) inter (n_ %Int3: | |||
_) inter (nK %Int3: | |||
_) inter (nal %Int3: | |||
_) inter (pr %Int3: | |||
_) inter (pol@ %Int3: | |||
@@ -4576,7 +4580,7 @@ | |||
pull) ov oUv | |||
m) ov (A u:v | |||
n) ov (el 0v | |||
p) over (@ 0v@ | |||
p) over (@ 0v3 | |||
pr) ov (e# u:v | |||
gr) ov (el 0v | |||
tr) ov (er 0v | |||
@@ -4942,6 +4946,8 @@ | |||
_) re (i@P2 r,i: | |||
_) rei (c raI | |||
_) rei (l raI | |||
_) rei (s raI | |||
_) re (iss r%i: | |||
_) rele (g rElI2 | |||
rele (nt rI2lE | |||
rele (v rElI# | |||
@@ -5122,9 +5128,8 @@ | |||
1_) st (_ | |||
_) st (_ s@nt | |||
stein staIn | |||
ti) ssue Su: | |||
_) s (u s | |||
ss (ue S | |||
ssue Su: | |||
ssur S3 | |||
a) ssur SU@ | |||
a) ssure S'U@ |
@@ -14,4 +14,4 @@ stressAmp 17 16 19 19 19 19 21 19 | |||
replace 03 I i | |||
replace 03 I2 i | |||
replace 03 @ @/ | |||
@@ -6,7 +6,7 @@ consonants 10 118 | |||
base2 26 125 | |||
en 54 156 | |||
en-n 33 156 | |||
en-us 40 157 | |||
en-us 39 156 | |||
en-sc 41 158 | |||
en-rp 34 156 | |||
en-wm 31 156 | |||
@@ -44,15 +44,15 @@ consonants 10 118 | |||
es-la 1 125 | |||
ca 11 127 | |||
an 4 125 | |||
pt 30 141 | |||
pt-pt 20 141 | |||
pt 29 140 | |||
pt-pt 20 140 | |||
ro 36 148 | |||
el 10 125 | |||
grc 12 129 | |||
sv 22 129 | |||
no 28 134 | |||
is 42 141 | |||
vi 52 146 | |||
vi 53 147 | |||
zhy 41 138 | |||
zh 64 155 | |||
sw 9 110 | |||
@@ -421,7 +421,7 @@ l/l_ [l] base | |||
[l/] fr | |||
l/l_@ [l/3] base | |||
[l/] fr | |||
l/l@ [hFp] base | |||
l/l@ [L¸j] base | |||
[l#] base | |||
[l] fr | |||
[l/2] fr | |||
@@ -455,7 +455,7 @@ l/L2_oL [l/2] base | |||
l/L2_uL [l/2] base | |||
l/l_3 [l/] de | |||
l/l_4 [ll] sq | |||
l/la [hFp] base | |||
l/la [L¸j] base | |||
[l#] base | |||
[l] fr | |||
[l/2] fr | |||
@@ -463,7 +463,7 @@ l/la [hFp] base | |||
[K] tn | |||
l/l_a [l/3] base | |||
[l/] fr | |||
l/le [hFp] base | |||
l/le [L¸j] base | |||
[l#] base | |||
[l] fr | |||
[l/2] fr | |||
@@ -475,7 +475,7 @@ l/L_eL_af [&] af | |||
[&:] af | |||
l/l_front [L] sq | |||
l/l_front_ [l/4] sq | |||
l/li [hFp] base | |||
l/li [L¸j] base | |||
[l#] base | |||
[l] fr | |||
[l/2] fr | |||
@@ -489,7 +489,7 @@ ll/ll [L] base | |||
ll/_ll [L] base | |||
l/l_long [l] base | |||
[l] fr | |||
l/lo [hFp] base | |||
l/lo [L¸j] base | |||
[l#] base | |||
[l/2] fr | |||
[K] nso | |||
@@ -500,7 +500,7 @@ l^/l_rfx [l.] base | |||
[l;] lt | |||
[l] ru | |||
[l^] ru | |||
l/lu [hFp] base | |||
l/lu [L¸j] base | |||
[l#] base | |||
[l] fr | |||
[l/2] fr | |||
@@ -551,7 +551,6 @@ n/_n [n] base | |||
[n] zh | |||
n/n_ [n] base | |||
n/n@ [n] base | |||
[n.] base | |||
[n] fr | |||
[n#] is | |||
[n] zh | |||
@@ -561,7 +560,6 @@ n^/n^a [n^] base | |||
[n;] lt | |||
[n#] ru | |||
n/na [n] base | |||
[n.] base | |||
[n] fr | |||
[n#] is | |||
[n] zh | |||
@@ -569,7 +567,6 @@ n^/n^e [n^] base | |||
[n;] lt | |||
[n#] ru | |||
n/ne [n] base | |||
[n.] base | |||
[n] fr | |||
[n#] is | |||
[n] zh | |||
@@ -577,7 +574,6 @@ n^/n^i [n^] base | |||
[n;] lt | |||
[n#] ru | |||
n/ni [n] base | |||
[n.] base | |||
[n] fr | |||
[n#] is | |||
[n] zh | |||
@@ -617,18 +613,22 @@ n^/n^o [n^] base | |||
[n;] lt | |||
[n#] ru | |||
n/no [n] base | |||
[n.] base | |||
[n] fr | |||
[n#] is | |||
[n] zh | |||
n/_nr [n.] base | |||
n/nr_ [n.] base | |||
n/nr@ [n.] base | |||
n/nra [n.] base | |||
n/nre [n.] base | |||
n/nri [n.] base | |||
n/nro [n.] base | |||
n/nru [n.] base | |||
n/n-syl [n-] base | |||
n^/n^u [n^] base | |||
[n;] lt | |||
[n#] ru | |||
n/nu [n] base | |||
[n.] base | |||
[n] fr | |||
[n#] is | |||
[n] zh | |||
@@ -1345,6 +1345,7 @@ vietnam/a [a:] vi | |||
vietnam/_c [kh] vi | |||
vietnam/ch [c] vi | |||
vietnam/dd [d] vi | |||
vietnam/ie_2 [iE] vi | |||
vietnam/oe [o&] vi | |||
vietnam/th [t] vi | |||
vietnam/tr [cr] vi | |||
@@ -1367,6 +1368,7 @@ vnasal/e_n [e~] af | |||
[e~] hi | |||
[e~] pt | |||
vnasal/ii_n [I~] hi | |||
[i] vi | |||
vnasal/i_n [i~] pt | |||
vnasal/i_n2 [i~] hi | |||
vnasal/oi_n [oI~] pt | |||
@@ -1389,7 +1391,7 @@ vnasal/u_n [U~] hi | |||
vnasal/V_n [V~] hi | |||
vnasal/W_n [E~] fr | |||
[W~] fr | |||
[&2~] pt | |||
[&~] pt | |||
[E~] ht | |||
voc/bh [B] base | |||
voc/dh [D] base | |||
@@ -1537,6 +1539,7 @@ vowel/@_4 [@] en-us | |||
[@] nl | |||
[@] no | |||
vowel/@_6 [@] en | |||
[@] en-us | |||
[W] fr | |||
[W2] fr | |||
vowel/8 [o-] zh | |||
@@ -2071,8 +2074,7 @@ vowel/@_low [@] en-rp | |||
[@] pa | |||
[V] pa | |||
[@] si | |||
vowel/@_low2 [@/] en-us | |||
[@2] en-us | |||
vowel/@_low2 [@2] en-us | |||
vowel/o [o] base2 | |||
[o:] en | |||
[oU] en-n | |||
@@ -2482,52 +2484,52 @@ vwl_en_us/oor [O:] en-us | |||
vwl_en_us/or [o@] en-us | |||
[O:] en-sc | |||
vwl_en_us/ur [U@] en-us | |||
vwl_fr/@2r [] fr | |||
vwl_fr/a2r [] fr | |||
vwl_fr/aa2r [] fr | |||
vwl_fr/@2r [L¸j] fr | |||
vwl_fr/a2r [L¸j] fr | |||
vwl_fr/aa2r [L¸j] fr | |||
vwl_fr/br [r/2] fr | |||
vwl_fr/e2r [] fr | |||
vwl_fr/e_2r [] fr | |||
vwl_fr/ee2r [] fr | |||
vwl_fr/i2r [] fr | |||
vwl_fr/e2r [L¸j] fr | |||
vwl_fr/e_2r [L¸j] fr | |||
vwl_fr/ee2r [L¸j] fr | |||
vwl_fr/i2r [L¸j] fr | |||
vwl_fr/j [j/] fr | |||
vwl_fr/lo [l] fr | |||
vwl_fr/o2r [] fr | |||
vwl_fr/oo2r [] fr | |||
vwl_fr/o2r [L¸j] fr | |||
vwl_fr/oo2r [L¸j] fr | |||
vwl_fr/r [r] fr | |||
[r/2] fr | |||
vwl_fr/r_ [r/] fr | |||
vwl_fr/r_@ [r/] fr | |||
vwl_fr/r@ [] fr | |||
vwl_fr/r@ [L¸j] fr | |||
vwl_fr/@R [x] pt-pt | |||
vwl_fr/r@2 [] fr | |||
vwl_fr/r@2 [L¸j] fr | |||
vwl_fr/@R2 [R] fr-ca | |||
vwl_fr/ra [] fr | |||
vwl_fr/ra [L¸j] fr | |||
vwl_fr/r_a [r/] fr | |||
vwl_fr/raa [] fr | |||
vwl_fr/re [] fr | |||
vwl_fr/raa [L¸j] fr | |||
vwl_fr/re [L¸j] fr | |||
vwl_fr/r_e [r/] fr | |||
vwl_fr/re2 [] fr | |||
vwl_fr/ree [] fr | |||
vwl_fr/ri [] fr | |||
vwl_fr/re2 [L¸j] fr | |||
vwl_fr/ree [L¸j] fr | |||
vwl_fr/ri [L¸j] fr | |||
vwl_fr/r_i [r/] fr | |||
vwl_fr/rj [] fr | |||
vwl_fr/rj [L¸j] fr | |||
vwl_fr/r_n [r/] fr | |||
vwl_fr/ro [] fr | |||
vwl_fr/ro [L¸j] fr | |||
vwl_fr/r_o [r/] fr | |||
vwl_fr/roo [] fr | |||
vwl_fr/roo [L¸j] fr | |||
vwl_fr/rr [r/] fr | |||
vwl_fr/ru [] fr | |||
vwl_fr/ru [L¸j] fr | |||
vwl_fr/r_u [r/] fr | |||
vwl_fr/rw [] fr | |||
vwl_fr/ry [] fr | |||
vwl_fr/rw [L¸j] fr | |||
vwl_fr/ry [L¸j] fr | |||
vwl_fr/r_y [r/] fr | |||
vwl_fr/tr [r/2] fr | |||
vwl_fr/trr [r/] fr | |||
vwl_fr/u2r [] fr | |||
vwl_fr/u2r [L¸j] fr | |||
vwl_fr/wa [w] fr | |||
[w/] fr | |||
vwl_fr/y2r [] fr | |||
vwl_fr/y2r [L¸j] fr | |||
vwl_hi/l-voc [l-] base | |||
[l] lt | |||
[l-] sk |
@@ -8,7 +8,7 @@ phoneme 3 // Schwa, used for rhotic schwa in American | |||
vowel starttype #@ endtype #@ | |||
ipa ɚ | |||
unstressed | |||
length 210 | |||
length 200 | |||
IfNextVowelAppend(r-) | |||
FMT(vwl_en_us/3_us) | |||
endphoneme | |||
@@ -21,15 +21,12 @@ phoneme @ // Schwa | |||
IF nextPh(isRhotic) THEN | |||
ChangePhoneme(3) | |||
ENDIF | |||
IF thisPh(isWordEnd) THEN | |||
FMT(vowel/@_6) | |||
ENDIF | |||
FMT(vowel/@_4) | |||
endphoneme | |||
phoneme @/ // Schwa, end of word | |||
vowel starttype #@ endtype #@ | |||
unstressed | |||
length 130 | |||
FMT(vowel/@_low2) | |||
endphoneme | |||
phoneme @2 // Schwa, changes to I before a vowel | |||
vowel starttype #@ endtype #@ |
@@ -39,7 +39,11 @@ phoneme &~ | |||
vowel starttype #@ endtype #@ | |||
ipa ɐU+0303 | |||
length 180 | |||
FMT(vnasal/a#_n) | |||
IF thisPh(isStressed) THEN | |||
FMT(vnasal/W_n) | |||
ELSE | |||
FMT(vnasal/a#_n) | |||
ENDIF | |||
endphoneme | |||
phoneme &U~ | |||
@@ -224,10 +228,3 @@ phoneme * | |||
endphoneme | |||
// TESTING | |||
phoneme &2~ | |||
vowel starttype #@ endtype #@ | |||
ipa ɐU+0303 | |||
length 200 | |||
FMT(vnasal/W_n) | |||
endphoneme |
@@ -85,14 +85,18 @@ phoneme i | |||
IF prevPhW(w) THEN | |||
VowelStart(w/wi) | |||
ENDIF | |||
FMT(vowel/i_4) | |||
IF nextPh(n^) OR nextPh(c) THEN | |||
FMT(vnasal/ii_n) | |||
ELSE | |||
FMT(vowel/i_4) | |||
ENDIF | |||
endphoneme | |||
phoneme O | |||
vowel starttype #o endtype #o | |||
IF nextPh(kh) THEN | |||
length 95 | |||
IF nextPh(kh) OR nextPh(N) THEN | |||
length 110 | |||
ELSE | |||
length 200 | |||
ENDIF | |||
@@ -101,8 +105,8 @@ endphoneme | |||
phoneme o | |||
vowel starttype #o endtype #o | |||
IF nextPh(kh) THEN | |||
length 95 | |||
IF nextPh(kh) OR nextPh(N) THEN | |||
length 110 | |||
ELSE | |||
length 200 | |||
ENDIF | |||
@@ -286,7 +290,7 @@ endphoneme | |||
phoneme u@ | |||
vowel starttype #u endtype #@ | |||
length 200 | |||
length 150 //200 | |||
FMT(vdiph2/uu@) | |||
endphoneme | |||
@@ -317,6 +321,12 @@ phoneme o& | |||
FMT(vietnam/oe) | |||
endphoneme | |||
phoneme iE // iê : viết, giệc | |||
vowel starttype #i endtype #e | |||
length 190 | |||
FMT(vietnam/ie_2) | |||
endphoneme | |||
phoneme kh | |||
vls vel frc | |||
lengthmod 3 |
@@ -771,12 +771,12 @@ phoneme n. | |||
ENDIF | |||
NextVowelStarts | |||
VowelStart(n/n@) | |||
VowelStart(n/na) | |||
VowelStart(n/ne) | |||
VowelStart(n/ni) | |||
VowelStart(n/no) | |||
VowelStart(n/nu) | |||
VowelStart(n/nr@) | |||
VowelStart(n/nra) | |||
VowelStart(n/nre) | |||
VowelStart(n/nri) | |||
VowelStart(n/nro) | |||
VowelStart(n/nru) | |||
EndSwitch | |||
IF prevPh(isNotVowel) AND nextPhW(isLiquid) THEN | |||
@@ -1936,4 +1936,3 @@ include ph_korean | |||
phonemetable kl base | |||
include ph_greenlandic | |||
@@ -1,5 +1,5 @@ | |||
// 20.02.13 Add samplerate 4-bytes at start of phondata | |||
// 14.09.10 Recognize long and short frames in phondata | |||
// 02.09.10 Fix: Q sections were omitted from the converted phondata | |||
// 13.08.10 jonsd: Added Q lines. Use Address to set the displacement in phondata file. | |||
@@ -235,7 +235,9 @@ void swap_phondata (const char *infile, const char *outfile, | |||
exit (1); | |||
} | |||
xread = fread(buf_4, 4, 1, in); | |||
xread = fread(buf_4, 4, 1, in); // version number | |||
fwrite(buf_4, 4, 1, out); | |||
xread = fread(buf_4, 4, 1, in); // sample rate | |||
fwrite(buf_4, 4, 1, out); | |||
while (fgets (line, sizeof(line), mfest)) |
@@ -29,6 +29,7 @@ | |||
#define INCLUDE_KLATT | |||
#define INCLUDE_MBROLA | |||
#define INCLUDE_SONIC | |||
#define _ESPEAKEDIT | |||
#include <windows.h> | |||
#define PLATFORM_WINDOWS |
@@ -29,6 +29,7 @@ | |||
#define INCLUDE_KLATT | |||
#define INCLUDE_MBROLA | |||
#define INCLUDE_SONIC | |||
#define _ESPEAKEDIT | |||
#include <windows.h> | |||
#define PLATFORM_WINDOWS |
@@ -27,6 +27,7 @@ | |||
#include "wx/wfstream.h" | |||
#include "wx/dir.h" | |||
#include "wx/filename.h" | |||
#include <wx/numdlg.h> | |||
#include "speak_lib.h" | |||
#include "main.h" | |||
@@ -45,6 +46,7 @@ extern void FindPhonemesUsed(void); | |||
extern void DisplayErrorFile(const char *fname); | |||
extern int utf8_out(unsigned int c, char *buf); | |||
extern void DrawEnvelopes(); | |||
extern void ReadPhondataManifest(); | |||
char path_source[sizeof(path_home)+20]; | |||
@@ -465,7 +467,7 @@ return; | |||
instn_category = (instn >> 12) & 0xf; | |||
data1 = instn & 0xff; | |||
type2 = (instn >> 8) & 0xf; | |||
fprintf(f_out, " %.3x: %.4x %s",pc-prog_buf,instn,instn_category_string[instn_category]); | |||
fprintf(f_out, " %.3x: %.4x %s",(unsigned int)(pc-prog_buf),instn,instn_category_string[instn_category]); | |||
switch(instn_category) | |||
{ | |||
@@ -644,6 +646,7 @@ static int duplicate_references = 0; | |||
static int count_frames = 0; | |||
static int error_count = 0; | |||
static int resample_count = 0; | |||
static int resample_fails = 0; | |||
static int then_count = 0; | |||
static int after_if = 0; | |||
@@ -738,7 +741,6 @@ static void CompileReport(void) | |||
const char *data_path; | |||
int prev_table; | |||
int prev_mnemonic; | |||
char fname[sizeof(path_source)+20]; | |||
if(f_report == NULL) | |||
return; | |||
@@ -1791,8 +1793,12 @@ static int LoadWavefile(FILE *f, const char *fname) | |||
int max = 0; | |||
int length; | |||
int sr1, sr2; | |||
int failed; | |||
int len; | |||
int resample_wav = 0; | |||
const char *fname2; | |||
char fname_temp[100]; | |||
char msg[120]; | |||
int scale_factor=0; | |||
fseek(f,24,SEEK_SET); | |||
@@ -1802,53 +1808,67 @@ static int LoadWavefile(FILE *f, const char *fname) | |||
if((sr1 != samplerate_native) || (sr2 != sr1*2)) | |||
{ | |||
#ifdef PLATFORM_WINDOWS | |||
if(sr1 != samplerate_native) | |||
{ | |||
fprintf(f_errors,"Wrong samplerate %d, wants %d\n",sr1,samplerate_native); | |||
error("Wrong samplerate: %s",fname); | |||
} | |||
if(sr2 != sr1*2) | |||
int fd_temp; | |||
char command[sizeof(path_source)+200]; | |||
failed = 0; | |||
#ifdef PLATFORM_POSIX | |||
strcpy(fname_temp,"/tmp/espeakXXXXXX"); | |||
if((fd_temp = mkstemp(fname_temp)) >= 0) | |||
{ | |||
error("Not mono: %s",fname); | |||
close(fd_temp); | |||
} | |||
#else | |||
{ | |||
int fd_temp; | |||
char command[sizeof(path_source)+200]; | |||
strcpy(fname_temp,"/tmp/espeakXXXXXX"); | |||
if((fd_temp = mkstemp(fname_temp)) >= 0) | |||
{ | |||
close(fd_temp); | |||
sprintf(command,"sox \"%s%s.wav\" -c1 -t wav %s rate -h %d\n",path_source,fname,fname_temp,samplerate_native); | |||
if(system(command) < 0) | |||
{ | |||
error("Failed to resample: %s",command); | |||
remove(fname_temp); | |||
return(0); | |||
} | |||
} | |||
strcpy(fname_temp,tmpnam(NULL)); | |||
#endif | |||
if(GetFileLength(fname_temp) <= 0) | |||
fname2 = fname; | |||
len = strlen(fname); | |||
if(strcmp(&fname[len-4], ".wav") == 0) | |||
{ | |||
strcpy(msg, fname); | |||
msg[len-4] = 0; | |||
fname2 = msg; | |||
} | |||
sprintf(command,"sox \"%s%s.wav\" -r %d -c1 -t wav %s\n",path_source,fname2,samplerate_native, fname_temp); | |||
if(system(command) < 0) | |||
{ | |||
failed = 1; | |||
} | |||
if(failed || (GetFileLength(fname_temp) <= 0)) | |||
{ | |||
if(resample_fails < 2) | |||
error("Resample command failed: %s", command); | |||
resample_fails++; | |||
if(sr1 != samplerate_native) | |||
{ | |||
error("Failed to resample: %s",command); | |||
remove(fname_temp); | |||
return(0); | |||
sprintf(msg, "Can't resample (%d to %d): %s", sr1, samplerate_native, fname); | |||
error("%s", msg); | |||
} | |||
f = fopen(fname_temp,"rb"); | |||
if(f == NULL) | |||
{ | |||
error("Can't read temp file: %s",fname_temp); | |||
return(0); | |||
} | |||
if(f_report != NULL) | |||
fprintf(f_report, "resampled %s\n", fname); | |||
resample_count++; | |||
resample_wav = 1; | |||
fseek(f,40,SEEK_SET); // skip past the WAV header, up to before "data length" | |||
} | |||
#endif | |||
else | |||
{ | |||
error("WAV file is not mono: %s", fname); | |||
} | |||
remove(fname_temp); | |||
return(0); | |||
} | |||
f = fopen(fname_temp,"rb"); | |||
if(f == NULL) | |||
{ | |||
error("Can't read temp file: %s",fname_temp); | |||
return(0); | |||
} | |||
if(f_report != NULL) | |||
fprintf(f_report, "resampled %s\n", fname); | |||
resample_count++; | |||
resample_wav = 1; | |||
fseek(f,40,SEEK_SET); // skip past the WAV header, up to before "data length" | |||
} | |||
displ = ftell(f_phdata); | |||
@@ -3321,8 +3341,11 @@ static void CompileEquivalents() | |||
p_start[2] = n_bytes >> 8; // index of next table | |||
p_start[3] = n_bytes; | |||
LoadVoice(voice_name2,0); // reset the original phoneme table | |||
LoadVoiceVariant(save_voice_name,0); | |||
if(gui_flag != 0) | |||
{ | |||
LoadVoice(voice_name2,0); // reset the original phoneme table | |||
LoadVoiceVariant(save_voice_name,0); | |||
} | |||
} // end of CompileEquivalents | |||
@@ -3362,6 +3385,7 @@ static void CompilePhonemeFiles() | |||
case kINCLUDE: | |||
NextItem(tSTRING); | |||
sprintf(buf,"%s%s",path_source,item_string); | |||
if((stack_ix < N_STACK) && (f = fopen_log(f_errors,buf,"rb")) != NULL) | |||
{ | |||
fprintf(f_errors,"include %s\n",item_string); | |||
@@ -3421,6 +3445,7 @@ make_envs(); | |||
n_envelopes = 0; | |||
error_count = 0; | |||
resample_count = 0; | |||
memset(markers_used,0,sizeof(markers_used)); | |||
f_errors = stderr; | |||
@@ -3534,6 +3559,7 @@ memset(markers_used,0,sizeof(markers_used)); | |||
// write a word so that further data doesn't start at displ=0 | |||
Write4Bytes(f_phdata,version_phdata); | |||
Write4Bytes(f_phdata,samplerate_native); | |||
Write4Bytes(f_phindex,version_phdata); | |||
memset(ref_hash_tab,0,sizeof(ref_hash_tab)); | |||
@@ -3555,9 +3581,10 @@ fprintf(f_errors,"\nRefs %d, Reused %d\n",count_references,duplicate_references | |||
fclose(f_phtab); | |||
fclose(f_phcontents); | |||
LoadPhData(); | |||
LoadVoice(voice_name2,0); | |||
LoadPhData(NULL); | |||
if(gui_flag != 0) | |||
LoadVoice(voice_name2,0); | |||
CompileReport(); | |||
report_dict = CompileAllDictionaries(); | |||
@@ -3595,6 +3622,8 @@ fprintf(f_errors,"\nRefs %d, Reused %d\n",count_references,duplicate_references | |||
fprintf(stderr,"%s\n",fname); | |||
} | |||
ReadPhondataManifest(); | |||
} // end of CompilePhonemeData | |||
@@ -3759,7 +3788,6 @@ void CompileIntonation() | |||
char buf[sizeof(path_source)+120]; | |||
error_count = 0; | |||
resample_count = 0; | |||
sprintf(fname_errors,"%s%s",path_source,"error_intonation"); | |||
if((f_errors = fopen(fname_errors,"w")) == NULL) | |||
@@ -4036,7 +4064,7 @@ void CompileIntonation() | |||
{ | |||
DisplayErrorFile(fname_errors); | |||
} | |||
LoadPhData(); | |||
LoadPhData(NULL); | |||
} // end of CompileIntonation | |||
@@ -4044,7 +4072,22 @@ void CompileIntonation() | |||
void CompilePhonemeData() | |||
{ | |||
WavegenInit(22050, 0); | |||
WavegenSetVoice(voice); | |||
CompilePhonemeData2("phonemes"); | |||
return; | |||
} | |||
void CompileSampleRate() | |||
{ | |||
long value; | |||
value = wxGetNumberFromUser(_T("Compile phoneme data with a specified sample rate"), _T("Sample rate"), _T("Resample (needs sox)"), 22050, 5000, 48000); | |||
if(value > 1000) | |||
{ | |||
WavegenInit(value, 0); | |||
WavegenSetVoice(voice); | |||
CompilePhonemeData2("phonemes"); | |||
} | |||
} | |||
@@ -296,10 +296,6 @@ int LoadDictionary(Translator *tr, const char *name, int no_error) | |||
// set up indices into data_dictrules | |||
InitGroups(tr); | |||
if(tr->groups1[0] == NULL) | |||
{ | |||
fprintf(stderr,"Error in %s_rules, no default rule group\n",name); | |||
} | |||
// set up hash table for data_dictlist | |||
p = &(tr->data_dictlist[8]); |
@@ -43,11 +43,11 @@ | |||
#include "prosodydisplay.h" | |||
#ifdef deleted | |||
static const char *about_string = "espeakedit: %s\nAuthor: Jonathan Duddington (c) 2009\n\n" | |||
static const char *about_string2 = "espeakedit: %s\nAuthor: Jonathan Duddington (c) 2009\n\n" | |||
"Licensed under GNU General Public License version 3\n" | |||
"http://espeak.sourceforge.net/"; | |||
#endif | |||
static const char *about_string = "<font size=0><b>espeakedit </b> %s<br>Author: Jonathan Duddington (c) 2009<br>" | |||
"<a href=\"http://espeak.sourceforge.net/\">http://espeak.sourceforge.net</a><br>" | |||
@@ -63,6 +63,7 @@ extern void DictionarySort(const char *dictname); | |||
extern void init_z(); | |||
extern void CompilePhonemeData(void); | |||
extern void CompileSampleRate(void); | |||
extern void CompileMbrola(); | |||
extern void CompileIntonation(); | |||
extern void InitSpectrumDisplay(); | |||
@@ -133,22 +134,21 @@ if(argc > 1) | |||
if((strcmp(param,"--help")==0) || (strcmp(param,"-h")==0)) | |||
{ | |||
printf(about_string,espeak_Info(NULL)); | |||
printf(help_text); | |||
printf(about_string2,espeak_Info(NULL)); | |||
printf("%s", help_text); | |||
exit(0); | |||
} | |||
ConfigInit(); | |||
VoiceReset(0); | |||
WavegenSetVoice(voice); | |||
WavegenInitSound(); | |||
if(strcmp(param,"--compile")==0) | |||
{ | |||
LoadPhData(NULL); | |||
samplerate_native = samplerate = 22050; | |||
CompilePhonemeData(); | |||
CompileIntonation(); | |||
exit(0); | |||
} | |||
exit(0); | |||
} | |||
ConfigInit(); | |||
@@ -205,6 +205,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) | |||
EVT_MENU(MENU_PATH3, MyFrame::OnOptions) | |||
EVT_MENU(MENU_PATH4, MyFrame::OnOptions) | |||
EVT_MENU(MENU_COMPILE_PH, MyFrame::OnTools) | |||
EVT_MENU(MENU_COMPILE_PH2, MyFrame::OnTools) | |||
EVT_MENU(MENU_COMPILE_DICT, MyFrame::OnTools) | |||
EVT_MENU(MENU_COMPILE_DICT_DEBUG, MyFrame::OnTools) | |||
EVT_MENU(MENU_FORMAT_DICTIONARY, MyFrame::OnTools) | |||
@@ -266,6 +267,7 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c | |||
int error_flag = 0; | |||
int result; | |||
int param; | |||
int srate; | |||
notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxSize(312,760)); | |||
// notebook->AddPage(voicedlg,_T("Voice"),FALSE); | |||
@@ -301,9 +303,8 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c | |||
SetSize(pos.x, pos.y, size.GetWidth(), size.GetHeight()); | |||
LoadConfig(); | |||
WavegenInitSound(); | |||
if((result = LoadPhData()) != 1) | |||
if((result = LoadPhData(&srate)) != 1) | |||
{ | |||
if(result == -1) | |||
wxLogError(_T("Failed to read espeak-data/phontab,phondata,phonindex\nPath = ")+wxString(path_home,wxConvLocal)+_T("\n\nThe 'eSpeak' package needs to be installed")); | |||
@@ -311,7 +312,10 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c | |||
wxLogError(_T("Wrong version of espeak-data at:\n")+ wxString(path_home,wxConvLocal)+_T("\nVersion 0x%x (expects 0x%x)"),result,version_phdata); | |||
error_flag = 1; | |||
srate = 22050; | |||
} | |||
WavegenInit(srate,0); | |||
WavegenInitSound(); | |||
f_trans = stdout; | |||
option_ssml = 1; | |||
@@ -350,7 +354,13 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c | |||
void MyFrame::SetVoiceTitle(char *voice_name) | |||
{//========================================== | |||
char buf[100]; | |||
SetTitle(AppName + _T(" - ") + wxString(voice_name,wxConvLocal) + _T(" voice")); | |||
if(samplerate_native == 22050) | |||
sprintf(buf, " - %s voice", voice_name); | |||
else | |||
sprintf(buf, " - %s voice %dHz", voice_name, samplerate_native); | |||
SetTitle(AppName + wxString(buf,wxConvLocal)); | |||
if((data_menu != NULL) && (translator != NULL)) | |||
{ | |||
sprintf(buf,"Compile &dictionary '%s'",translator->dictionary_name); | |||
@@ -738,6 +748,12 @@ void MyFrame::OnTools(wxCommandEvent& event) | |||
case MENU_COMPILE_PH: | |||
CompilePhonemeData(); | |||
SetVoiceTitle(voice_name2); | |||
break; | |||
case MENU_COMPILE_PH2: | |||
CompileSampleRate(); | |||
SetVoiceTitle(voice_name2); | |||
break; | |||
case MENU_COMPILE_MBROLA: |
@@ -135,7 +135,7 @@ int TestSynthCallback(short *wav, int numsamples, espeak_EVENT *events) | |||
else | |||
if(type==espeakEVENT_PHONEME) | |||
{ | |||
char buf[10]; | |||
// char buf[10]; | |||
fprintf(f_events,"[%s]\n",WordToString(events->id.number)); //old version, only 4 characters bytes | |||
// memcpy(buf, events->id.string, 8); | |||
// buf[8] = 0; | |||
@@ -206,7 +206,7 @@ static const unsigned short KOI8_R[0x60] = { | |||
#define N_CHARS 34 | |||
#define PH(c1,c2) (c2<<8)+c1 // combine two characters into an integer for phoneme name | |||
#define PH(c1,c2) (c2<<8)+c1 // combine two characters into an integer for phoneme name | |||
@@ -236,7 +236,7 @@ static void DecodePhonemes2(const char *inptr, char *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 > 2) | |||
@@ -281,7 +281,7 @@ static void DecodePhonemes2(const char *inptr, char *outptr) | |||
else | |||
if(mnem != 0) | |||
{ | |||
while((c = (mnem & 0xff)) != 0) | |||
while((c = (mnem & 0xff)) != 0) | |||
{ | |||
*outptr++ = c; | |||
mnem = mnem >> 8; | |||
@@ -363,7 +363,7 @@ void Lexicon_It(int pass) | |||
path_dir1 = wxFileName(fname_lex).GetPath(); | |||
strcpy(buf_out, path_dir1.mb_str(wxConvLocal)); | |||
sprintf(buf, "%s/IT_errors", buf_out); | |||
if((f_out = fopen(buf,"w")) == NULL) | |||
{ | |||
str = wxString(buf, wxConvLocal); | |||
@@ -412,7 +412,7 @@ void Lexicon_It(int pass) | |||
if((p = strstr(buf,"//")) != NULL) | |||
*p = 0; | |||
if((sscanf(buf,"%s %s",word,temp)) < 2) | |||
continue; | |||
@@ -522,7 +522,7 @@ void Lexicon_It(int pass) | |||
fputc(*p, f_listx); // omit secondary stress marks | |||
} | |||
fputc('\n',f_listx); | |||
} | |||
else | |||
if((stress_posn1 != stress_posn2) && (stress_posn1 > 0) && (stress_posn2 > 0)) | |||
@@ -706,7 +706,7 @@ void Lexicon_De() | |||
return; | |||
} | |||
path_dir1 = wxFileName(fname).GetPath(); | |||
if((f_out = fopen("compare_de","w")) == NULL) | |||
{ | |||
wxLogError(_T("Can't write file ")); | |||
@@ -934,7 +934,7 @@ void Lexicon_Bg() | |||
FILE *f_in; | |||
FILE *f_out; | |||
char word[80]; | |||
char word_in[80]; | |||
char phonemes[N_WORD_PHONEMES]; | |||
@@ -1101,7 +1101,7 @@ if(n_stress > 1) n_stress = 1; | |||
if(done) | |||
n_out++; | |||
} | |||
} | |||
n_words++; | |||
} | |||
@@ -1383,10 +1383,10 @@ void Lexicon_Ru() | |||
len = strlen(suffix); | |||
if(len >= (wlen-2)) | |||
continue; | |||
if(ru_stress > (vcount - suffixes[sfx].syllables)) | |||
continue; | |||
if(strcmp(suffix,&word[wlen-len])==0) | |||
{ | |||
strcpy(word2,word); | |||
@@ -1547,7 +1547,7 @@ void CountWordFreq(wxString path, wcount **hashtab) | |||
// skip leading spaces, numbers, etc | |||
if(feof(f_in)) break; | |||
} | |||
// read utf8 bytes until a space, number or punctuation | |||
ix = 0; | |||
while(!feof(f_in) && (c >= 'A') && (ix < sizeof(buf)-1)) | |||
@@ -1557,7 +1557,7 @@ void CountWordFreq(wxString path, wcount **hashtab) | |||
} | |||
buf[ix++] = 0; | |||
buf[ix] = 0; | |||
// the buf may contain non-alphabetic characters | |||
j = 0; | |||
n_chars = 0; | |||
@@ -1583,7 +1583,7 @@ void CountWordFreq(wxString path, wcount **hashtab) | |||
} | |||
} | |||
fclose(f_in); | |||
} // end of CountWordFreq | |||
@@ -1645,7 +1645,7 @@ void MakeWordFreqList() | |||
free(p); | |||
} | |||
fclose(f_out); | |||
} // end of Make WorkFreqList | |||
@@ -2129,9 +2129,9 @@ void SetSpeedTab(void) | |||
// Interpolation table to translate from words-per-minute to internal speed | |||
// words-per-minute values (measured) | |||
static float wpm1[N_WPM] = | |||
{0, 82, 96, 108, 124, 134, 147, 162, 174, 189, 224, 259, 273, 289, 307, 326, 346, 361, 370 }; | |||
{0, 82, 96, 108, 124, 134, 147, 162, 174, 189, 224, 259, 273, 289, 307, 326, 346, 361, 370 }; | |||
// corresponding internal speed values | |||
static float wpm2[N_WPM] = | |||
static float wpm2[N_WPM] = | |||
{0,253,200, 170, 140, 125, 110, 95, 85, 75, 55, 40, 35, 30, 25, 20, 15, 10, 5 }; | |||
unsigned char speed_lookup[290]; | |||
@@ -2245,7 +2245,7 @@ void CharsetToUnicode(const char *charset) | |||
#ifdef deleted | |||
void Test2() | |||
{ | |||
// | |||
// | |||
char buf[120]; | |||
FILE *f; | |||
FILE *f_out; | |||
@@ -2299,7 +2299,7 @@ if(control==2) | |||
f = fopen("/home/jsd1/speechdata/text/test.txt","r"); | |||
if(f==NULL) | |||
return; | |||
while(!feof(f) && (ix < sizeof(textbuf)-2)) | |||
{ |
@@ -136,6 +136,7 @@ enum { | |||
MENU_PROSODY, | |||
MENU_COMPILE_PH, | |||
MENU_COMPILE_PH2, | |||
MENU_COMPILE_DICT, | |||
MENU_COMPILE_DICT_DEBUG, | |||
MENU_FORMAT_DICTIONARY, |
@@ -1,5 +1,5 @@ | |||
/*************************************************************************** | |||
* Copyright (C) 2005 to 2010 by Jonathan Duddington * | |||
* Copyright (C) 2005 to 2013 by Jonathan Duddington * | |||
* email: [email protected] * | |||
* * | |||
* This program is free software; you can redistribute it and/or modify * | |||
@@ -90,6 +90,7 @@ wxMenuBar *MakeMenu(int type, const char *dict_name) | |||
// DATA MENU | |||
data_menu = new wxMenu; | |||
data_menu->Append(MENU_COMPILE_PH, _("Compile &phoneme data")); | |||
data_menu->Append(MENU_COMPILE_PH2, _("Change sample &rate")); | |||
data_menu->Append(MENU_COMPILE_DICT, _("Compile &dictionary")); | |||
data_menu->Append(MENU_COMPILE_DICT_DEBUG, _("Compile dictionary (debu&g)")); | |||
data_menu->AppendSeparator(); |
@@ -1,5 +1,5 @@ | |||
/*************************************************************************** | |||
* Copyright (C) 2005 to 2011 by Jonathan Duddington * | |||
* Copyright (C) 2005 to 2013 by Jonathan Duddington * | |||
* email: [email protected] * | |||
* * | |||
* This program is free software; you can redistribute it and/or modify * | |||
@@ -435,7 +435,7 @@ void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf) | |||
if((letter >= 0x250) && (letter <= 0x2a8)) | |||
{ | |||
accent_data = letter_accents_250[letter - 0x250]; | |||
} | |||
} | |||
if(accent_data != 0) | |||
{ | |||
@@ -551,7 +551,7 @@ void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_b | |||
// if the $accent flag is set for this letter, use the accents table (below) | |||
dict_flags[1] = 0; | |||
if(Lookup(tr, &single_letter[1], ph_buf3) == 0) | |||
{ | |||
single_letter[1] = ' '; | |||
@@ -678,7 +678,7 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control) | |||
if((ph_buf[0]==0) && !iswspace(letter)) | |||
Lookup(tr, "_??", ph_buf); | |||
if(ph_buf[0] != 0) | |||
{ | |||
// speak the hexadecimal number of the character code | |||
@@ -872,7 +872,7 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab) | |||
static const char *roman_numbers = "ixcmvld"; | |||
static int roman_values[] = {1,10,100,1000,5,50,500}; | |||
acc = 0; | |||
prev = 0; | |||
subtract = 0x7fff; | |||
@@ -922,7 +922,7 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab) | |||
if(isdigit(word[0])) | |||
return(0); // eg. 'xx2' | |||
acc += prev; | |||
if(acc < tr->langopts.min_roman) | |||
return(0); | |||
@@ -985,7 +985,7 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab) | |||
static const char *M_Variant(int value) | |||
{//==================================== | |||
// returns M, or perhaps MA or MB for some cases | |||
int teens = 0; | |||
if(((value % 100) > 10) && ((value % 100) < 20)) | |||
@@ -1074,7 +1074,7 @@ static int LookupThousands(Translator *tr, int value, int thousandplex, int thou | |||
if(found_value == 0) | |||
{ | |||
if((value % 100) >= 20) | |||
if((value % 100) >= 20) | |||
{ | |||
Lookup(tr, "_0of", ph_of); | |||
} | |||
@@ -1199,7 +1199,7 @@ static int LookupNum2(Translator *tr, int value, const int control, char *ph_out | |||
if(is_ordinal) | |||
{ | |||
strcpy(ph_ordinal, ph_ordinal2); | |||
if(control & 4) | |||
{ | |||
sprintf(string,"_%d%cx",value,ord_type); // LANG=hu, special word for 1. 2. when there are no higher digits | |||
@@ -1212,7 +1212,7 @@ static int LookupNum2(Translator *tr, int value, const int control, char *ph_out | |||
} | |||
found_ordinal = found; | |||
} | |||
if(found == 0) | |||
{ | |||
if(control & 2) | |||
@@ -1246,9 +1246,9 @@ static int LookupNum2(Translator *tr, int value, const int control, char *ph_out | |||
} | |||
} | |||
} | |||
// no, speak as tens+units | |||
if((control & 0x10) && (value < 10)) | |||
{ | |||
// speak leading zero | |||
@@ -1262,8 +1262,8 @@ static int LookupNum2(Translator *tr, int value, const int control, char *ph_out | |||
} | |||
else | |||
{ | |||
if((is_ordinal) && | |||
if((is_ordinal) && | |||
((units == 0) || (tr->langopts.numbers & NUM_SWAP_TENS) || (tr->langopts.numbers2 & NUM2_MULTIPLE_ORDINAL))) | |||
{ | |||
sprintf(string,"_%dX%c", tens, ord_type); | |||
@@ -1283,7 +1283,7 @@ static int LookupNum2(Translator *tr, int value, const int control, char *ph_out | |||
sprintf(string,"_%dX", tens); | |||
Lookup(tr, string, ph_tens); | |||
} | |||
if((ph_tens[0] == 0) && (tr->langopts.numbers & NUM_VIGESIMAL)) | |||
{ | |||
// tens not found, (for example) 73 is 60+13 | |||
@@ -1291,12 +1291,12 @@ static int LookupNum2(Translator *tr, int value, const int control, char *ph_out | |||
sprintf(string,"_%dX", tens & 0xfe); | |||
Lookup(tr, string, ph_tens); | |||
} | |||
ph_digits[0] = 0; | |||
if(units > 0) | |||
{ | |||
{ | |||
found = 0; | |||
if((control & 2) && (digit_lookup[0] != 0)) | |||
{ | |||
// we have an entry for this digit (possibly together with the next word) | |||
@@ -1346,7 +1346,7 @@ static int LookupNum2(Translator *tr, int value, const int control, char *ph_out | |||
} | |||
} | |||
} | |||
if((is_ordinal) && (found_ordinal == 0) && (ph_ordinal[0] == 0)) | |||
{ | |||
if((value >= 20) && (((value % 10) == 0) || (tr->langopts.numbers & NUM_SWAP_TENS))) | |||
@@ -1354,7 +1354,7 @@ static int LookupNum2(Translator *tr, int value, const int control, char *ph_out | |||
if(ph_ordinal[0] == 0) | |||
Lookup(tr, "_ord", ph_ordinal); | |||
} | |||
if((tr->langopts.numbers & (NUM_SWAP_TENS | NUM_AND_UNITS)) && (ph_tens[0] != 0) && (ph_digits[0] != 0)) | |||
{ | |||
Lookup(tr, "_0and", ph_and); | |||
@@ -1377,7 +1377,7 @@ static int LookupNum2(Translator *tr, int value, const int control, char *ph_out | |||
{ | |||
if((next_phtype = phoneme_tab[(unsigned int)(ph_digits[0])]->type) == phSTRESS) | |||
next_phtype = phoneme_tab[(unsigned int)(ph_digits[1])]->type; | |||
if((phoneme_tab[(unsigned int)(ph_tens[ix])]->type == phVOWEL) && (next_phtype == phVOWEL)) | |||
ph_tens[ix] = 0; | |||
} | |||
@@ -1559,13 +1559,13 @@ static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null | |||
sprintf(string,"_%dC0",hundreds); | |||
found = Lookup(tr, string, ph_digits); | |||
} | |||
if(!found) | |||
{ | |||
sprintf(string,"_%dC",hundreds); | |||
found = Lookup(tr, string, ph_digits); // is there a specific pronunciation for n-hundred ? | |||
} | |||
if(found) | |||
{ | |||
ph_100[0] = 0; | |||
@@ -1628,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 | control & 0x100, 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 | |||
@@ -1787,7 +1787,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned | |||
// this is an ordinal suffix | |||
ordinal = 2; | |||
flags[0] |= FLAG_SKIPWORDS; | |||
skipwords = 1; | |||
skipwords = 1; | |||
} | |||
} | |||
} | |||
@@ -2048,7 +2048,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned | |||
break; | |||
n_digits++; | |||
strcat(ph_out, buf1); | |||
} | |||
} | |||
} | |||
} | |||
@@ -1,5 +1,5 @@ | |||
/*************************************************************************** | |||
* Copyright (C) 2005 to 2007 by Jonathan Duddington * | |||
* Copyright (C) 2005 to 2013 by Jonathan Duddington * | |||
* email: [email protected] * | |||
* * | |||
* This program is free software; you can redistribute it and/or modify * | |||
@@ -79,7 +79,7 @@ Options::~Options() | |||
for(ix=0; ix < 1; ix++) | |||
delete m_lab[ix]; | |||
delete m_samplerate; | |||
delete m_save; | |||
delete m_close; | |||
@@ -89,13 +89,13 @@ void Options::OnCommand(wxCommandEvent& event) | |||
{//=========================================== | |||
int id; | |||
int value; | |||
switch(id = event.GetId()) | |||
{ | |||
case wxID_SAVE: | |||
value = GetNumeric(m_samplerate); | |||
if(value > 0) WavegenInit(value,0); | |||
Destroy(); | |||
break; | |||
@@ -120,11 +120,10 @@ void ConfigSetPaths() | |||
void ConfigInit() | |||
{//============== | |||
long value; | |||
wxString string; | |||
wxString basedir; | |||
const char *path_base; | |||
#ifdef PLATFORM_WINDOWS | |||
int found = 0; | |||
char buf[200]; | |||
@@ -134,7 +133,7 @@ void ConfigInit() | |||
{ | |||
sprintf(path_home,"%s\\espeak-data",path_base); | |||
if(GetFileLength(path_home) == -2) | |||
found = 1; // an espeak-data directory exists | |||
found = 1; // an espeak-data directory exists | |||
} | |||
if(found == 0) | |||
@@ -142,7 +141,7 @@ void ConfigInit() | |||
if(pRegKey->Exists() ) | |||
{ | |||
wxString RegVal; | |||
pRegKey->QueryValue(_T("Path"),RegVal); | |||
pRegKey->QueryValue(_T("Path"),RegVal); | |||
strncpy0(buf,RegVal.mb_str(wxConvLocal),sizeof(buf)); | |||
path_base = buf; | |||
} | |||
@@ -161,12 +160,6 @@ void ConfigInit() | |||
wxFileConfig *pConfig = new wxFileConfig(_T("espeakedit")); | |||
wxFileConfig::Set(pConfig); | |||
pConfig->Read(_T("/samplerate"),&value,22050); | |||
#ifdef PLATFORM_WINDOWS | |||
value = 22050; | |||
#endif | |||
WavegenInit(value,0); | |||
basedir = wxString(path_base,wxConvLocal); // this is only used to set defaults for other paths if they are not in the config file | |||
pConfig->Read(_T("/spectload"),&path_spectload,basedir+_T("/phsource")); | |||
pConfig->Read(_T("/spectload2"),&path_spectload2,basedir+_T("/phsource")); |
@@ -50,6 +50,86 @@ static wxPen PEN_PHSELECTED(wxColour(255,0,0),2,wxSOLID); | |||
static wxPen PEN_PHSTRESSED(wxColour(80,80,196),3,wxSOLID); | |||
static wxPen PEN_PHSTRESSED2(wxColour(160,160,255),2,wxSOLID); | |||
typedef struct { | |||
unsigned int value; | |||
char *name; | |||
} NAMETAB; | |||
NAMETAB *manifest = NULL; | |||
int n_manifest; | |||
const char *LookupManifest(unsigned int addr) | |||
{//============================================= | |||
int ix; | |||
if(manifest != NULL) | |||
{ | |||
for(ix=0; ix < n_manifest; ix++) | |||
{ | |||
if(manifest[ix].value == addr) | |||
return(manifest[ix].name); | |||
if(manifest[ix].value > addr) | |||
break; | |||
} | |||
} | |||
return(""); | |||
} | |||
void ReadPhondataManifest() | |||
{//========================= | |||
// Read the phondata-manifest file | |||
FILE *f; | |||
int n_lines=0; | |||
int ix; | |||
char *p; | |||
unsigned int value; | |||
char buf[sizeof(path_home)+40]; | |||
char name[120]; | |||
sprintf(buf,"%s%c%s",path_home,PATHSEP,"phondata-manifest"); | |||
if((f = fopen(buf, "r")) == NULL) | |||
return; | |||
while(fgets(buf, sizeof(buf), f) != NULL) | |||
n_lines++; | |||
rewind(f); | |||
if(manifest != NULL) | |||
{ | |||
for(ix=0; ix < n_manifest; ix++) | |||
free(manifest[ix].name); | |||
} | |||
if((manifest = (NAMETAB *)realloc(manifest, n_lines * sizeof(NAMETAB))) == NULL) | |||
return; | |||
n_manifest = 0; | |||
while(fgets(buf, sizeof(buf), f) != NULL) | |||
{ | |||
if(!isalpha(buf[0])) | |||
continue; | |||
if(sscanf(&buf[2], "%x %s", &value, name) == 2) | |||
{ | |||
if((p = (char *)malloc(strlen(name)+1)) != NULL) | |||
{ | |||
strcpy(p, name); | |||
manifest[n_manifest].value = value; | |||
manifest[n_manifest].name = p; | |||
n_manifest++; | |||
} | |||
} | |||
} | |||
fclose(f); | |||
} | |||
ProsodyDisplay::ProsodyDisplay(wxWindow *parent, const wxPoint& pos, const wxSize& size) | |||
: wxScrolledWindow(parent, -1, pos, size, | |||
wxSUNKEN_BORDER | wxNO_FULL_REPAINT_ON_RESIZE) | |||
@@ -76,6 +156,7 @@ void InitProsodyDisplay() | |||
int ix; | |||
wxString string; | |||
ReadPhondataManifest(); | |||
menu_envelopes = new wxMenu; | |||
// entries match those in envelope_data[] in intonation.cpp | |||
@@ -142,6 +223,7 @@ void ProsodyDisplay::SelectPh(int index) | |||
int ix; | |||
const char *name = "?"; | |||
char buf[120]; | |||
char len_string[20]; | |||
if(index < 0) return; | |||
@@ -162,8 +244,12 @@ void ProsodyDisplay::SelectPh(int index) | |||
} | |||
y1 = p->pitch1; | |||
y2 = p->pitch2; | |||
sprintf(buf,"Stress %s%d Amp %2d StdLength %2d LengthMod %2d Pitch %3d %3d %s PhFlags %.2x ", | |||
emphasized,p->stresslevel&0x7,p->amp,p->std_length*2, p->length,y1,y2,name,p->ph->phflags); | |||
len_string[0] = 0; | |||
if(p->std_length > 0) | |||
sprintf(len_string," Length %d", p->std_length*2); | |||
sprintf(buf,"Stress %s%d Amp %2d LengthMod %2d Pitch %3d %3d %s PhFlags %.2x [%s%s]", | |||
emphasized,p->stresslevel&0x7,p->amp, p->length,y1,y2,name,p->ph->phflags, LookupManifest(p->phontab_addr), len_string); | |||
wxLogStatus(wxString(buf,wxConvLocal)); | |||
} | |||
@@ -625,4 +711,3 @@ void MyFrame::OnProsody(wxCommandEvent& WXUNUSED(event)) | |||
adding_page = 2; // work around for wxNotebook bug (version 2.8.7) | |||
screenpages->AddPage(prosodycanvas, _T("Prosody"), true); | |||
} | |||
@@ -736,7 +736,6 @@ static int LoadSoundFile(const char *fname, int index) | |||
{ | |||
int ix; | |||
int fd_temp; | |||
const char *resample; | |||
int header[3]; | |||
char command[sizeof(fname2)+sizeof(fname2)+40]; | |||
@@ -750,17 +749,11 @@ static int LoadSoundFile(const char *fname, int index) | |||
fclose(f); | |||
f = NULL; | |||
if(header[2] == samplerate) | |||
resample = ""; | |||
else | |||
resample = "polyphase"; | |||
strcpy(fname_temp,"/tmp/espeakXXXXXX"); | |||
if((fd_temp = mkstemp(fname_temp)) >= 0) | |||
{ | |||
close(fd_temp); | |||
// sprintf(fname_temp,"%s.wav",tmpnam(NULL)); | |||
sprintf(command,"sox \"%s\" -r %d -w -s -c1 %s %s\n", fname, samplerate, fname_temp, resample); | |||
sprintf(command,"sox \"%s\" -r %d -c1 -t wav %s\n", fname, samplerate, fname_temp); | |||
if(system(command) == 0) | |||
{ | |||
fname = fname_temp; |
@@ -1,5 +1,5 @@ | |||
/*************************************************************************** | |||
* Copyright (C) 2005 to 2007 by Jonathan Duddington * | |||
* Copyright (C) 2005 to 2013 by Jonathan Duddington * | |||
* email: [email protected] * | |||
* * | |||
* This program is free software; you can redistribute it and/or modify * | |||
@@ -397,6 +397,7 @@ static int initialise(void) | |||
{//======================== | |||
int param; | |||
int result; | |||
int srate = 22050; // default sample rate | |||
// It seems that the wctype functions don't work until the locale has been set | |||
// to something other than the default "C". Then, not only Latin1 but also the | |||
@@ -412,8 +413,7 @@ static int initialise(void) | |||
#endif | |||
WavegenInit(22050,0); // 22050 | |||
if((result = LoadPhData()) != 1) | |||
if((result = LoadPhData(&srate)) != 1) | |||
{ | |||
if(result == -1) | |||
{ | |||
@@ -423,6 +423,7 @@ static int initialise(void) | |||
else | |||
fprintf(stderr,"Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n",result,version_phdata,path_home); | |||
} | |||
WavegenInit(srate,0); | |||
LoadConfig(); | |||
SetVoiceStack(NULL, ""); | |||
SynthesizeInit(); |
@@ -377,11 +377,12 @@ static int initialise(int control) | |||
{//=============================== | |||
int param; | |||
int result; | |||
int srate = 22050; // default sample rate 22050 Hz | |||
err = EE_OK; | |||
LoadConfig(); | |||
WavegenInit(22050,0); // 22050 | |||
if((result = LoadPhData()) != 1) | |||
if((result = LoadPhData(&srate)) != 1) // reads sample rate from espeak-data/phontab | |||
{ | |||
if(result == -1) | |||
{ | |||
@@ -394,6 +395,7 @@ static int initialise(int control) | |||
else | |||
fprintf(stderr,"Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n",result,version_phdata,path_home); | |||
} | |||
WavegenInit(srate,0); | |||
memset(¤t_voice_selected,0,sizeof(current_voice_selected)); | |||
SetVoiceStack(NULL, ""); |
@@ -35,8 +35,8 @@ | |||
#include "translate.h" | |||
#include "wave.h" | |||
const char *version_string = "1.46.35 14.Feb.13"; | |||
const int version_phdata = 0x014631; | |||
const char *version_string = "1.46.36 20.Feb.13"; | |||
const int version_phdata = 0x014636; | |||
int option_device_number = -1; | |||
FILE *f_logespeak = NULL; | |||
@@ -108,13 +108,14 @@ static char *ReadPhFile(void *ptr, const char *fname, int *size) | |||
} // end of ReadPhFile | |||
int LoadPhData() | |||
{//============= | |||
int LoadPhData(int *srate) | |||
{//======================== | |||
int ix; | |||
int n_phonemes; | |||
int version; | |||
int result = 1; | |||
int length; | |||
int rate; | |||
unsigned char *p; | |||
int *pw; | |||
@@ -126,14 +127,16 @@ int LoadPhData() | |||
return(-1); | |||
if((tunes = (TUNE *)ReadPhFile((void *)(tunes),"intonations",&length)) == NULL) | |||
return(-1); | |||
wavefile_data = (unsigned char *)phondata_ptr; | |||
wavefile_data = (unsigned char *)phondata_ptr; | |||
n_tunes = length / sizeof(TUNE); | |||
// read the version number from the first 4 bytes of phondata | |||
version = 0; | |||
// read the version number and sample rate from the first 8 bytes of phondata | |||
version = 0; // bytes 0-3, version number | |||
rate = 0; // bytes 4-7, sample rate | |||
for(ix=0; ix<4; ix++) | |||
{ | |||
version += (wavefile_data[ix] << (ix*8)); | |||
rate += (wavefile_data[ix+4] << (ix*8)); | |||
} | |||
if(version != version_phdata) | |||
@@ -163,6 +166,8 @@ int LoadPhData() | |||
if(phoneme_tab_number >= n_phoneme_tables) | |||
phoneme_tab_number = 0; | |||
if(srate != NULL) | |||
*srate = rate; | |||
return(result); | |||
} // end of LoadPhData | |||
@@ -970,7 +975,9 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_ | |||
phdata->pd_param[i_LENGTH_MOD] = ph->length_mod; | |||
if(ph->program == 0) | |||
{ | |||
return; | |||
} | |||
end_flag = 0; | |||
@@ -1215,7 +1222,13 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_ | |||
memcpy(&worddata->prev_vowel, &plist[0], sizeof(PHONEME_LIST)); | |||
} | |||
#ifdef _ESPEAKEDIT | |||
plist->std_length = phdata->pd_param[i_SET_LENGTH]; | |||
if(phdata->sound_addr[0] != 0) | |||
plist->phontab_addr = phdata->sound_addr[0]; // FMT address | |||
else | |||
plist->phontab_addr = phdata->sound_addr[1]; // WAV address | |||
#endif | |||
} // end of InterpretPhoneme | |||
@@ -1,5 +1,5 @@ | |||
/*************************************************************************** | |||
* Copyright (C) 2005 to 2010 by Jonathan Duddington * | |||
* Copyright (C) 2005 to 2013 by Jonathan Duddington * | |||
* email: [email protected] * | |||
* * | |||
* This program is free software; you can redistribute it and/or modify * | |||
@@ -40,7 +40,7 @@ static void SmoothSpect(void); | |||
// list of phonemes in a clause | |||
int n_phoneme_list=0; | |||
PHONEME_LIST phoneme_list[N_PHONEME_LIST]; | |||
PHONEME_LIST phoneme_list[N_PHONEME_LIST+1]; | |||
int mbrola_delay; | |||
char mbrola_name[20]; | |||
@@ -1395,6 +1395,8 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume) | |||
prev = &phoneme_list[ix-1]; | |||
next = &phoneme_list[ix+1]; | |||
next2 = &phoneme_list[ix+2]; | |||
if(next2->ph == NULL) | |||
break; | |||
if(p->synthflags & SFLAG_EMBEDDED) | |||
{ | |||
@@ -1448,6 +1450,9 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume) | |||
{ | |||
case phPAUSE: | |||
DoPause(p->length,0); | |||
#ifdef _ESPEAKEDIT | |||
p->std_length = p->ph->std_length; | |||
#endif | |||
break; | |||
case phSTOP: |
@@ -1,5 +1,5 @@ | |||
/*************************************************************************** | |||
* Copyright (C) 2005 to 2007 by Jonathan Duddington * | |||
* Copyright (C) 2005 to 2013 by Jonathan Duddington * | |||
* email: [email protected] * | |||
* * | |||
* This program is free software; you can redistribute it and/or modify * | |||
@@ -220,7 +220,10 @@ typedef struct { | |||
unsigned char newword; // bit 0=start of word, bit 1=end of clause, bit 2=start of sentence | |||
unsigned char pitch1; | |||
unsigned char pitch2; | |||
#ifdef _ESPEAKEDIT | |||
unsigned char std_length; | |||
unsigned int phontab_addr; | |||
#endif | |||
} PHONEME_LIST; | |||
@@ -435,7 +438,7 @@ extern PHONEME_TAB *phoneme_tab[N_PHONEME_TAB]; | |||
// list of phonemes in a clause | |||
extern int n_phoneme_list; | |||
extern PHONEME_LIST phoneme_list[N_PHONEME_LIST]; | |||
extern PHONEME_LIST phoneme_list[N_PHONEME_LIST+1]; | |||
extern unsigned int embedded_list[]; | |||
extern unsigned char env_fall[128]; | |||
@@ -510,7 +513,7 @@ unsigned int LookupSound(PHONEME_TAB *ph1, PHONEME_TAB *ph2, int which, int *mat | |||
frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, int *n_frames, PHONEME_LIST *plist); | |||
unsigned char *LookupEnvelope(int ix); | |||
int LoadPhData(); | |||
int LoadPhData(int *srate); | |||
void SynthesizeInit(void); | |||
int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume); |
@@ -3378,6 +3378,8 @@ if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(pre | |||
} | |||
MakePhonemeList(tr, clause_pause, new_sentence); | |||
phoneme_list[N_PHONEME_LIST].ph = NULL; // recognize end of phoneme_list array, in Generate() | |||
phoneme_list[N_PHONEME_LIST].sourceix = 1; | |||
if(embedded_count) // ???? is this needed | |||
{ |
@@ -1,5 +1,5 @@ | |||
/*************************************************************************** | |||
* Copyright (C) 2005 to 2007 by Jonathan Duddington * | |||
* Copyright (C) 2005 to 2013 by Jonathan Duddington * | |||
* email: [email protected] * | |||
* * | |||
* This program is free software; you can redistribute it and/or modify * | |||
@@ -503,13 +503,15 @@ void TranslDlg::OnCommand(wxCommandEvent& event) | |||
if((n_ph_list + n_phoneme_list) >= N_PH_LIST) | |||
{ | |||
n_phoneme_list = N_PH_LIST - n_ph_list - n_phoneme_list; | |||
n_phoneme_list = N_PH_LIST - n_ph_list; | |||
} | |||
memcpy(&ph_list[n_ph_list],phoneme_list,sizeof(PHONEME_LIST)*n_phoneme_list); | |||
n_ph_list += n_phoneme_list; | |||
} | |||
ph_list[N_PH_LIST].ph = NULL; // to recognize overrun off list (in Generate() ) | |||
t_phonetic->Clear(); | |||
if(option_phonemes == 2) | |||
{ |