Skip to content

Commit

Permalink
Use LookupMnem in ReadVoiceFile when parsing lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhdunn committed Feb 5, 2017
1 parent d30cf6f commit 1c5bbe3
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/libespeak-ng/voices.c
Expand Up @@ -69,6 +69,7 @@ enum {
V_TRANSLATOR,
V_PHONEMES,
V_DICTIONARY,
V_VARIANTS,

V_MAINTAINER,
V_STATUS,
Expand Down Expand Up @@ -125,6 +126,7 @@ static MNEM_TAB keyword_tab[] = {
{ "maintainer", V_MAINTAINER },
{ "status", V_STATUS },

{ "variants", V_VARIANTS },
{ "formant", V_FORMANT },
{ "pitch", V_PITCH },
{ "phonemes", V_PHONEMES },
Expand Down Expand Up @@ -289,15 +291,23 @@ static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname)
age = 0;

while (fgets_strip(linebuf, sizeof(linebuf), f_in) != NULL) {
if (memcmp(linebuf, "name", 4) == 0) {
p = &linebuf[4];
// isolate the attribute name
for (p = linebuf; (*p != 0) && !isspace(*p); p++) ;
*p++ = 0;

if (linebuf[0] == 0) continue;

switch (LookupMnem(keyword_tab, linebuf))
{
case V_NAME:
while (isspace(*p)) p++;
strncpy0(vname, p, sizeof(vname));
} else if (memcmp(linebuf, "language", 8) == 0) {
break;
case V_LANGUAGE:
priority = DEFAULT_LANGUAGE_PRIORITY;
vlanguage[0] = 0;

sscanf(&linebuf[8], "%s %d", vlanguage, &priority);
sscanf(p, "%s %d", vlanguage, &priority);
len = strlen(vlanguage) + 2;
// check for space in languages[]
if (len < (sizeof(languages)-langix-1)) {
Expand All @@ -307,10 +317,13 @@ static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname)
langix += len;
n_languages++;
}
} else if (memcmp(linebuf, "gender", 6) == 0)
sscanf(&linebuf[6], "%s %d", vgender, &age);
else if (memcmp(linebuf, "variants", 8) == 0)
sscanf(&linebuf[8], "%d", &n_variants);
break;
case V_GENDER:
sscanf(p, "%s %d", vgender, &age);
break;
case V_VARIANTS:
sscanf(p, "%d", &n_variants);
}
}
languages[langix++] = 0;

Expand Down

0 comments on commit 1c5bbe3

Please sign in to comment.