Browse Source

Merge pull request #791

master
Valdis Vitolins 5 years ago
parent
commit
04caefe54e

+ 14
- 0
src/include/espeak-ng/espeak_ng.h View File

ENGENDER_NEUTRAL = 3, ENGENDER_NEUTRAL = 3,
} espeak_ng_VOICE_GENDER; } espeak_ng_VOICE_GENDER;


typedef struct
{
void (*outputPhoSymbol)(char* pho_code,int pho_type);
void (*outputSilence)(short echo_tail);
void (*outputVoiced)(short sample);
void (*outputUnvoiced)(short sample);
} espeak_ng_OUTPUT_HOOKS;

/* eSpeak NG 1.49.0 */ /* eSpeak NG 1.49.0 */


typedef struct espeak_ng_ERROR_CONTEXT_ *espeak_ng_ERROR_CONTEXT; typedef struct espeak_ng_ERROR_CONTEXT_ *espeak_ng_ERROR_CONTEXT;
const char *destination_path, const char *destination_path,
FILE *log, FILE *log,
espeak_ng_ERROR_CONTEXT *context); espeak_ng_ERROR_CONTEXT *context);
ESPEAK_NG_API espeak_ng_STATUS
espeak_ng_SetOutputHooks(espeak_ng_OUTPUT_HOOKS* hooks);
ESPEAK_NG_API espeak_ng_STATUS
espeak_ng_SetConstF0(int f0);



#ifdef __cplusplus #ifdef __cplusplus
} }

+ 18
- 0
src/libespeak-ng/synthesize.c View File

WcmdqInc(); WcmdqInc();
} }


static void DoPhonemeAlignment(char* pho, int type)
{
wcmdq[wcmdq_tail][0] = WCMD_PHONEME_ALIGNMENT;
wcmdq[wcmdq_tail][1] = pho;
wcmdq[wcmdq_tail][2] = type;
WcmdqInc();
}

static void DoPitch(unsigned char *env, int pitch1, int pitch2) static void DoPitch(unsigned char *env, int pitch1, int pitch2)
{ {
intptr_t *q; intptr_t *q;
} while ((word & 0x80) == 0); } while ((word & 0x80) == 0);
} }


extern espeak_ng_OUTPUT_HOOKS* output_hooks;

int Generate(PHONEME_LIST *phoneme_list, int *n_ph, bool resume) int Generate(PHONEME_LIST *phoneme_list, int *n_ph, bool resume)
{ {
static int ix; static int ix;


while ((ix < (*n_ph)) && (ix < N_PHONEME_LIST-2)) { while ((ix < (*n_ph)) && (ix < N_PHONEME_LIST-2)) {
p = &phoneme_list[ix]; p = &phoneme_list[ix];
if(output_hooks && output_hooks->outputPhoSymbol)
{
char buf[30];
int dummy=0;
WritePhMnemonic(buf, p->ph, p, 0, &dummy);
DoPhonemeAlignment(strdup(buf),p->type);
}


if (p->type == phPAUSE) if (p->type == phPAUSE)
free_min = 10; free_min = 10;

+ 1
- 0
src/libespeak-ng/synthesize.h View File

#define WCMD_MBROLA_DATA 13 #define WCMD_MBROLA_DATA 13
#define WCMD_FMT_AMPLITUDE 14 #define WCMD_FMT_AMPLITUDE 14
#define WCMD_SONIC_SPEED 15 #define WCMD_SONIC_SPEED 15
#define WCMD_PHONEME_ALIGNMENT 16


#define N_WCMDQ 170 #define N_WCMDQ 170
#define MIN_WCMDQ 25 // need this many free entries before adding new phoneme #define MIN_WCMDQ 25 // need this many free entries before adding new phoneme

+ 36
- 0
src/libespeak-ng/wavegen.c View File

unsigned char *out_start; unsigned char *out_start;
unsigned char *out_end; unsigned char *out_end;


espeak_ng_OUTPUT_HOOKS* output_hooks = NULL;
int const_f0 = 0;

// the queue of operations passed to wavegen from sythesize // the queue of operations passed to wavegen from sythesize
intptr_t wcmdq[N_WCMDQ][4]; intptr_t wcmdq[N_WCMDQ][4];
int wcmdq_head = 0; int wcmdq_head = 0;
if ((ix = wdata.pitch_ix>>8) > 127) ix = 127; if ((ix = wdata.pitch_ix>>8) > 127) ix = 127;
x = wdata.pitch_env[ix] * wdata.pitch_range; x = wdata.pitch_env[ix] * wdata.pitch_range;
wdata.pitch = (x>>8) + wdata.pitch_base; wdata.pitch = (x>>8) + wdata.pitch_base;


amp_ix += amp_inc; amp_ix += amp_inc;


x = ((int)(Flutter_tab[Flutter_ix >> 6])-0x80) * flutter_amp; x = ((int)(Flutter_tab[Flutter_ix >> 6])-0x80) * flutter_amp;
Flutter_ix += Flutter_inc; Flutter_ix += Flutter_inc;
wdata.pitch += x; wdata.pitch += x;
if(const_f0)
wdata.pitch = (const_f0<<12);
if (wdata.pitch < 102400) if (wdata.pitch < 102400)
wdata.pitch = 102400; // min pitch, 25 Hz (25 << 12) wdata.pitch = 102400; // min pitch, 25 Hz (25 << 12)


} }
*out_ptr++ = z; *out_ptr++ = z;
*out_ptr++ = z >> 8; *out_ptr++ = z >> 8;
if(output_hooks && output_hooks->outputVoiced) output_hooks->outputVoiced(z);


echo_buf[echo_head++] = z; echo_buf[echo_head++] = z;
if (echo_head >= N_ECHO_BUF) if (echo_head >= N_ECHO_BUF)


*out_ptr++ = value; *out_ptr++ = value;
*out_ptr++ = value >> 8; *out_ptr++ = value >> 8;
if(output_hooks && output_hooks->outputSilence) output_hooks->outputSilence(value);


echo_buf[echo_head++] = value; echo_buf[echo_head++] = value;
if (echo_head >= N_ECHO_BUF) if (echo_head >= N_ECHO_BUF)


out_ptr[0] = value; out_ptr[0] = value;
out_ptr[1] = value >> 8; out_ptr[1] = value >> 8;
if(output_hooks && output_hooks->outputUnvoiced) output_hooks->outputUnvoiced(value);
out_ptr += 2; out_ptr += 2;


echo_buf[echo_head++] = (value*3)/4; echo_buf[echo_head++] = (value*3)/4;
case WCMD_PITCH: case WCMD_PITCH:
SetPitch(length, (unsigned char *)q[2], q[3] >> 16, q[3] & 0xffff); SetPitch(length, (unsigned char *)q[2], q[3] >> 16, q[3] & 0xffff);
break; break;
case WCMD_PHONEME_ALIGNMENT:
{
char* data = (char*)q[1];
output_hooks->outputPhoSymbol(data,q[2]);
free(data);
}
break;
case WCMD_PAUSE: case WCMD_PAUSE:
if (resume == false) if (resume == false)
echo_complete -= length; echo_complete -= length;
#endif #endif
return finished; return finished;
} }

#pragma GCC visibility push(default)

ESPEAK_NG_API espeak_ng_STATUS
espeak_ng_SetOutputHooks(espeak_ng_OUTPUT_HOOKS* hooks)
{
output_hooks = hooks;
return 0;
}

ESPEAK_NG_API espeak_ng_STATUS
espeak_ng_SetConstF0(int f0)
{
const_f0 = f0;
}

#pragma GCC visibility pop

Loading…
Cancel
Save