mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-12-01 22:36:14 +00:00
[1.31]
Return espeakEVENT_MARK events in AUDIO_OUTPUT_PLAYBACK mode. New phoneme [ _;_ ] a pause which ends intonation for a clause (the equivalent of a comma). lang=en-r: adjusted phonemes git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@129 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
+14
-12
@@ -193,11 +193,11 @@ static espeak_EVENT* event_copy (espeak_EVENT* event)
|
||||
static void event_notify(espeak_EVENT* event)
|
||||
{
|
||||
ENTER("event_notify");
|
||||
|
||||
static unsigned int a_old_uid = 0;
|
||||
|
||||
espeak_EVENT events[2];
|
||||
memcpy(&events[0],event,sizeof(espeak_EVENT)); // the event parameter in the callback function should be an array of eventd
|
||||
memcpy(&events[1],event,sizeof(espeak_EVENT));
|
||||
events[1].type = espeakEVENT_LIST_TERMINATED; // ... terminated by an event type=0
|
||||
|
||||
if (event && my_callback)
|
||||
@@ -207,31 +207,33 @@ ENTER("event_notify");
|
||||
switch(event->type)
|
||||
{
|
||||
case espeakEVENT_SENTENCE:
|
||||
my_callback(NULL, 0, event);
|
||||
my_callback(NULL, 0, events);
|
||||
a_old_uid = event->unique_identifier;
|
||||
break;
|
||||
|
||||
case espeakEVENT_MSG_TERMINATED:
|
||||
case espeakEVENT_MARK:
|
||||
case espeakEVENT_WORD:
|
||||
case espeakEVENT_MSG_TERMINATED:
|
||||
case espeakEVENT_END:
|
||||
case espeakEVENT_PHONEME:
|
||||
{
|
||||
// jonsd - I'm not sure what this is for. gilles says it's for when Gnome Speech reads a file of blank lines
|
||||
if (a_old_uid != event->unique_identifier)
|
||||
{
|
||||
espeak_EVENT_TYPE a_new_type = event->type;
|
||||
event->type = espeakEVENT_SENTENCE;
|
||||
my_callback(NULL, 0, event);
|
||||
event->type = a_new_type;
|
||||
espeak_EVENT_TYPE a_new_type = events[0].type;
|
||||
events[0].type = espeakEVENT_SENTENCE;
|
||||
my_callback(NULL, 0, events);
|
||||
events[0].type = a_new_type;
|
||||
usleep(50000);
|
||||
}
|
||||
my_callback(NULL, 0, event);
|
||||
my_callback(NULL, 0, events);
|
||||
a_old_uid = event->unique_identifier;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case espeakEVENT_LIST_TERMINATED:
|
||||
case espeakEVENT_MARK:
|
||||
case espeakEVENT_PLAY:
|
||||
case espeakEVENT_END:
|
||||
case espeakEVENT_LIST_TERMINATED:
|
||||
case espeakEVENT_PLAY:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-73
@@ -80,6 +80,8 @@ void CloseWaveFile3(FILE *f)
|
||||
unsigned int pos;
|
||||
static int value;
|
||||
|
||||
if(f == NULL)
|
||||
return;
|
||||
|
||||
fflush(f);
|
||||
pos = ftell(f);
|
||||
@@ -118,13 +120,13 @@ int TestUriCallback(int type, const char *uri, const char *base)
|
||||
int TestSynthCallback(short *wav, int numsamples, espeak_EVENT *events)
|
||||
{//====================================================================
|
||||
int type;
|
||||
f_events = fopen("/home/jsd1/speechdata/text/events","a");
|
||||
|
||||
fprintf(f_events,"--\n");
|
||||
if(f_wavtest == NULL) return(0);
|
||||
|
||||
while((type = events->type) != 0)
|
||||
{
|
||||
fprintf(f_events,"%5d %4d (%2d) %d ",events->audio_position,events->text_position,events->length,type);
|
||||
fprintf(f_events,"%2d (%4d %4d) %5d %5d (%3d) ",type,events->unique_identifier,(int)events->user_data,events->audio_position,events->text_position,events->length);
|
||||
if((type==3) || (type==4))
|
||||
fprintf(f_events,"'%s'\n",events->id.name);
|
||||
else
|
||||
@@ -136,15 +138,15 @@ int TestSynthCallback(short *wav, int numsamples, espeak_EVENT *events)
|
||||
events++;
|
||||
}
|
||||
|
||||
if(wav == NULL)
|
||||
if((wav == NULL) && (f_wavtest != NULL))
|
||||
{
|
||||
fprintf(f_events,"Finished\n");
|
||||
CloseWaveFile3(f_wavtest);
|
||||
f_wavtest = NULL;
|
||||
fclose(f_events);
|
||||
return(0);
|
||||
}
|
||||
fclose(f_events);
|
||||
|
||||
if(f_wavtest == NULL) return(0);
|
||||
fwrite(wav,numsamples*2,1,f_wavtest);
|
||||
return(0);
|
||||
}
|
||||
@@ -1154,71 +1156,11 @@ void Test2()
|
||||
fclose(f_out);
|
||||
}
|
||||
|
||||
void Test3()
|
||||
{
|
||||
espeak_VOICE voicespec;
|
||||
espeak_VOICE *newvoice;
|
||||
int x;
|
||||
|
||||
espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,100,NULL,0);
|
||||
memset(&voicespec,0,sizeof(voicespec));
|
||||
voicespec.languages = "de";
|
||||
voicespec.gender = 2;
|
||||
|
||||
espeak_SetVoiceByProperties(&voicespec);
|
||||
newvoice = espeak_GetCurrentVoice();
|
||||
x = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define OUTPUT_MODE AUDIO_OUTPUT_PLAYBACK
|
||||
#define TEXT "Hello world."
|
||||
#define TEXT_SSML ("<speak>" TEXT "</speak>")
|
||||
static void
|
||||
speak(const char *text)
|
||||
{
|
||||
int result;
|
||||
result = espeak_Synth(text, strlen(text) + 1, 0, POS_CHARACTER, 0, espeakSSML, NULL, NULL);
|
||||
assert(result == EE_OK);
|
||||
}
|
||||
|
||||
|
||||
int test4() {
|
||||
espeak_ERROR result;
|
||||
int sample_rate;
|
||||
sample_rate = espeak_Initialize(OUTPUT_MODE, 2000, NULL, 0);
|
||||
assert(sample_rate != EE_INTERNAL_ERROR);
|
||||
espeak_SetSynthCallback(synth_callback);
|
||||
|
||||
espeak_VOICE voice;
|
||||
memset(&voice, 0, sizeof(espeak_VOICE));
|
||||
// voice.name = "default";
|
||||
// voice.languages = "en";
|
||||
voice.gender = 2;
|
||||
// voice.age = 4;
|
||||
|
||||
result = espeak_SetVoiceByProperties(&voice);
|
||||
assert(result == EE_OK);
|
||||
speak(TEXT_SSML);
|
||||
speak(TEXT_SSML);
|
||||
espeak_Synchronize();
|
||||
|
||||
#ifdef deleted
|
||||
/* Now the same ting without ssml tags. */
|
||||
result = espeak_SetVoiceByProperties(&voice);
|
||||
assert(result == EE_OK);
|
||||
speak(TEXT);
|
||||
speak(TEXT);
|
||||
espeak_Synchronize();
|
||||
#endif
|
||||
result = espeak_Terminate();
|
||||
assert(result == EE_OK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const char* text1 = "Hello World2. <audio src=\"here\"> Some text</audio> This is the second sentence";
|
||||
const char* text1 = "Hello, World2 <mark name=\"mark2\"/>. This is the second sentence";
|
||||
|
||||
void TestTest(int control)
|
||||
{//=======================
|
||||
@@ -1227,10 +1169,9 @@ void TestTest(int control)
|
||||
unsigned int ix=0;
|
||||
char textbuf[2000];
|
||||
espeak_VOICE voice;
|
||||
unsigned int unique_identifier=0;
|
||||
static unsigned int unique_identifier= 123;
|
||||
static int user_data = 456;
|
||||
|
||||
//FindPhonemesUsed();
|
||||
//return;
|
||||
//CharsetToUnicode("ISO-8859-4");
|
||||
//CharsetToUnicode("ISCII");
|
||||
|
||||
@@ -1243,7 +1184,7 @@ if(control==2)
|
||||
}
|
||||
memset(&voice,0,sizeof(voice));
|
||||
|
||||
f = fopen("/home/jsd1/speechdata/text/test","r");
|
||||
f = fopen("/home/jsd1/speechdata/text/test.txt","r");
|
||||
if(f==NULL)
|
||||
return;
|
||||
|
||||
@@ -1259,13 +1200,15 @@ if(control==2)
|
||||
|
||||
f_wavtest = OpenWaveFile3("/home/jsd1/speechdata/text/test.wav");
|
||||
f_events = fopen("/home/jsd1/speechdata/text/events","w");
|
||||
fprintf(f_events,"Audio Text Length Type Id\n");
|
||||
fprintf(f_events,"Type Audio Text Length Id\n");
|
||||
fclose(f_events);
|
||||
|
||||
espeak_Initialize(AUDIO_OUTPUT_RETRIEVAL,1000,NULL,1);
|
||||
espeak_Initialize(AUDIO_OUTPUT_PLAYBACK,1000,NULL,0);
|
||||
espeak_SetSynthCallback(TestSynthCallback);
|
||||
espeak_SetUriCallback(TestUriCallback);
|
||||
|
||||
espeak_Synth(text1, strlen(text1)+1, 0, POS_CHARACTER, 0, espeakSSML|espeakCHARS_UTF8, &unique_identifier, NULL);
|
||||
espeak_Synth(text1, strlen(text1)+1, 0, POS_CHARACTER, 0, espeakSSML|espeakCHARS_UTF8, &unique_identifier, (void *)user_data);
|
||||
espeak_Synth(text1, strlen(text1)+1, 0, POS_CHARACTER, 0, espeakSSML|espeakCHARS_UTF8, &unique_identifier, (void *)(user_data+1));
|
||||
|
||||
espeak_SetParameter(espeakPUNCTUATION, 1, 0);
|
||||
espeak_Synchronize();
|
||||
|
||||
+28
-7
@@ -35,10 +35,15 @@
|
||||
provide a more flexible intonation system.
|
||||
*/
|
||||
|
||||
// bits in SYLLABLE.flags
|
||||
#define SYL_RISE 1
|
||||
#define SYL_EMPHASIS 2
|
||||
#define SYL_END_CLAUSE 4
|
||||
|
||||
typedef struct {
|
||||
char stress;
|
||||
char env;
|
||||
char flags; //bit 0=pitch rising, bit1=emnphasized
|
||||
char flags; //bit 0=pitch rising, bit1=emnphasized, bit2=end of clause
|
||||
char nextph_type;
|
||||
short pitch1;
|
||||
short pitch2;
|
||||
@@ -286,7 +291,7 @@ static TONE_TABLE tone_table[N_TONE_TABLE] = {
|
||||
20, 25, 34, 20, drops_0, 3, 3, 5, oflow, NULL, 15, 28, 0},
|
||||
|
||||
{PITCHfall, 41, 4, PITCHfall, 41, 27, // 3 exclamation
|
||||
20, 25, 34, 24, drops_0, 3, 4, 5, oflow_emf, back_emf, 16, 4, 0},
|
||||
20, 25, 36, 22, drops_0, 3, 4, 5, oflow_emf, back_emf, 16, 4, 0},
|
||||
|
||||
{PITCHfall, 38, 2, PITCHfall, 42, 30, // 4 statement, emphatic
|
||||
20, 25, 34, 22, drops_0, 3, 3, 5, oflow, NULL, 15, 5, 0},
|
||||
@@ -456,7 +461,7 @@ static void set_pitch(SYLLABLE *syl, int base, int drop)
|
||||
|
||||
if(drop < 0)
|
||||
{
|
||||
flags = 1;
|
||||
flags = SYL_RISE;
|
||||
drop = -drop;
|
||||
}
|
||||
|
||||
@@ -892,8 +897,10 @@ void Translator::CalcPitches(int clause_type)
|
||||
int option;
|
||||
int group_tone;
|
||||
int group_tone_emph;
|
||||
int group_tone_comma;
|
||||
int ph_start=0;
|
||||
int st_start;
|
||||
int st_clause_end;
|
||||
int count;
|
||||
int n_primary;
|
||||
int count_primary;
|
||||
@@ -917,6 +924,11 @@ void Translator::CalcPitches(int clause_type)
|
||||
if(p->tone >= 4)
|
||||
n_primary++;
|
||||
}
|
||||
else
|
||||
if((p->ph->code == phonPAUSE_CLAUSE) && (n_st > 0))
|
||||
{
|
||||
syllable_tab[n_st-1].flags |= SYL_END_CLAUSE;
|
||||
}
|
||||
}
|
||||
syllable_tab[n_st].stress = 0; // extra 0 entry at the end
|
||||
|
||||
@@ -938,6 +950,7 @@ void Translator::CalcPitches(int clause_type)
|
||||
|
||||
group_tone = punct_to_tone[option][clause_type];
|
||||
group_tone_emph = punct_to_tone[option][5]; // emphatic form of statement
|
||||
group_tone_comma = punct_to_tone[option][1]; // emphatic form of statement
|
||||
|
||||
if(clause_type == 4)
|
||||
no_tonic = 1; /* incomplete clause, used for abbreviations such as Mr. Dr. Mrs. */
|
||||
@@ -975,7 +988,7 @@ void Translator::CalcPitches(int clause_type)
|
||||
if(syllable_tab[ix].stress == 6)
|
||||
{
|
||||
// emphasize this syllable, but don't end the current tone group
|
||||
syllable_tab[st_ix].flags = 2;
|
||||
syllable_tab[st_ix].flags = SYL_EMPHASIS;
|
||||
syl->stress = 5;
|
||||
break;
|
||||
}
|
||||
@@ -985,7 +998,7 @@ void Translator::CalcPitches(int clause_type)
|
||||
if(syl->stress == 6)
|
||||
{
|
||||
// an emphasized syllable, end the tone group after the next primary stress
|
||||
syllable_tab[st_ix].flags = 2;
|
||||
syllable_tab[st_ix].flags = SYL_EMPHASIS;
|
||||
|
||||
count = 0;
|
||||
if((n_primary - count_primary) > 1)
|
||||
@@ -1011,6 +1024,14 @@ void Translator::CalcPitches(int clause_type)
|
||||
|
||||
st_start = ix;
|
||||
}
|
||||
if((st_start < st_ix) && (syl->flags & SYL_END_CLAUSE))
|
||||
{
|
||||
// end of clause after this syllable, indicated by a phonPAUSE_CLAUSE phoneme
|
||||
st_clause_end = st_ix+1;
|
||||
count_pitch_vowels(st_start, st_clause_end, st_clause_end);
|
||||
calc_pitches(st_start, st_clause_end, group_tone_comma);
|
||||
st_start = st_clause_end;
|
||||
}
|
||||
}
|
||||
|
||||
if(st_start < st_ix)
|
||||
@@ -1040,7 +1061,7 @@ void Translator::CalcPitches(int clause_type)
|
||||
p->pitch2 = x;
|
||||
|
||||
p->env = PITCHfall;
|
||||
if(syl->flags & 1)
|
||||
if(syl->flags & SYL_RISE)
|
||||
{
|
||||
p->env = PITCHrise;
|
||||
}
|
||||
@@ -1054,7 +1075,7 @@ void Translator::CalcPitches(int clause_type)
|
||||
if(p->tone > 5)
|
||||
p->env = syl->env;
|
||||
|
||||
if(syl->flags & 2)
|
||||
if(syl->flags & SYL_EMPHASIS)
|
||||
{
|
||||
p->tone |= 8; // emphasized
|
||||
}
|
||||
|
||||
@@ -85,6 +85,8 @@
|
||||
#define phonPAUSE_LONG 24
|
||||
#define phonT_REDUCED 25
|
||||
#define phonSTRESS_TONIC 26
|
||||
#define phonPAUSE_CLAUSE 27
|
||||
|
||||
extern const unsigned char pause_phonemes[8]; // 0, vshort, short, pause, long, glottalstop
|
||||
|
||||
// place of articulation
|
||||
|
||||
+17
-4
@@ -50,6 +50,7 @@ int ungot_char2 = 0;
|
||||
char *p_textinput;
|
||||
wchar_t *p_wchar_input;
|
||||
int ungot_char;
|
||||
char *ungot_word = NULL;
|
||||
int end_of_input;
|
||||
|
||||
int ignore_text=0; // set during <sub> ... </sub> to ignore text which has been replaced by an alias
|
||||
@@ -1741,6 +1742,13 @@ int Translator::ReadClause(FILE *f_in, char *buf, unsigned short *charix, int n_
|
||||
|
||||
f_input = f_in; // for GetC etc
|
||||
|
||||
if(ungot_word != NULL)
|
||||
{
|
||||
strcpy(buf,ungot_word);
|
||||
ix += strlen(ungot_word);
|
||||
ungot_word = NULL;
|
||||
}
|
||||
|
||||
if(ungot_char2 != 0)
|
||||
{
|
||||
c2 = ungot_char2;
|
||||
@@ -1936,17 +1944,22 @@ f_input = f_in; // for GetC etc
|
||||
else
|
||||
if(iswspace(c1))
|
||||
{
|
||||
char *p_word;
|
||||
|
||||
if(translator_name == 0x6a626f)
|
||||
{
|
||||
// language jbo : lojban
|
||||
// treat "i" or ".i" as end-of-sentence
|
||||
if(buf[ix-1] == 'i')
|
||||
p_word = &buf[ix-1];
|
||||
if(p_word[0] == 'i')
|
||||
{
|
||||
if(iswspace(buf[ix-2]) || ((buf[ix-2] == '.') && iswspace(buf[ix-3])))
|
||||
if(p_word[-1] == '.')
|
||||
p_word--;
|
||||
if(p_word[-1] == ' ')
|
||||
{
|
||||
ungot_word = "i ";
|
||||
UngetC(c2);
|
||||
buf[ix] = ' ';
|
||||
buf[ix+1] = 0;
|
||||
p_word[0] = 0;
|
||||
return(CLAUSE_PERIOD);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,7 +467,13 @@ void Translator::CalcLengths()
|
||||
{
|
||||
if((p2->type == phVOWEL) && !(p2->ph->phflags & phNONSYLLABIC))
|
||||
more_syllables++;
|
||||
|
||||
if(p2->ph->code == phonPAUSE_CLAUSE)
|
||||
end_of_clause = 2;
|
||||
}
|
||||
if(p2->ph->code == phonPAUSE_CLAUSE)
|
||||
end_of_clause = 2;
|
||||
|
||||
if((p2->newword & 2) && (more_syllables==0))
|
||||
{
|
||||
end_of_clause = 2;
|
||||
|
||||
+2
-2
@@ -35,8 +35,8 @@
|
||||
#include "translate.h"
|
||||
#include "wave.h"
|
||||
|
||||
const char *version_string = "1.30.15 17.Jan.08";
|
||||
const int version_phdata = 0x013010;
|
||||
const char *version_string = "1.31 19.Jan.08";
|
||||
const int version_phdata = 0x013100;
|
||||
|
||||
int option_device_number = -1;
|
||||
|
||||
|
||||
@@ -423,8 +423,8 @@ SetLengthMods(tr,3); // all equal
|
||||
|
||||
case L_jbo: // Lojban
|
||||
{
|
||||
static const short stress_lengths_jbo[8] = {180,180, 220,220, 0,0, 260,280};
|
||||
static const wchar_t jbo_punct_within_word[] = {'.',',','\'',0x2c8,0}; // allow period and comma within a word, also stress marker
|
||||
static const short stress_lengths_jbo[8] = {185,170, 200,200, 0,0, 290,300};
|
||||
static const wchar_t jbo_punct_within_word[] = {'.',',','\'',0x2c8,0}; // allow period and comma within a word, also stress marker (from LOPT_SYLLABLE_CAPS)
|
||||
tr = new Translator();
|
||||
SetupTranslator(tr,stress_lengths_jbo,NULL);
|
||||
tr->langopts.stress_rule = 2;
|
||||
@@ -572,14 +572,14 @@ SetLengthMods(tr,3); // all equal
|
||||
tr->langopts.spelling_stress = 1;
|
||||
tr->langopts.param[LOPT_COMBINE_WORDS] = 4; // combine some prepositions with the following word
|
||||
|
||||
tr->langopts.numbers = 0x1c01 + 0x4000;
|
||||
tr->langopts.numbers = 0x0c01 + 0x4000 + NUM_ROMAN;
|
||||
tr->langopts.numbers2 = 0x40;
|
||||
tr->langopts.thousands_sep = 0; //no thousands separator
|
||||
tr->langopts.decimal_sep = ',';
|
||||
|
||||
if(name2 == L('c','s'))
|
||||
{
|
||||
tr->langopts.numbers2 = 0x8; // variant numbers before milliards
|
||||
tr->langopts.numbers2 = 0x48; // variant numbers before milliards
|
||||
}
|
||||
|
||||
SetLetterVowel(tr,'y');
|
||||
@@ -623,7 +623,7 @@ SetLengthMods(tr,3); // all equal
|
||||
|
||||
case L('t','a'):
|
||||
{
|
||||
static const short stress_lengths_ta[8] = {190, 190, 210, 210, 0, 0, 230, 250};
|
||||
static const short stress_lengths_ta[8] = {190, 190, 210, 210, 0, 0, 220, 220};
|
||||
static const unsigned char stress_amps_ta[8] = {17,14, 20,19, 20,24, 24,22 };
|
||||
|
||||
tr = new Translator();
|
||||
|
||||
Reference in New Issue
Block a user