mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-29 05:51:52 +00:00
Merge pull request #791
This commit is contained in:
@@ -77,6 +77,14 @@ typedef enum {
|
|||||||
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;
|
||||||
@@ -189,6 +197,12 @@ espeak_ng_CompilePhonemeDataPath(long rate,
|
|||||||
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
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -146,6 +146,14 @@ static void DoAmplitude(int amp, unsigned char *amp_env)
|
|||||||
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;
|
||||||
@@ -1131,6 +1139,8 @@ void DoEmbedded(int *embix, int sourceix)
|
|||||||
} 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;
|
||||||
@@ -1188,6 +1198,14 @@ int Generate(PHONEME_LIST *phoneme_list, int *n_ph, bool resume)
|
|||||||
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;
|
||||||
else if (p->type != phVOWEL)
|
else if (p->type != phVOWEL)
|
||||||
|
|||||||
@@ -433,6 +433,7 @@ extern unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1];
|
|||||||
#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
|
||||||
|
|||||||
@@ -116,6 +116,9 @@ unsigned char *out_ptr;
|
|||||||
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;
|
||||||
@@ -546,6 +549,8 @@ static void AdvanceParameters()
|
|||||||
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;
|
||||||
|
|
||||||
/* add pitch flutter */
|
/* add pitch flutter */
|
||||||
@@ -554,6 +559,10 @@ static void AdvanceParameters()
|
|||||||
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)
|
||||||
|
|
||||||
@@ -884,6 +893,7 @@ static int Wavegen()
|
|||||||
}
|
}
|
||||||
*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)
|
||||||
@@ -917,6 +927,7 @@ static int PlaySilence(int length, bool resume)
|
|||||||
|
|
||||||
*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)
|
||||||
@@ -969,6 +980,7 @@ static int PlayWave(int length, bool resume, unsigned char *data, int scale, int
|
|||||||
|
|
||||||
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;
|
||||||
@@ -1284,6 +1296,13 @@ static int WavegenFill2()
|
|||||||
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;
|
||||||
@@ -1418,3 +1437,20 @@ int WavegenFill(void)
|
|||||||
#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
|
||||||
|
|||||||
Reference in New Issue
Block a user