diff options
author | Skylion007 <dragonsrcool.aaron@gmail.com> | 2013-08-26 00:23:13 +0400 |
---|---|---|
committer | Skylion007 <dragonsrcool.aaron@gmail.com> | 2013-08-26 00:23:13 +0400 |
commit | 272a0ee7de2e3f4663c1c6c505404a4afa561780 (patch) | |
tree | 5f3f55228b64b8c5dde3d21114632af931df6648 | |
parent | cfdd99d4580d5bc7e8d01681ce9548c028d614b9 (diff) |
Stability and parsing improvements
Improved the parsing algorithm upon further experimentation with Google's formatting. Will update with accepted languages to remove fictions and untranslatable languages such as Wolof.
-rw-r--r-- | src/com/darkprograms/speech/synthesiser/Synthesiser.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/com/darkprograms/speech/synthesiser/Synthesiser.java b/src/com/darkprograms/speech/synthesiser/Synthesiser.java index 2821601..d304df8 100644 --- a/src/com/darkprograms/speech/synthesiser/Synthesiser.java +++ b/src/com/darkprograms/speech/synthesiser/Synthesiser.java @@ -243,14 +243,15 @@ public class Synthesiser { } /** - * Searches RAWData for Language - * @param RAWData the raw String directly from Google you want to search through - * @return The language parsed from the rawData or en-US (English-United States) if Google cannot determine it. + * Searches RawData for Language + * @param RawData the raw String directly from Google you want to search through + * @return The language parsed from the rawData or null if Google cannot determine it. */ private String parseRawData(String rawData){ - for(int i = 0; i+3<=rawData.length(); i++){ - if(rawData.charAt(i)=='"' && rawData.charAt(i+3)=='"'){ - String possible = rawData.substring(i+1,i+3); + for(int i = 0; i+5<rawData.length(); i++){ + if(rawData.charAt(i)==',' && rawData.charAt(i+5)==',' //Looks for ,"en", ,"es", etc. + && rawData.charAt(i+1)== '"' && rawData.charAt(i+4)=='"'){ // ,"**", + String possible = rawData.substring(i+2,i+4); if(containsLettersOnly(possible)){//Required due to Google's inconsistent formatting. return possible; } |