DroidFish: Improved Spanish text to speech.

This commit is contained in:
Peter Osterlund 2017-01-01 20:44:39 +01:00
parent 7cc84a2b6e
commit 827febd8e1
2 changed files with 25 additions and 11 deletions

View File

@ -279,6 +279,8 @@ public class Speech {
} }
private static String fromToString(String from, Language lang) { private static String fromToString(String from, Language lang) {
if ("b4".equals(from)) // Some TTS systems convert "b4" to "before"
from = "b 4";
switch (lang) { switch (lang) {
case EN: case EN:
if ("a".equals(from)) if ("a".equals(from))
@ -295,7 +297,19 @@ public class Speech {
} }
private static String toToString(String to, Language lang) { private static String toToString(String to, Language lang) {
if ("b4".equals(to)) // Some TTS systems convert "b4" to "before"
to = "b 4";
switch (lang) {
case EN:
return to; return to;
case DE:
return to;
case ES:
return to;
case NONE:
return "";
}
throw new IllegalArgumentException();
} }
private static String captureToString(String to, Language lang) { private static String captureToString(String to, Language lang) {
@ -362,7 +376,7 @@ public class Speech {
case DE: case DE:
return "Schach!"; return "Schach!";
case ES: case ES:
return ",jaque!"; return ", jaque!";
case NONE: case NONE:
return ""; return "";
} }
@ -376,7 +390,7 @@ public class Speech {
case DE: case DE:
return "Schach matt!"; return "Schach matt!";
case ES: case ES:
return ",mate!"; return ", mate!";
case NONE: case NONE:
return ""; return "";
} }

View File

@ -79,7 +79,7 @@ public class SpeechTest extends TestCase {
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
res = game.processString("b4"); res = game.processString("b4");
assertEquals(new String[]{"b4", "b4", "b4"}, assertEquals(new String[]{"b 4", "b 4", "b 4"},
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
res = game.processString("a5"); res = game.processString("a5");
@ -91,11 +91,11 @@ public class SpeechTest extends TestCase {
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
res = game.processString("axb4"); res = game.processString("axb4");
assertEquals(new String[]{"ae takes b4", "a schlägt b4", "a captura b4"}, assertEquals(new String[]{"ae takes b 4", "a schlägt b 4", "a captura b 4"},
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
res = game.processString("axb4"); res = game.processString("axb4");
assertEquals(new String[]{"ae takes b4", "a schlägt b4", "a captura b4"}, assertEquals(new String[]{"ae takes b 4", "a schlägt b 4", "a captura b 4"},
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
} }
{ {
@ -119,7 +119,7 @@ public class SpeechTest extends TestCase {
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
res = game.processString("Bb4"); res = game.processString("Bb4");
assertEquals(new String[]{"Bishop b4 check!", "Läufer b4 Schach!", "Alfil b4 ,jaque!"}, assertEquals(new String[]{"Bishop b 4 check!", "Läufer b 4 Schach!", "Alfil b 4 , jaque!"},
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
res = game.processString("c3"); res = game.processString("c3");
@ -131,7 +131,7 @@ public class SpeechTest extends TestCase {
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
res = game.processString("cxb4"); res = game.processString("cxb4");
assertEquals(new String[]{"c takes b4", "c schlägt b4", "c captura b4"}, assertEquals(new String[]{"c takes b 4", "c schlägt b 4", "c captura b 4"},
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
res = game.processString("O-O"); res = game.processString("O-O");
@ -148,7 +148,7 @@ public class SpeechTest extends TestCase {
res = game.processString("gxf8Q+"); res = game.processString("gxf8Q+");
assertEquals(new String[]{"g takes f8 Queen check!", "g schlägt f8 Umwandlung zu Dame Schach!", assertEquals(new String[]{"g takes f8 Queen check!", "g schlägt f8 Umwandlung zu Dame Schach!",
"g captura f8 Dama ,jaque!"}, "g captura f8 Dama , jaque!"},
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
res = game.processString("Kxf8"); res = game.processString("Kxf8");
@ -182,7 +182,7 @@ public class SpeechTest extends TestCase {
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
res = game.processString("Qh4"); res = game.processString("Qh4");
assertEquals(new String[]{"Queen h4 check mate!", "Dame h4 Schach matt!", "Dama h4 ,mate!"}, assertEquals(new String[]{"Queen h4 check mate!", "Dame h4 Schach matt!", "Dama h4 , mate!"},
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
} }
{ {
@ -193,7 +193,7 @@ public class SpeechTest extends TestCase {
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
playMoves(game, "Nxd4 Nxd5 Qxd5 Qxd4 Qxd4 Nf3 Qxd1 Kxd1"); playMoves(game, "Nxd4 Nxd5 Qxd5 Qxd4 Qxd4 Nf3 Qxd1 Kxd1");
res = game.processString("O-O-O"); res = game.processString("O-O-O");
assertEquals(new String[]{"Long castle check!", "Große Rochade Schach!", "Enroque largo ,jaque!"}, assertEquals(new String[]{"Long castle check!", "Große Rochade Schach!", "Enroque largo , jaque!"},
moveToText(game.prevPos(), res.second, lang)); moveToText(game.prevPos(), res.second, lang));
playMoves(game, "Kc1"); playMoves(game, "Kc1");
res = game.processString("Rd7"); res = game.processString("Rd7");