Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unitselection #3

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2cf0149
'cherry picked' files from Ali's InfoRequestHandler-Code-Refactored b…
Feb 2, 2015
cd000f3
created new empty marytts-unitselection maven module. updated master …
Feb 2, 2015
69fd3ef
remove vocalizations package from runtime and remove specific vocalis…
Feb 2, 2015
267c126
clean runtime of all references to vocalizations
Feb 2, 2015
3d1093d
remove unit-selection package from runtime -> Compile Errors
Feb 5, 2015
a2a9b5a
moved unitselection into new maven module marytts-unitselection.
Feb 5, 2015
bc75cdb
remove trove4j dependancy from marytts-runtime pom, add to marytts-un…
Feb 5, 2015
76d492a
clean up references to Target and its subclasses
Feb 5, 2015
cbfa832
getPhoneSymbol(element) method from UnitSelector copied to MaryDomUtils
Feb 5, 2015
5297f5b
UnitSelector.getPhoneSymbol() replaced by MaryDomUtils.getPhoneSymbol()
Feb 5, 2015
6e40153
FeatureFileReader references updated
Feb 5, 2015
9369030
remove vocalization packages from marytts-builder
Feb 5, 2015
108f6a4
more updated references to Target
Feb 5, 2015
5cef770
interpolation packages sent to purgatory
Feb 5, 2015
8d8803c
clean code of interpolation references
Feb 5, 2015
b4761f2
more cleaning of references to Target
Feb 5, 2015
a57ae79
remove deprecated getLexicon(voice) method from FreeTTSVoices
Feb 5, 2015
4c8d012
BaseHttpRequestHandler had lots of unused imports - cleaned
Feb 6, 2015
8499c63
removed duplicate features package from marytts-unitselection module
Feb 6, 2015
8841eff
remove duplicate cart packages from unitselection module
Feb 6, 2015
a71db75
clean reference to FeatureFileReader
Feb 6, 2015
d3f6a35
CARTF0Modeller sent to purgatory
Feb 6, 2015
da9b24b
moved domain and example text from unitselectionvoice to voice
Feb 6, 2015
c0a8092
previous commit added isUnitSelection to Voice, this allows for UnitS…
Feb 6, 2015
6527c83
send Vocalizations to purgatory
Feb 9, 2015
e06d525
vocalisation builder packages sent to purgatory
Feb 9, 2015
a686bb9
add unitselection config to unitselectionmodule, remove from synthesi…
Feb 9, 2015
04298b0
'cherry picked' more files from ali's InfoRequestHandler-Code-Refacto…
Feb 11, 2015
99a8b1d
needed to change unitselection.config file location so it could be read
Feb 11, 2015
7230f50
created UnitSelectionIT class, required Hamcrest for testing -> updat…
Mar 10, 2015
9b5f4cd
added methods to improve SynthesisConfig class and to retrieve Synthe…
Mar 10, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions marytts-builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,22 @@
<artifactId>marytts-signalproc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>marytts-unitselection</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-integration</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -87,12 +98,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>swing-layout</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import marytts.modules.TargetFeatureLister;
import marytts.server.Mary;
import marytts.server.Request;
import marytts.unitselection.select.Target;
import marytts.features.Target;
import marytts.util.MaryUtils;
import marytts.util.dom.MaryDomUtils;

Expand Down
6 changes: 5 additions & 1 deletion marytts-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>


<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.incava</groupId>
<artifactId>java-diff</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public Vector<MaryClient.DataType> getOutputDataTypes() throws IOException {
* if the host could not be found
*/
public Vector<MaryClient.Voice> getVoices() throws IOException {
if (data.allVoices == null)
if (data.allVoices == null || data.allVoices.isEmpty())
fillVoices();

assert data.allVoices != null && data.allVoices.size() > 0;
Expand Down
135 changes: 89 additions & 46 deletions marytts-client/src/main/java/marytts/client/MaryFormData.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,20 @@
import java.util.StringTokenizer;
import java.util.Vector;

import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioFileFormat.Type;
import javax.sound.sampled.AudioSystem;

import marytts.util.MaryUtils;
import marytts.util.data.audio.MaryAudioUtils;
import marytts.util.http.Address;
import marytts.util.math.MathUtils;
import marytts.util.string.StringUtils;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

/**
*
* This class nests all the information and functions that a Mary client needs to receive/send data from/to server. To be able to
Expand Down Expand Up @@ -83,9 +88,11 @@ public class MaryFormData {
public AudioEffectsBoxData effectsBoxData;
public Vector<String> limitedDomainExampleTexts;

public Map<String, String> keyValuePairs; // Key-Value pairs for communication with server
public Map<String, String> keyValuePairs; // Key-Value pairs for
// communication with server

public String outputAudioResponseID; // output audio file for web browser client
public String outputAudioResponseID; // output audio file for web browser
// client
public String mimeType; // MIME type for output audio (web browser clients)

public MaryFormData() {
Expand Down Expand Up @@ -194,56 +201,40 @@ public void toVoices(String info) {
allVoices = null;
voicesByLocaleMap = null;
limitedDomainVoices = null;

if (info != null && info.length() > 0) {
JsonArray voiceArray = null;
try {
JsonParser parser = new JsonParser();
JsonElement jsonElement = parser.parse(info);
voiceArray = jsonElement.getAsJsonArray();
} catch (Exception e) {
e.printStackTrace();
}
// if (info!=null && info.length()>0)
if (voiceArray != null && voiceArray.size() > 0) {
allVoices = new Vector<MaryClient.Voice>();
voicesByLocaleMap = new HashMap<Locale, Vector<MaryClient.Voice>>();
limitedDomainVoices = new HashMap<String, Vector<String>>();
String[] voiceStrings = info.split("\n");

for (int i = 0; i < voiceStrings.length; i++) {
StringTokenizer st = new StringTokenizer(voiceStrings[i]);
if (!st.hasMoreTokens())
continue; // ignore entry
String name = st.nextToken();
if (!st.hasMoreTokens())
continue; // ignore entry
String localeString = st.nextToken();
// String[] voiceStrings = info.split("\n");
for (int i = 0; i < voiceArray.size(); i++) {
JsonObject currentVoice = (JsonObject) voiceArray.get(i);
String name = currentVoice.has("name") ? currentVoice.get("name").toString().replace("\"", "") : "";
String localeString = currentVoice.has("locale") ? currentVoice.get("locale").toString().replace("\"", "") : "";
Locale locale = string2locale(localeString);
// locale = string2locale("en-US");
assert locale != null;
if (!st.hasMoreTokens())
continue; // ignore entry
String gender = st.nextToken();

String gender = currentVoice.has("gender") ? currentVoice.get("gender").toString().replace("\"", "") : "";
MaryClient.Voice voice = null;
if (!currentVoice.has("domain")) {
voice = new MaryClient.Voice(name, locale, gender, "general");
} else {
String domain = currentVoice.get("domain").toString().replace("\"", "");
voice = new MaryClient.Voice(name, locale, gender, domain);
}
if (isServerVersionAtLeast("3.5.0")) {
String synthesizerType;
if (!st.hasMoreTokens())
synthesizerType = "non-specified";
else
synthesizerType = st.nextToken();

if (!st.hasMoreTokens()) {
// assume domain is general
voice = new MaryClient.Voice(name, locale, gender, "general");
} else {
// read in the domain
String domain = st.nextToken();
voice = new MaryClient.Voice(name, locale, gender, domain);
}

String synthesizerType = currentVoice.has("type") ? currentVoice.get("type").toString().replace("\"", "")
: "non-specified";
voice.setSynthesizerType(synthesizerType);
} else {
if (!st.hasMoreTokens()) {
// assume domain is general
voice = new MaryClient.Voice(name, locale, gender, "general");
} else {
// read in the domain
String domain = st.nextToken();
voice = new MaryClient.Voice(name, locale, gender, domain);
}
}

allVoices.add(voice);
Vector<MaryClient.Voice> localeVoices = null;
if (voicesByLocaleMap.containsKey(locale)) {
Expand All @@ -254,6 +245,56 @@ public void toVoices(String info) {
}
localeVoices.add(voice);
}
// for (int i=0; i<voiceStrings.length; i++) {
// StringTokenizer st = new StringTokenizer(voiceStrings[i]);
// if (!st.hasMoreTokens()) continue; // ignore entry
// String name = st.nextToken();
// if (!st.hasMoreTokens()) continue; // ignore entry
// String localeString = st.nextToken();
// Locale locale = string2locale(localeString);
// assert locale != null;
// if (!st.hasMoreTokens()) continue; // ignore entry
// String gender = st.nextToken();
//
// MaryClient.Voice voice = null;
// if (isServerVersionAtLeast("3.5.0")) {
// String synthesizerType;
// if (!st.hasMoreTokens())
// synthesizerType = "non-specified";
// else
// synthesizerType = st.nextToken();
//
// if (!st.hasMoreTokens()) {
// //assume domain is general
// voice = new MaryClient.Voice(name, locale, gender, "general");
// } else {
// //read in the domain
// String domain = st.nextToken();
// voice = new MaryClient.Voice(name, locale, gender, domain);
// }
//
// voice.setSynthesizerType(synthesizerType);
// } else {
// if (!st.hasMoreTokens()) {
// //assume domain is general
// voice = new MaryClient.Voice(name, locale, gender, "general");
// } else {
// //read in the domain
// String domain = st.nextToken();
// voice = new MaryClient.Voice(name, locale, gender, domain);
// }
// }
//
// allVoices.add(voice);
// Vector<MaryClient.Voice> localeVoices = null;
// if (voicesByLocaleMap.containsKey(locale)) {
// localeVoices = voicesByLocaleMap.get(locale);
// } else {
// localeVoices = new Vector<MaryClient.Voice>();
// voicesByLocaleMap.put(locale, localeVoices);
// }
// localeVoices.add(voice);
// }
}
}

Expand Down Expand Up @@ -517,7 +558,8 @@ else if (serverExampleTexts != null)

// Check box
selected = keyValuePairs.get("effect_" + currentEffectName + "_selected");
if (selected != null && selected.compareTo("on") == 0) // Effect is selected
if (selected != null && selected.compareTo("on") == 0) // Effect is
// selected
effectsBoxData.getControlData(i).setSelected(true);
else
// If not found, effect is not selected
Expand All @@ -544,7 +586,8 @@ public boolean isServerVersionAtLeast(String serverVersionToCompare) {
return tmp >= 0;
}

// Check if all selections are appropriately made, i.e. no array bounds exceeded etc
// Check if all selections are appropriately made, i.e. no array bounds
// exceeded etc
public void checkAndCorrectSelections() {
audioFormatSelected = MathUtils.CheckLimits(audioFormatSelected, 0, audioFileFormatTypes.size() - 1);
audioOutSelected = MathUtils.CheckLimits(audioOutSelected, 0, audioOutTypes.size() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import marytts.features.FeatureProcessorManager;
import marytts.features.FeatureRegistry;
import marytts.server.Mary;
import marytts.unitselection.select.Target;
import marytts.features.Target;
import marytts.util.dom.MaryDomUtils;

import org.junit.BeforeClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@
import marytts.datatypes.MaryDataType;
import marytts.datatypes.MaryXML;
import marytts.features.MaryGenericFeatureProcessors.TargetElementNavigator;
import marytts.server.MaryProperties;
import marytts.unitselection.select.HalfPhoneTarget;
import marytts.unitselection.select.Target;
import marytts.features.HalfPhoneTarget;
import marytts.features.Target;
import marytts.util.dom.MaryDomUtils;

import org.apache.log4j.BasicConfigurator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import marytts.modules.synthesis.Voice;
import marytts.server.MaryProperties;
import marytts.unitselection.UnitSelectionVoice;
import marytts.unitselection.select.Target;
import marytts.features.Target;
import marytts.util.MaryRuntimeUtils;
import marytts.util.MaryUtils;
import marytts.util.dom.MaryDomUtils;
Expand Down
9 changes: 4 additions & 5 deletions marytts-runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>

<dependency>
<groupId>net.sf.trove4j</groupId>
<artifactId>trove4j</artifactId>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion marytts-runtime/src/main/java/marytts/cart/CART.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

import marytts.features.FeatureDefinition;
import marytts.features.FeatureVector;
import marytts.unitselection.select.Target;
import marytts.features.Target;

/**
* A tree is a specific kind of directed graph in which each node can have only a single parent node. It consists exclusively of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import marytts.features.FeatureDefinition;
import marytts.features.FeatureVector;
import marytts.unitselection.select.Target;
import marytts.features.Target;
import marytts.util.MaryUtils;

import org.apache.log4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import marytts.cart.io.WagonCARTReader;
import marytts.features.FeatureDefinition;
import marytts.features.FeatureVector;
import marytts.unitselection.select.Target;
import marytts.features.Target;

//import com.sun.tools.javac.code.Attribute.Array;

Expand Down
20 changes: 20 additions & 0 deletions marytts-runtime/src/main/java/marytts/config/MaryConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ public static void checkConsistency() throws MaryConfigurationException {
+ "', but there is no corresponding language config.");
}
}
// Check that for each synthesis config, we have a matching synthesis class
if (getSynthesisConfigs() == null){
throw new MaryConfigurationException("No synthesizer config");
}
for (SynthesisConfig sc : getSynthesisConfigs()) {
if (MaryProperties.synthesizerClasses().contains(sc.getSynthesisName())) {
throw new MaryConfigurationException("Synthesizer '" + sc.getSynthesisName() + "' is not in config properties.");
}
}
}

public static int countConfigs() {
Expand Down Expand Up @@ -145,6 +154,17 @@ public static LanguageConfig getLanguageConfig(Locale locale) {
return null;
}

public static Iterable<SynthesisConfig> getSynthesisConfigs() {
Set<SynthesisConfig> scs = new HashSet<SynthesisConfig>();
for (MaryConfig mc : configLoader) {
if (mc.isSynthesisConfig()) {
SynthesisConfig sc = (SynthesisConfig) mc;
scs.add(sc);
}
}
return scs;
}

/**
* Get the voice config for the given voice name, or null if there is no such voice config.
*
Expand Down
12 changes: 12 additions & 0 deletions marytts-runtime/src/main/java/marytts/config/SynthesisConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,22 @@ public class SynthesisConfig extends MaryConfig {

public SynthesisConfig(InputStream propertyStream) throws MaryConfigurationException {
super(propertyStream);
if (getSynthesisName() == null) {
throw new MaryConfigurationException("No synthesizer class defined in config file");
}
}

@Override
public boolean isSynthesisConfig() {
return true;
}

/**
* The synthesizer's name.
*
* @return
*/
public String getSynthesisName() {
return getProperties().getProperty("synthesizers.classes.list");
}
}
Loading