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