Skip to content

Commit 9b5f4cd

Browse files
author
Tristan Hamilton
committed
added methods to improve SynthesisConfig class and to retrieve Synthesis configs in MaryConfig. NOTE: MaryConfig.checkConsistency() is never used.
1 parent 7230f50 commit 9b5f4cd

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

marytts-runtime/src/main/java/marytts/config/MaryConfig.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ public static void checkConsistency() throws MaryConfigurationException {
7171
+ "', but there is no corresponding language config.");
7272
}
7373
}
74+
// Check that for each synthesis config, we have a matching synthesis class
75+
if (getSynthesisConfigs() == null){
76+
throw new MaryConfigurationException("No synthesizer config");
77+
}
78+
for (SynthesisConfig sc : getSynthesisConfigs()) {
79+
if (MaryProperties.synthesizerClasses().contains(sc.getSynthesisName())) {
80+
throw new MaryConfigurationException("Synthesizer '" + sc.getSynthesisName() + "' is not in config properties.");
81+
}
82+
}
7483
}
7584

7685
public static int countConfigs() {
@@ -145,6 +154,17 @@ public static LanguageConfig getLanguageConfig(Locale locale) {
145154
return null;
146155
}
147156

157+
public static Iterable<SynthesisConfig> getSynthesisConfigs() {
158+
Set<SynthesisConfig> scs = new HashSet<SynthesisConfig>();
159+
for (MaryConfig mc : configLoader) {
160+
if (mc.isSynthesisConfig()) {
161+
SynthesisConfig sc = (SynthesisConfig) mc;
162+
scs.add(sc);
163+
}
164+
}
165+
return scs;
166+
}
167+
148168
/**
149169
* Get the voice config for the given voice name, or null if there is no such voice config.
150170
*

marytts-runtime/src/main/java/marytts/config/SynthesisConfig.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,22 @@ public class SynthesisConfig extends MaryConfig {
3333

3434
public SynthesisConfig(InputStream propertyStream) throws MaryConfigurationException {
3535
super(propertyStream);
36+
if (getSynthesisName() == null) {
37+
throw new MaryConfigurationException("No synthesizer class defined in config file");
38+
}
3639
}
3740

3841
@Override
3942
public boolean isSynthesisConfig() {
4043
return true;
4144
}
45+
46+
/**
47+
* The synthesizer's name.
48+
*
49+
* @return
50+
*/
51+
public String getSynthesisName() {
52+
return getProperties().getProperty("synthesizers.classes.list");
53+
}
4254
}

0 commit comments

Comments
 (0)