Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/java-speech-api.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSkylion007 <dragonsrcool.aaron@gmail.com>2013-09-02 02:37:09 +0400
committerSkylion007 <dragonsrcool.aaron@gmail.com>2013-09-02 02:37:09 +0400
commit7a8780206e02b0cc820a2b10d733f0018d872848 (patch)
treeb0f03a857f7691573a0542a1bec62b550fd9f929
parentf7553d8d1cb5e25dcfc230d3ff06dfc406673c43 (diff)
Language support detection
Ensures that odd languages such as Maori are not passed on to (and rejected by) Google's TTS.
-rw-r--r--src/com/darkprograms/speech/synthesiser/Synthesiser.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/com/darkprograms/speech/synthesiser/Synthesiser.java b/src/com/darkprograms/speech/synthesiser/Synthesiser.java
index aa58c51..d648386 100644
--- a/src/com/darkprograms/speech/synthesiser/Synthesiser.java
+++ b/src/com/darkprograms/speech/synthesiser/Synthesiser.java
@@ -224,6 +224,8 @@ public class Synthesiser {
URLConnection urlConn = url.openConnection(); //Open connection
urlConn.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0) Gecko/20100101 Firefox/4.0"); //Adding header for user agent is required
String rawData = urlToText(urlConn);//Gets text from Google
+ if(!isLanguageSupported(rawData))
+ return null;//Comment this if statement out if you want to use this code for rare languages like Maori.
return parseRawData(rawData);
}
@@ -277,5 +279,14 @@ public class Synthesiser {
}
return true;
}
+
+ /**
+ * Check is a language is supported from rawData
+ * @param rawData Checks if a language is supported based off of rawData
+ * @return true if supported otherwise false.
+ */
+ private boolean isLanguageSupported(String rawData){
+ return !rawData.contains(",\"We are not yet able to translate from ");
+ }
}