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

@@ -24,6 +24,9 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int LookupTune(const char *name);

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

enum {
V_NAME = 1,
@@ -85,6 +89,7 @@ extern const MNEM_TAB langopts_tab[];

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

switch (key) {
case V_INTONATION: {
@@ -165,9 +170,39 @@ void LoadLanguageOptions(Translator *translator, int key, char *keyValue ) {

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_STATUS:
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

@@ -128,6 +128,7 @@ const MNEM_TAB langopts_tab[] = {
{ "stressLength", V_STRESSLENGTH },
{ "stressOpt", V_STRESSOPT },
{ "stressRule", V_STRESSRULE },
{ "tunes", V_TUNES },

{ "maintainer", V_MAINTAINER },
{ "status", V_STATUS },
@@ -145,7 +146,6 @@ static const MNEM_TAB keyword_tab[] = {
{ "pitch", V_PITCH },
{ "phonemes", V_PHONEMES },
{ "dictionary", V_DICTIONARY },
{ "tunes", V_TUNES },
{ "dictrules", V_DICTRULES },
{ "replace", V_REPLACE },
{ "words", V_WORDGAP },
@@ -211,17 +211,6 @@ static char *fgets_strip(char *buf, int size, FILE *f_in)
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)
{
int ix;
@@ -551,7 +540,7 @@ voice_t *LoadVoice(const char *vname, int control)
char buf[sizeof(path_home)+30];
char path_voices[sizeof(path_home)+12];

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

@@ -715,23 +704,6 @@ voice_t *LoadVoice(const char *vname, int control)
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
if (CheckTranslator(translator, keyword_tab, key) != 0)

Loading…
Cancel
Save