mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-13 09:14:12 +00:00
Merge branch 'development' into build
This commit is contained in:
@@ -25,12 +25,19 @@ 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
|
||||
@@ -61,6 +68,7 @@ endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
speak_SOURCES = speak.cpp compiledict.cpp dictionary.cpp intonation.cpp \
|
||||
readclause.cpp setlengths.cpp numbers.cpp synth_mbrola.cpp \
|
||||
|
||||
+2
-1
@@ -95,8 +95,8 @@ static keywtab_t k_conditions[] = {
|
||||
{"nextPh", tWHICH_PHONEME, 0x200},
|
||||
{"next2Ph", tWHICH_PHONEME, 0x300},
|
||||
{"nextPhW", tWHICH_PHONEME, 0x400},
|
||||
{"next2PhW", tWHICH_PHONEME, 0x700},
|
||||
{"nextVowel",tWHICH_PHONEME, 0x600},
|
||||
// {"next2PhW", tWHICH_PHONEME, 0x700},
|
||||
|
||||
// {"numVowels", tTEST, 0x000},
|
||||
// {"afterStress", tTEST, 0x000},
|
||||
@@ -144,6 +144,7 @@ static keywtab_t k_properties[] = {
|
||||
{"isFirstVowel", 0, i_isFirstVowel},
|
||||
{"isSecondVowel", 0, i_isSecondVowel},
|
||||
{"isSeqFlag1", 0, i_isSeqFlag1},
|
||||
{"isTranslationGiven", 0, i_IsTranslationGiven}, // phoneme translation given in **_list or as [[...]]
|
||||
|
||||
{NULL, 0, 0}
|
||||
};
|
||||
|
||||
+13
-3
@@ -2161,9 +2161,19 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
|
||||
break;
|
||||
|
||||
case RULE_ENDING:
|
||||
// next 3 bytes are a (non-zero) ending type. 2 bytes of flags + suffix length
|
||||
match.end_type = (rule[0] << 16) + ((rule[1] & 0x7f) << 8) + (rule[2] & 0x7f);
|
||||
rule += 3;
|
||||
{
|
||||
int end_type;
|
||||
// next 3 bytes are a (non-zero) ending type. 2 bytes of flags + suffix length
|
||||
end_type = (rule[0] << 16) + ((rule[1] & 0x7f) << 8) + (rule[2] & 0x7f);
|
||||
|
||||
if((tr->word_vowel_count == 0) && !(end_type & SUFX_P))
|
||||
failed = 1; // don't match a suffix rule if there are no previous syllables (needed for lang=tr).
|
||||
else
|
||||
{
|
||||
match.end_type = end_type;
|
||||
rule += 3;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RULE_NO_SUFFIX:
|
||||
|
||||
@@ -448,50 +448,6 @@ void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef deleted
|
||||
while((ph->reduce_to != 0) && (!(plist3->synthflags & SFLAG_DICTIONARY) || (tr->langopts.param[LOPT_REDUCE] & 1)))
|
||||
{
|
||||
int reduce_level;
|
||||
int stress_level;
|
||||
int reduce = 0;
|
||||
|
||||
reduce_level = (ph->phflags >> 28) & 7;
|
||||
|
||||
if(ph->type == phVOWEL)
|
||||
{
|
||||
stress_level = plist3->stress;
|
||||
}
|
||||
else
|
||||
{
|
||||
// consonant, get stress from the following vowel
|
||||
if(next->type == phVOWEL)
|
||||
stress_level = (plist3+1)->stress;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if((stress_level == 1) && (first_vowel))
|
||||
stress_level = 0; // ignore 'dimished' stress on first syllable
|
||||
|
||||
if(stress_level == 1)
|
||||
reduce = 1; // stress = 'reduced'
|
||||
|
||||
if(stress_level < reduce_level)
|
||||
reduce =1;
|
||||
|
||||
if((word_stress < 4) && (tr->langopts.param[LOPT_REDUCE] & 0x2) && (stress_level >= word_stress))
|
||||
{
|
||||
// don't reduce the most stressed syllable in an unstressed word
|
||||
reduce = 0;
|
||||
}
|
||||
|
||||
if(reduce)
|
||||
ph = phoneme_tab[ph->reduce_to];
|
||||
else
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(ph->type == phVOWEL)
|
||||
first_vowel = 0;
|
||||
|
||||
|
||||
+15
-10
@@ -35,7 +35,7 @@
|
||||
#include "translate.h"
|
||||
#include "wave.h"
|
||||
|
||||
const char *version_string = "1.45.41 07.Sep.11";
|
||||
const char *version_string = "1.45.44 16.Sep.11";
|
||||
const int version_phdata = 0x014500;
|
||||
|
||||
int option_device_number = -1;
|
||||
@@ -614,7 +614,16 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist,
|
||||
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, next2PhW
|
||||
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
|
||||
// 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
|
||||
|
||||
|
||||
data = instn & 0xff;
|
||||
instn2 = instn >> 8;
|
||||
@@ -635,13 +644,6 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist,
|
||||
if(plist[0].sourceix)
|
||||
return(false);
|
||||
}
|
||||
if(which==7)
|
||||
{
|
||||
// nextPh2 not word boundary
|
||||
if((plist[1].sourceix) || (plist[2].sourceix))
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(which==6)
|
||||
{
|
||||
// nextVowel, not word boundary
|
||||
@@ -784,6 +786,9 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist,
|
||||
break;
|
||||
}
|
||||
return(count > 0);
|
||||
|
||||
case 0x10: // isTranslationGiven
|
||||
return((plist->synthflags & SFLAG_DICTIONARY) != 0);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -904,7 +909,7 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_
|
||||
|
||||
switch(instn >> 12)
|
||||
{
|
||||
case 0:
|
||||
case 0: // 0xxx
|
||||
data = instn & 0xff;
|
||||
|
||||
if(instn2 == 0)
|
||||
|
||||
@@ -329,6 +329,8 @@ typedef struct {
|
||||
#define i_isFirstVowel 0x8d
|
||||
#define i_isSecondVowel 0x8e
|
||||
#define i_isSeqFlag1 0x8f
|
||||
#define i_IsTranslationGiven 0x90
|
||||
|
||||
|
||||
// place of articulation
|
||||
#define i_isVel 0x28
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@
|
||||
#define SUFX_I 0x0200 // y may have been changed to i
|
||||
#define SUFX_P 0x0400 // prefix
|
||||
#define SUFX_V 0x0800 // suffix means use the verb form pronunciation
|
||||
#define SUFX_D 0x1000 // previous letter may have been doubles
|
||||
#define SUFX_D 0x1000 // previous letter may have been doubled
|
||||
#define SUFX_F 0x2000 // verb follows
|
||||
#define SUFX_Q 0x4000 // don't retranslate
|
||||
#define SUFX_T 0x10000 // don't affect the stress position in the stem
|
||||
|
||||
@@ -1757,6 +1757,18 @@ void FreeVoiceList()
|
||||
n_voices_list = 0;
|
||||
}
|
||||
|
||||
void FreeVoiceList()
|
||||
{//=================
|
||||
for(int ix=0; ix<n_voices_list; ix++)
|
||||
{
|
||||
if(voices_list[ix] != NULL)
|
||||
{
|
||||
free(voices_list[ix]);
|
||||
voices_list[ix] = NULL;
|
||||
}
|
||||
}
|
||||
n_voices_list = 0;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
|
||||
+142
@@ -53,6 +53,148 @@ enum {ONE_BILLION=1000000000};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef USE_PULSEAUDIO
|
||||
// create some wrappers for runtime detection
|
||||
|
||||
// checked on wave_init
|
||||
static int pulse_running;
|
||||
|
||||
// wave.cpp (this file)
|
||||
void wave_port_init(int);
|
||||
void* wave_port_open(const char* the_api);
|
||||
size_t wave_port_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize);
|
||||
int wave_port_close(void* theHandler);
|
||||
int wave_port_is_busy(void* theHandler);
|
||||
void wave_port_terminate();
|
||||
uint32_t wave_port_get_read_position(void* theHandler);
|
||||
uint32_t wave_port_get_write_position(void* theHandler);
|
||||
void wave_port_flush(void* theHandler);
|
||||
void wave_port_set_callback_is_output_enabled(t_wave_callback* cb);
|
||||
void* wave_port_test_get_write_buffer();
|
||||
int wave_port_get_remaining_time(uint32_t sample, uint32_t* time);
|
||||
|
||||
// wave_pulse.cpp
|
||||
int is_pulse_running();
|
||||
void wave_pulse_init(int);
|
||||
void* wave_pulse_open(const char* the_api);
|
||||
size_t wave_pulse_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize);
|
||||
int wave_pulse_close(void* theHandler);
|
||||
int wave_pulse_is_busy(void* theHandler);
|
||||
void wave_pulse_terminate();
|
||||
uint32_t wave_pulse_get_read_position(void* theHandler);
|
||||
uint32_t wave_pulse_get_write_position(void* theHandler);
|
||||
void wave_pulse_flush(void* theHandler);
|
||||
void wave_pulse_set_callback_is_output_enabled(t_wave_callback* cb);
|
||||
void* wave_pulse_test_get_write_buffer();
|
||||
int wave_pulse_get_remaining_time(uint32_t sample, uint32_t* time);
|
||||
|
||||
// wrappers
|
||||
void wave_init(int srate) {
|
||||
pulse_running = is_pulse_running();
|
||||
|
||||
if (pulse_running)
|
||||
wave_pulse_init(srate);
|
||||
else
|
||||
wave_port_init(srate);
|
||||
}
|
||||
|
||||
void* wave_open(const char* the_api) {
|
||||
if (pulse_running)
|
||||
return wave_pulse_open(the_api);
|
||||
else
|
||||
return wave_port_open(the_api);
|
||||
}
|
||||
|
||||
size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {
|
||||
if (pulse_running)
|
||||
return wave_pulse_write(theHandler, theMono16BitsWaveBuffer, theSize);
|
||||
else
|
||||
return wave_port_write(theHandler, theMono16BitsWaveBuffer, theSize);
|
||||
}
|
||||
|
||||
int wave_close(void* theHandler) {
|
||||
if (pulse_running)
|
||||
return wave_pulse_close(theHandler);
|
||||
else
|
||||
return wave_port_close(theHandler);
|
||||
}
|
||||
|
||||
int wave_is_busy(void* theHandler) {
|
||||
if (pulse_running)
|
||||
return wave_pulse_is_busy(theHandler);
|
||||
else
|
||||
return wave_port_is_busy(theHandler);
|
||||
}
|
||||
|
||||
void wave_terminate() {
|
||||
if (pulse_running)
|
||||
wave_pulse_terminate();
|
||||
else
|
||||
wave_port_terminate();
|
||||
}
|
||||
|
||||
uint32_t wave_get_read_position(void* theHandler) {
|
||||
if (pulse_running)
|
||||
return wave_pulse_get_read_position(theHandler);
|
||||
else
|
||||
return wave_port_get_read_position(theHandler);
|
||||
}
|
||||
|
||||
uint32_t wave_get_write_position(void* theHandler) {
|
||||
if (pulse_running)
|
||||
return wave_pulse_get_write_position(theHandler);
|
||||
else
|
||||
return wave_port_get_write_position(theHandler);
|
||||
}
|
||||
|
||||
void wave_flush(void* theHandler) {
|
||||
if (pulse_running)
|
||||
wave_pulse_flush(theHandler);
|
||||
else
|
||||
wave_port_flush(theHandler);
|
||||
}
|
||||
|
||||
void wave_set_callback_is_output_enabled(t_wave_callback* cb) {
|
||||
if (pulse_running)
|
||||
wave_pulse_set_callback_is_output_enabled(cb);
|
||||
else
|
||||
wave_port_set_callback_is_output_enabled(cb);
|
||||
}
|
||||
|
||||
void* wave_test_get_write_buffer() {
|
||||
if (pulse_running)
|
||||
return wave_pulse_test_get_write_buffer();
|
||||
else
|
||||
return wave_port_test_get_write_buffer();
|
||||
}
|
||||
|
||||
int wave_get_remaining_time(uint32_t sample, uint32_t* time)
|
||||
{
|
||||
if (pulse_running)
|
||||
return wave_pulse_get_remaining_time(sample, time);
|
||||
else
|
||||
return wave_port_get_remaining_time(sample, time);
|
||||
}
|
||||
|
||||
// rename functions to be wrapped
|
||||
#define wave_init wave_port_init
|
||||
#define wave_open wave_port_open
|
||||
#define wave_write wave_port_write
|
||||
#define wave_close wave_port_close
|
||||
#define wave_is_busy wave_port_is_busy
|
||||
#define wave_terminate wave_port_terminate
|
||||
#define wave_get_read_position wave_port_get_read_position
|
||||
#define wave_get_write_position wave_port_get_write_position
|
||||
#define wave_flush wave_port_flush
|
||||
#define wave_set_callback_is_output_enabled wave_port_set_callback_is_output_enabled
|
||||
#define wave_test_get_write_buffer wave_port_test_get_write_buffer
|
||||
#define wave_get_remaining_time wave_port_get_remaining_time
|
||||
|
||||
#endif // USE_PULSEAUDIO
|
||||
|
||||
|
||||
static t_wave_callback* my_callback_is_output_enabled=NULL;
|
||||
|
||||
#define N_WAV_BUF 10
|
||||
|
||||
+37
-1
@@ -65,6 +65,7 @@ enum {
|
||||
|
||||
static t_wave_callback* my_callback_is_output_enabled=NULL;
|
||||
|
||||
#define SAMPLE_RATE 22050
|
||||
#define ESPEAK_FORMAT PA_SAMPLE_S16LE
|
||||
#define ESPEAK_CHANNEL 1
|
||||
|
||||
@@ -74,6 +75,39 @@ static t_wave_callback* my_callback_is_output_enabled=NULL;
|
||||
#define MINREQ 880
|
||||
#define FRAGSIZE 0
|
||||
|
||||
#ifdef USE_PORTAUDIO
|
||||
// rename functions to be wrapped
|
||||
#define wave_init wave_pulse_init
|
||||
#define wave_open wave_pulse_open
|
||||
#define wave_write wave_pulse_write
|
||||
#define wave_close wave_pulse_close
|
||||
#define wave_is_busy wave_pulse_is_busy
|
||||
#define wave_terminate wave_pulse_terminate
|
||||
#define wave_get_read_position wave_pulse_get_read_position
|
||||
#define wave_get_write_position wave_pulse_get_write_position
|
||||
#define wave_flush wave_pulse_flush
|
||||
#define wave_set_callback_is_output_enabled wave_pulse_set_callback_is_output_enabled
|
||||
#define wave_test_get_write_buffer wave_pulse_test_get_write_buffer
|
||||
#define wave_get_remaining_time wave_pulse_get_remaining_time
|
||||
|
||||
// check whether we can connect to PulseAudio
|
||||
#include <pulse/simple.h>
|
||||
int is_pulse_running()
|
||||
{
|
||||
pa_sample_spec ss;
|
||||
ss.format = ESPEAK_FORMAT;
|
||||
ss.rate = SAMPLE_RATE;
|
||||
ss.channels = ESPEAK_CHANNEL;
|
||||
|
||||
pa_simple *s = pa_simple_new(NULL, "eSpeak", PA_STREAM_PLAYBACK, NULL, "is_pulse_running", &ss, NULL, NULL, NULL);
|
||||
if (s) {
|
||||
pa_simple_free(s);
|
||||
return 1;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
#endif // USE_PORTAUDIO
|
||||
|
||||
static pthread_mutex_t pulse_mutex;
|
||||
|
||||
static pa_context *context = NULL;
|
||||
@@ -843,8 +877,9 @@ int wave_get_remaining_time(uint32_t sample, uint32_t* time)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // of USE_PORTAUDIO
|
||||
#endif // of USE_PULSEAUDIO
|
||||
|
||||
#ifndef USE_PORTAUDIO
|
||||
//>
|
||||
//<clock_gettime2, add_time_in_ms
|
||||
|
||||
@@ -878,6 +913,7 @@ void add_time_in_ms(struct timespec *ts, int time_in_ms)
|
||||
}
|
||||
ts->tv_nsec = (long int)t_ns;
|
||||
}
|
||||
#endif // ifndef USE_PORTAUDIO
|
||||
|
||||
|
||||
#endif // USE_ASYNC
|
||||
|
||||
Reference in New Issue
Block a user