DroidFish: Improved text to speech output.

* If the previous speech is not finished when a new move is made, queue
the new speech instead of interrupting the old speech.

* Play the regular move sound before speaking the move, to get the human
attention before the speech starts.

* Added a menu item to the board menu to repeat the last move.
This commit is contained in:
Peter Osterlund 2016-12-27 01:08:45 +01:00
parent 7fab4ff646
commit c34b04903a
4 changed files with 25 additions and 8 deletions

View File

@ -43,6 +43,7 @@ you are not actively using the program.\
<string name="load_scid_game">Load game from Scid file</string>
<string name="save_game">Save game to PGN file</string>
<string name="get_fen">Retrieve Position</string>
<string name="repeat_last_move">Repeat last move</string>
<string name="truncate_gametree">Truncate Game Tree</string>
<string name="move_var_up">Move Variation Up</string>
<string name="move_var_down">Move Variation Down</string>

View File

@ -2186,6 +2186,7 @@ public class DroidFish extends Activity
// savePGNToFile(".autosave.pgn", true);
TimeControlData tcData = new TimeControlData();
tcData.setTimeControl(timeControl, movesPerSession, timeIncrement);
speech.flushQueue();
ctrl.newGame(gameMode, tcData);
ctrl.startGame();
setBoardFlip(true);
@ -2264,12 +2265,13 @@ public class DroidFish extends Activity
}
private final Dialog boardMenuDialog() {
final int CLIPBOARD = 0;
final int FILEMENU = 1;
final int SHARE_GAME = 2;
final int SHARE_TEXT = 3;
final int SHARE_IMAG = 4;
final int GET_FEN = 5;
final int CLIPBOARD = 0;
final int FILEMENU = 1;
final int SHARE_GAME = 2;
final int SHARE_TEXT = 3;
final int SHARE_IMAG = 4;
final int GET_FEN = 5;
final int REPEAT_LAST_MOVE = 6;
setAutoMode(AutoMode.OFF);
List<CharSequence> lst = new ArrayList<CharSequence>();
@ -2284,6 +2286,9 @@ public class DroidFish extends Activity
if (hasFenProvider(getPackageManager())) {
lst.add(getString(R.string.get_fen)); actions.add(GET_FEN);
}
if (moveAnnounceType.startsWith("speech_")) {
lst.add(getString(R.string.repeat_last_move)); actions.add(REPEAT_LAST_MOVE);
}
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.tools_menu);
builder.setItems(lst.toArray(new CharSequence[lst.size()]), new DialogInterface.OnClickListener() {
@ -2308,6 +2313,10 @@ public class DroidFish extends Activity
case GET_FEN:
getFen();
break;
case REPEAT_LAST_MOVE:
speech.flushQueue();
ctrl.repeatLastMove();
break;
}
}
});

View File

@ -74,6 +74,7 @@ public class Speech {
case TextToSpeech.LANG_COUNTRY_AVAILABLE:
case TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE:
lang = Language.fromString(langStr);
tts.addEarcon("[move]", "org.petero.droidfish", R.raw.movesound);
say(toSpeak);
break;
case TextToSpeech.LANG_MISSING_DATA:
@ -97,8 +98,10 @@ public class Speech {
@SuppressWarnings("deprecation")
public void say(String text) {
if (initialized) {
if (lang != Language.NONE && text != null)
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
if (lang != Language.NONE && text != null) {
tts.playEarcon("[move]", TextToSpeech.QUEUE_ADD, null);
tts.speak(text, TextToSpeech.QUEUE_ADD, null);
}
toSpeak = null;
} else {
toSpeak = text;

View File

@ -1036,6 +1036,10 @@ public class DroidChessController {
updateGUI();
}
public final void repeatLastMove() {
gui.movePlayed(game.prevPos(), game.tree.currentNode.move, true);
}
private final void setPlayerNames(Game game) {
if (game != null) {
String engine = "Computer";