ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode, int phonememode);
/* Translates text into phonemes. Call espeak_SetVoiceByName() first, to select a language.
It returns a pointer to a character string which contains the phonemes for the text up to
end of a sentence, or comma, semicolon, colon, or similar punctuation.
textptr: The address of a pointer to the input text which is terminated by a zero character.
On return, the pointer has been advanced past the text which has been translated, or else set
to NULL to indicate that the end of the text has been reached.
textmode: Type of character codes, one of:
espeakCHARS_UTF8 UTF8 encoding
espeakCHARS_8BIT The 8 bit ISO-8859 character set for the particular language.
espeakCHARS_AUTO 8 bit or UTF8 (this is the default)
espeakCHARS_WCHAR Wide characters (wchar_t)
espeakCHARS_16BIT 16 bit characters.
phoneme_mode
bit 1: 0=eSpeak's ascii phoneme names, 1= International Phonetic Alphabet (as UTF-8 characters).
bit 7: use (bits 8-23) as a tie within multi-letter phonemes names
bits 8-23: separator character, between phoneme names
*/
ESPEAK_API const char *espeak_TextToPhonemes(const void **textptr, int textmode, int phonememode)
{//=================================================================================================
/* phoneme_mode
bit 1: 0=eSpeak's ascii phoneme names, 1= International Phonetic Alphabet (as UTF-8 characters).
bit 7: use (bits 8-23) as a tie within multi-letter phonemes names
bits 8-23: separator character, between phoneme names
*/
option_multibyte = textmode & 7;
*textptr = TranslateClause(translator, NULL, *textptr, NULL, NULL);
return(GetTranslatedPhonemeString(phonememode));
}
My additions:
in javaSpeak.c
char *textToPhonemes(const char *text, int textmode, int phonememode) {
const void **textptr = &text;
return espeak_TextToPhonemes(textptr, textmode, phonememode);
}
and in javaSpeak.i 2x this line
extern char *textToPhonemes(const char *text, int textmode, int phonememode);
it generates the libjavaSpeak.so and calling it from Java kinda works but gives no output.
I fail with 2 tasks:
1) The pointer logic.
My goal is to pass in a String from java, and get a String returned. And C can do with pointers what it wants, but must take care of the garbage collection.
2) espeak_TextToPhonemes has a way of returning early on certain input (dots for example, as documented). This method should check if the (void input) is set to null, and if not, repeatedly call espeak_TextToPhonemes until it is, and concatenate the output string.
I could then go on and make the api nicer:
input param for the desired language by calling espeak_SetVoiceByName() as documented
charset simplification (automatic handling, utf16 for java I guess)
Note: your Linux may have an older version of eSpeak installed, and the package manager may not provide a newer one. I had to install from source, I had used the version from GitHub with nice instructions: https://github.com/rhdunn/espeak this gave me version 1.48.13. The Linux distro's 1.46.x is too old.
To be honest, I just don't have time to look at this right now. Other projects are absorbing all my time. I do hope to return to this at some point, but it may not be for a while.
This is a feature request to add the method espeak_TextToPhonemes. It has been added to the eSpeak api recently.
(I'm struggling to add it myself, no luck so far, C is not my world)
The interface is here http://sourceforge.net/p/espeak/code/HEAD/tree/trunk/src/speak_lib.h on line 505:
With the impl in http://sourceforge.net/p/espeak/code/HEAD/tree/trunk/src/speak_lib.cpp on line 1184:
My additions: in javaSpeak.c
and in javaSpeak.i 2x this line
it generates the libjavaSpeak.so and calling it from Java kinda works but gives no output.
I fail with 2 tasks:
1) The pointer logic. My goal is to pass in a String from java, and get a String returned. And C can do with pointers what it wants, but must take care of the garbage collection.
2) espeak_TextToPhonemes has a way of returning early on certain input (dots for example, as documented). This method should check if the (void input) is set to null, and if not, repeatedly call espeak_TextToPhonemes until it is, and concatenate the output string.
I could then go on and make the api nicer:
Note: your Linux may have an older version of eSpeak installed, and the package manager may not provide a newer one. I had to install from source, I had used the version from GitHub with nice instructions: https://github.com/rhdunn/espeak this gave me version 1.48.13. The Linux distro's 1.46.x is too old.
Any help or pointer ;-) much appreciated.