| 1 | From 2108b1e8ae02f49cc909894a1024efdfde6682fd Mon Sep 17 00:00:00 2001
|
| 2 | From: Jonathan McDowell <[email protected]>
|
| 3 | Date: Mon, 3 Mar 2025 23:11:01 +0000
|
| 4 | Subject: [PATCH] Add espeak_TextToPhonemesWithTerminator (#2127)
|
| 5 | Patch-Source: https://github.com/espeak-ng/espeak-ng/commit/2108b1e8ae02f49cc909894a1024efdfde6682fd.patch
|
| 6 |
|
| 7 | ---
|
| 8 | src/include/espeak-ng/speak_lib.h | 6 ++++++
|
| 9 | src/libespeak-ng/speech.c | 9 +++++++--
|
| 10 | 2 files changed, 13 insertions(+), 2 deletions(-)
|
| 11 |
|
| 12 | diff --git a/src/include/espeak-ng/speak_lib.h b/src/include/espeak-ng/speak_lib.h
|
| 13 | index 9c0e2739bd..9ec4cafbed 100644
|
| 14 | |
| 15 | |
| 16 | @@ -541,6 +541,12 @@ ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode,
|
| 17 |
|
| 18 | */
|
| 19 |
|
| 20 | +#ifdef __cplusplus
|
| 21 | +extern "C"
|
| 22 | +#endif
|
| 23 | +ESPEAK_API const char *espeak_TextToPhonemesWithTerminator(const void **textptr, int textmode, int phonememode, int *terminator);
|
| 24 | +/* Version of espeak_TextToPhonemes that also returns the clause terminator (e.g., CLAUSE_INTONATION_FULL_STOP) */
|
| 25 | +
|
| 26 | #ifdef __cplusplus
|
| 27 | extern "C"
|
| 28 | #endif
|
| 29 | diff --git a/src/libespeak-ng/speech.c b/src/libespeak-ng/speech.c
|
| 30 | index 9f90d10543..4c108a6073 100644
|
| 31 | |
| 32 | |
| 33 | @@ -850,7 +850,7 @@ ESPEAK_API void espeak_SetPhonemeTrace(int phonememode, FILE *stream)
|
| 34 | f_trans = stderr;
|
| 35 | }
|
| 36 |
|
| 37 | -ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode, int phonememode)
|
| 38 | +ESPEAK_API const char* espeak_TextToPhonemesWithTerminator(const void** textptr, int textmode, int phonememode, int* terminator)
|
| 39 | {
|
| 40 | /* phoneme_mode
|
| 41 | bit 1: 0=eSpeak's ascii phoneme names, 1= International Phonetic Alphabet (as UTF-8 characters).
|
| 42 | @@ -864,12 +864,17 @@ ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode,
|
| 43 | if (text_decoder_decode_string_multibyte(p_decoder, *textptr, translator->encoding, textmode) != ENS_OK)
|
| 44 | return NULL;
|
| 45 |
|
| 46 | - TranslateClause(translator, NULL, NULL);
|
| 47 | + TranslateClauseWithTerminator(translator, NULL, NULL, terminator);
|
| 48 | *textptr = text_decoder_get_buffer(p_decoder);
|
| 49 |
|
| 50 | return GetTranslatedPhonemeString(phonememode);
|
| 51 | }
|
| 52 |
|
| 53 | +ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode, int phonememode)
|
| 54 | +{
|
| 55 | + return espeak_TextToPhonemesWithTerminator(textptr, textmode, phonememode, NULL);
|
| 56 | +}
|
| 57 | +
|
| 58 | ESPEAK_NG_API espeak_ng_STATUS espeak_ng_Cancel(void)
|
| 59 | {
|
| 60 | #if USE_ASYNC
|