[1.47.08]

Add API function: espeak_TextToPhonemes().


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@349 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2013-04-26 22:33:46 +00:00
parent 2fbfd42fc6
commit 4a670d0f57
18 changed files with 139 additions and 91 deletions
+1
View File
@@ -133,6 +133,7 @@ MNEM_TAB mnem_flags[] = {
{"$stem", 0x30}, // must have a suffix
{"$atend", 0x31}, // use this pronunciation if at end of clause
{"$atstart", 0x32}, // use this pronunciation at start of clause
{"$native", 0x33}, // not if we've switched translators
// doesn't set dictionary_flags
{"$?", 100}, // conditional rule, followed by byte giving the condition number
+5
View File
@@ -3275,6 +3275,11 @@ static const char *LookupDict2(Translator *tr, const char *word, const char *wor
continue;
}
}
if(dictionary_flags2 & FLAG_NATIVE)
{
if(tr != translator)
continue; // don't use if we've switched translators
}
if(dictionary_flags & FLAG_ALT2_TRANS)
{
// language specific
+7
View File
@@ -199,6 +199,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(MENU_OPT_SPEED, MyFrame::OnOptions)
EVT_MENU(MENU_OPT_PUNCT, MyFrame::OnOptions)
EVT_MENU(MENU_OPT_SPELL, MyFrame::OnOptions)
EVT_MENU(MENU_OPT_SPELL2, MyFrame::OnOptions)
EVT_MENU(MENU_PATH0, MyFrame::OnOptions)
EVT_MENU(MENU_PATH1, MyFrame::OnOptions)
EVT_MENU(MENU_PATH2, MyFrame::OnOptions)
@@ -625,6 +626,12 @@ void OnOptions2(int event_id)
break;
case MENU_OPT_SPELL:
transldlg->t_source->SetValue(_T("<say-as interpret-as=\"characters\">\n"));
transldlg->t_source->SetInsertionPointEnd();
notebook->SetSelection(1);
break;
case MENU_OPT_SPELL2:
transldlg->t_source->SetValue(_T("<say-as interpret-as=\"tts:char\">\n"));
transldlg->t_source->SetInsertionPointEnd();
notebook->SetSelection(1);
+1
View File
@@ -127,6 +127,7 @@ enum {
MENU_OPT_SPEED,
MENU_OPT_PUNCT,
MENU_OPT_SPELL,
MENU_OPT_SPELL2,
MENU_PATHS,
MENU_PATH0,
MENU_PATH1,
+3 -1
View File
@@ -119,8 +119,10 @@ wxMenuBar *MakeMenu(int type, const char *dict_name)
option_menu = new wxMenu;
option_menu->Append(MENU_PATHS, _("Set &paths"), paths_menu);
option_menu->Append(MENU_OPT_SPEED, _("Speed..."));
option_menu->AppendSeparator();
option_menu->Append(MENU_OPT_PUNCT, _("Speak punctuation"));
option_menu->Append(MENU_OPT_SPELL, _("Speak character names"));
option_menu->Append(MENU_OPT_SPELL, _("Speak characters"));
option_menu->Append(MENU_OPT_SPELL2, _("Speak character name"));
// TOOLS
vowelchart_menu = new wxMenu;
+24 -20
View File
@@ -727,37 +727,41 @@ int TranslateLetter(Translator *tr, char *word, char *phonemes, int control)
}
}
letter = towlower2(letter);
LookupLetter(tr, letter, word[n_bytes], ph_buf, control & 1);
// is this a subscript or superscript letter ?
for(ix=0; (c = derived_letters[ix]) != 0; ix+=2)
if(ph_buf[0] == 0)
{
if(c > letter)
break;
if(c == letter)
// is this a subscript or superscript letter ?
for(ix=0; (c = derived_letters[ix]) != 0; ix+=2)
{
c = derived_letters[ix+1];
letter = c & 0x3fff;
if((modifier = modifiers[c >> 14]) != NULL)
if(c > letter)
break;
if(c == letter)
{
Lookup(tr, modifier, capital);
if(capital[0] == 0)
c = derived_letters[ix+1];
letter = c & 0x3fff;
if((modifier = modifiers[c >> 14]) != NULL)
{
capital[2] = SetTranslator2("en"); // overwrites previous contents of translator2
Lookup(translator2, modifier, &capital[3]);
if(capital[3] != 0)
Lookup(tr, modifier, capital);
if(capital[0] == 0)
{
capital[0] = phonPAUSE;
capital[1] = phonSWITCH;
len = strlen(&capital[3]);
capital[len+3] = phonSWITCH;
capital[len+4] = phontab_1;
capital[len+5] = 0;
capital[2] = SetTranslator2("en"); // overwrites previous contents of translator2
Lookup(translator2, modifier, &capital[3]);
if(capital[3] != 0)
{
capital[0] = phonPAUSE;
capital[1] = phonSWITCH;
len = strlen(&capital[3]);
capital[len+3] = phonSWITCH;
capital[len+4] = phontab_1;
capital[len+5] = 0;
}
}
}
}
}
LookupLetter(tr, letter, word[n_bytes], ph_buf, control & 1);
}
LookupLetter(tr, letter, word[n_bytes], ph_buf, control & 1);
if(ph_buf[0] == phonSWITCH)
{
+3 -3
View File
@@ -503,13 +503,13 @@ int towupper2(unsigned int c)
return(towupper(c));
// check whether a previous character code is the upper-case equivalent of this character
if(towlower2(c-32) == c)
if(towlower2(c-32) == (int)c)
return(c-32); // yes, use it
if(towlower2(c-1) == c)
if(towlower2(c-1) == (int)c)
return(c-1);
for(ix=0; wchar_toupper[ix] != 0; ix+=2)
{
if(wchar_toupper[ix] == c)
if(wchar_toupper[ix] == (int)c)
return(wchar_toupper[ix+1]);
}
return(c); // no
+1 -1
View File
@@ -1167,7 +1167,7 @@ ESPEAK_API void espeak_SetPhonemeTrace(int value, FILE *stream)
ESPEAK_API void espeak_TextToPhonemes(const void *text, char *buffer, int size, int textmode, int phonememode)
{//==============================================================================================================
/* phoneme_mode bits 0-3: 0=only phoneme names, 1=ties, 2=ZWJ, 3=underscore separator
bit 4: 0=eSpeak phoneme names, 1=IPA
bits 4-7: 0=eSpeak phoneme names, 1=IPA
*/
option_multibyte = textmode & 7;
TranslateClause(translator, NULL, text, NULL, NULL);
+62 -29
View File
@@ -55,6 +55,9 @@ Revision 7 24.Dec.2011
Changed espeak_EVENT structure to add id.string[] for phoneme mnemonics.
Added espeakINITIALIZE_PHONEME_IPA option for espeak_Initialize() to report phonemes as IPA names.
Revision 8 26.Apr.2013
Added function espeak_TextToPhonemes().
*/
/********************/
/* Initialization */
@@ -94,7 +97,7 @@ typedef struct {
char string[8]; // used for phoneme names (UTF8). Terminated by a zero byte unless the name needs the full 8 bytes.
} id;
} espeak_EVENT;
/*
/*
When a message is supplied to espeak_synth, the request is buffered and espeak_synth returns. When the message is really processed, the callback function will be repetedly called.
@@ -102,16 +105,16 @@ typedef struct {
In PLAYBACK mode, the callback function is called as soon as an event happens.
For example suppose that the following message is supplied to espeak_Synth:
For example suppose that the following message is supplied to espeak_Synth:
"hello, hello."
* Once processed in RETRIEVAL mode, it could lead to 3 calls of the callback function :
** Block 1:
<audio data> +
<audio data> +
List of events: SENTENCE + WORD + LIST_TERMINATED
** Block 2:
<audio data> +
List of events: WORD + END + LIST_TERMINATED
@@ -148,11 +151,11 @@ typedef enum {
typedef enum {
/* PLAYBACK mode: plays the audio data, supplies events to the calling program*/
AUDIO_OUTPUT_PLAYBACK,
AUDIO_OUTPUT_PLAYBACK,
/* RETRIEVAL mode: supplies audio data and events to the calling program */
AUDIO_OUTPUT_RETRIEVAL,
/* SYNCHRONOUS mode: as RETRIEVAL but doesn't return until synthesis is completed */
AUDIO_OUTPUT_SYNCHRONOUS,
@@ -199,7 +202,7 @@ extern "C"
ESPEAK_API void espeak_SetSynthCallback(t_espeak_callback* SynthCallback);
/* Must be called before any synthesis functions are called.
This specifies a function in the calling program which is called when a buffer of
speech sound data has been produced.
speech sound data has been produced.
The callback function is of the form:
@@ -288,7 +291,7 @@ ESPEAK_API espeak_ERROR espeak_Synth(const void *text,
start of the text.
position_type: Determines whether "position" is a number of characters, words, or sentences.
Values:
Values:
end_position: If set, this gives a character position at which speaking will stop. A value
of zero indicates no end position.
@@ -299,6 +302,7 @@ ESPEAK_API espeak_ERROR espeak_Synth(const void *text,
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.
espeakSSML Elements within < > are treated as SSML elements, or if not recognised are ignored.
@@ -307,13 +311,13 @@ ESPEAK_API espeak_ERROR espeak_Synth(const void *text,
espeakENDPAUSE If set then a sentence pause is added at the end of the text. If not set then
this pause is suppressed.
unique_identifier: message identifier; helpful for identifying later
unique_identifier: message identifier; helpful for identifying later
data supplied to the callback.
user_data: pointer which will be passed to the callback function.
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -336,8 +340,8 @@ ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text,
For the other parameters, see espeak_Synth()
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -350,8 +354,8 @@ ESPEAK_API espeak_ERROR espeak_Key(const char *key_name);
If key_name is a single character, it speaks the name of the character.
Otherwise, it speaks key_name as a text string.
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -360,10 +364,10 @@ ESPEAK_API espeak_ERROR espeak_Key(const char *key_name);
extern "C"
#endif
ESPEAK_API espeak_ERROR espeak_Char(wchar_t character);
/* Speak the name of the given character
/* Speak the name of the given character
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -420,7 +424,7 @@ ESPEAK_API espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int valu
espeakRANGE: pitch range, range 0-100. 0-monotone, 50=normal
espeakPUNCTUATION: which punctuation characters to announce:
value in espeak_PUNCT_TYPE (none, all, some),
value in espeak_PUNCT_TYPE (none, all, some),
see espeak_GetParameter() to specify which characters are announced.
espeakCAPITALS: announce capital letters by:
@@ -432,8 +436,8 @@ ESPEAK_API espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int valu
espeakWORDGAP: pause between words, units of 10mS (at the default speed)
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -455,8 +459,8 @@ ESPEAK_API espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist);
punctlist: A list of character codes, terminated by a zero character.
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -474,6 +478,35 @@ ESPEAK_API void espeak_SetPhonemeTrace(int value, FILE *stream);
stream output stream for the phoneme symbols (and trace). If stream=NULL then it uses stdout.
*/
#ifdef __cplusplus
extern "C"
#endif
ESPEAK_API void espeak_TextToPhonemes(const void *text, char *buffer, int size, int textmode, int phonememode);
/* Translates text into phonemes. Call espeak_SetVoiceByName() first, to select a language.
text: The text to translate, terminated by a zero character.
buffer: Output buffer for the phoneme translation.
size: Size of the output buffer in bytes.
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.
phonememode: bits0-3:
0= just phonemes.
1= include ties (U+361) for phoneme names of more than one letter.
2= include zero-width-joiner for phoneme names of more than one letter.
3= separate phonemes with underscore characters.
bits 4-7:
0= eSpeak's ascii phoneme names.
1= International Phonetic Alphabet (as UTF-8 characters).
*/
#ifdef __cplusplus
extern "C"
#endif
@@ -501,7 +534,7 @@ typedef struct {
unsigned char gender; // 0=none 1=male, 2=female,
unsigned char age; // 0=not specified, or age in years
unsigned char variant; // only used when passed as a parameter to espeak_SetVoiceByProperties
unsigned char xx1; // for internal use
unsigned char xx1; // for internal use
int score; // for internal use
void *spare; // for internal use
} espeak_VOICE;
@@ -546,8 +579,8 @@ ESPEAK_API espeak_ERROR espeak_SetVoiceByName(const char *name);
/* Searches for a voice with a matching "name" field. Language is not considered.
"name" is a UTF8 string.
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
Return: EE_OK: operation achieved
EE_BUFFER_FULL: the command can not be buffered;
you may try after a while to call the function again.
EE_INTERNAL_ERROR.
*/
@@ -588,7 +621,7 @@ ESPEAK_API espeak_ERROR espeak_Cancel(void);
function returns, the audio output is fully stopped and the synthesizer is ready to
synthesize a new message.
Return: EE_OK: operation achieved
Return: EE_OK: operation achieved
EE_INTERNAL_ERROR.
*/
@@ -605,7 +638,7 @@ extern "C"
#endif
ESPEAK_API espeak_ERROR espeak_Synchronize(void);
/* This function returns when all data have been spoken.
Return: EE_OK: operation achieved
Return: EE_OK: operation achieved
EE_INTERNAL_ERROR.
*/
@@ -614,7 +647,7 @@ extern "C"
#endif
ESPEAK_API espeak_ERROR espeak_Terminate(void);
/* last function to be called.
Return: EE_OK: operation achieved
Return: EE_OK: operation achieved
EE_INTERNAL_ERROR.
*/
+1 -1
View File
@@ -35,7 +35,7 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.47.07b 25.Apr.13";
const char *version_string = "1.47.08 26.Apr.13";
const int version_phdata = 0x014701;
int option_device_number = -1;
+2 -1
View File
@@ -81,8 +81,9 @@
#define FLAG_ONLY 0x4000
#define FLAG_ONLY_S 0x8000
#define FLAG_STEM 0x10000 // must have a suffix
#define FLAG_ATEND 0x20000 /* use this pronunciation if at end of clause */
#define FLAG_ATEND 0x20000 // use this pronunciation if at end of clause
#define FLAG_ATSTART 0x40000 // use this pronunciation if at start of clause
#define FLAG_NATIVE 0x80000 // not if we've switched translators
#define FLAG_LOOKUP_SYMBOL 0x40000000 // to indicate called from Lookup()
#define BITNUM_FLAG_ALLCAPS 0x2a