Skip to content

Commit

Permalink
espeak-ng-mbrola: Fix mbrola voices with rate different from 22KHz
Browse files Browse the repository at this point in the history
espeak_ng_GetSampleRate does not report the rate of mbrola voices.

Fixes brailcom#949
  • Loading branch information
sthibaul committed Sep 15, 2024
1 parent 6abad3e commit e51235d
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/modules/espeak.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* espeak.c - Speech Dispatcher backend for espeak
*
* Copyright (C) 2007 Brailcom, o.p.s.
* Copyright (C) 2019-2022 Samuel Thibault <[email protected]>
* Copyright (C) 2019-2024 Samuel Thibault <[email protected]>
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -677,15 +677,10 @@ static gboolean espeak_send_audio_upto(short *wav, int *sent, int upto)
if (wav == NULL || numsamples == 0) {
return TRUE;
}
#ifdef ESPEAK_NG_INCLUDE
int rate = espeak_ng_GetSampleRate();
#else
int rate = espeak_sample_rate;
#endif
AudioTrack track = {
.bits = 16,
.num_channels = 1,
.sample_rate = rate,
.sample_rate = espeak_sample_rate,
.num_samples = numsamples,
.samples = wav + (*sent),
};
Expand Down Expand Up @@ -743,6 +738,13 @@ static int synth_callback(short *wav, int numsamples, espeak_EVENT * events)
return 1;
/* Process actual event */
switch (events->type) {
case espeakEVENT_SENTENCE:
case espeakEVENT_WORD:
case espeakEVENT_PHONEME:
case espeakEVENT_END:
// Ignore
break;

case espeakEVENT_MARK:
if (EspeakIndexing) {
DBG(DBG_MODNAME " Reporting mark %s", events->id.name);
Expand All @@ -763,7 +765,12 @@ static int synth_callback(short *wav, int numsamples, espeak_EVENT * events)
// This event never has any audio in the same callback
DBG(DBG_MODNAME " Synth terminated");
break;
case espeakEVENT_SAMPLERATE:
DBG(DBG_MODNAME " Got sample rate %d", events->id.number);
espeak_sample_rate = events->id.number;
break;
default:
DBG(DBG_MODNAME " Got unsupported event %d\n", events->type);
break;
}
if (stop_requested)
Expand Down

0 comments on commit e51235d

Please sign in to comment.