Browse Source

moved tunes to LoadLanguageOptions()

master
Juho Hiltunen 2 years ago
parent
commit
f28841162f
2 changed files with 37 additions and 30 deletions
  1. 35
    0
      src/libespeak-ng/langopts.c
  2. 2
    30
      src/libespeak-ng/voices.c

+ 35
- 0
src/libespeak-ng/langopts.c View File

#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>

static int LookupTune(const char *name);


#include <espeak-ng/espeak_ng.h> #include <espeak-ng/espeak_ng.h>
#include <espeak-ng/speak_lib.h> #include <espeak-ng/speak_lib.h>
#include "mnemonics.h" // for MNEM_TAB #include "mnemonics.h" // for MNEM_TAB
#include "translate.h" // for Translator #include "translate.h" // for Translator
#include "voice.h" // for CheckTranslator() #include "voice.h" // for CheckTranslator()
#include "synthdata.h" // for n_tunes, tunes


enum { enum {
V_NAME = 1, V_NAME = 1,


void LoadLanguageOptions(Translator *translator, int key, char *keyValue ) { void LoadLanguageOptions(Translator *translator, int key, char *keyValue ) {
int ix; int ix;
int n;


switch (key) { switch (key) {
case V_INTONATION: { case V_INTONATION: {


break; break;
} }
case V_TUNES: {
if (CheckTranslator(translator, langopts_tab, key) != 0)
break;

char names[8][40];
n = sscanf(keyValue, "%s %s %s %s %s %s", names[0], names[1], names[2], names[3], names[4], names[5]);
translator->langopts.intonation_group = 0;

for (ix = 0; ix < n; ix++) {
if (strcmp(names[ix], "NULL") == 0)
continue;

if ((n = LookupTune(names[ix])) < 0)
fprintf(stderr, "Unknown tune '%s'\n", names[ix]);
else
translator->langopts.tunes[ix] = n;
}
break;
}



case V_MAINTAINER: case V_MAINTAINER:
case V_STATUS: case V_STATUS:
break; break;
} }
} }

static int LookupTune(const char *name) {
int ix;

for (ix = 0; ix < n_tunes; ix++) {
if (strcmp(name, tunes[ix].name) == 0)
return ix;
}
return -1;
}

+ 2
- 30
src/libespeak-ng/voices.c View File

{ "stressLength", V_STRESSLENGTH }, { "stressLength", V_STRESSLENGTH },
{ "stressOpt", V_STRESSOPT }, { "stressOpt", V_STRESSOPT },
{ "stressRule", V_STRESSRULE }, { "stressRule", V_STRESSRULE },
{ "tunes", V_TUNES },


{ "maintainer", V_MAINTAINER }, { "maintainer", V_MAINTAINER },
{ "status", V_STATUS }, { "status", V_STATUS },
{ "pitch", V_PITCH }, { "pitch", V_PITCH },
{ "phonemes", V_PHONEMES }, { "phonemes", V_PHONEMES },
{ "dictionary", V_DICTIONARY }, { "dictionary", V_DICTIONARY },
{ "tunes", V_TUNES },
{ "dictrules", V_DICTRULES }, { "dictrules", V_DICTRULES },
{ "replace", V_REPLACE }, { "replace", V_REPLACE },
{ "words", V_WORDGAP }, { "words", V_WORDGAP },
return buf; return buf;
} }


static int LookupTune(const char *name)
{
int ix;

for (ix = 0; ix < n_tunes; ix++) {
if (strcmp(name, tunes[ix].name) == 0)
return ix;
}
return -1;
}

static void SetToneAdjust(voice_t *voice, int *tone_pts) static void SetToneAdjust(voice_t *voice, int *tone_pts)
{ {
int ix; int ix;
char buf[sizeof(path_home)+30]; char buf[sizeof(path_home)+30];
char path_voices[sizeof(path_home)+12]; char path_voices[sizeof(path_home)+12];


char names[8][40];
char name1[40]; char name1[40];
char name2[80]; char name2[80];


break; break;




case V_TUNES:
if (CheckTranslator(translator, keyword_tab, key) != 0)
break;

n = sscanf(p, "%s %s %s %s %s %s", names[0], names[1], names[2], names[3], names[4], names[5]);
translator->langopts.intonation_group = 0;

for (ix = 0; ix < n; ix++) {
if (strcmp(names[ix], "NULL") == 0)
continue;

if ((value = LookupTune(names[ix])) < 0)
fprintf(stderr, "Unknown tune '%s'\n", names[ix]);
else
translator->langopts.tunes[ix] = value;
}
break;


case V_DICTRULES: // conditional dictionary rules and list entries case V_DICTRULES: // conditional dictionary rules and list entries
if (CheckTranslator(translator, keyword_tab, key) != 0) if (CheckTranslator(translator, keyword_tab, key) != 0)

Loading…
Cancel
Save