diff options
author | Luke Kuza <luke.kuza@allstarwireless.com> | 2013-09-02 06:05:17 +0400 |
---|---|---|
committer | Luke Kuza <luke.kuza@allstarwireless.com> | 2013-09-02 06:05:17 +0400 |
commit | 3a1c82ffb1d4b0ffc982123be2dc90fd89cb4ab3 (patch) | |
tree | 01532b811e45652449291d0fdb9e7daaa236b823 | |
parent | 0eb087f9dd4a4ee161400d447fdbd6fc9343a196 (diff) | |
parent | 7a8780206e02b0cc820a2b10d733f0018d872848 (diff) |
Merge pull request #18 from Skylion007/patch-2
Language support detection
-rw-r--r-- | src/com/darkprograms/speech/synthesiser/Synthesiser.java | 11 |
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 "); + } } |