mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-08 23:22:40 +01:00
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:
@@ -43,6 +43,7 @@ you are not actively using the program.\
|
|||||||
<string name="load_scid_game">Load game from Scid file</string>
|
<string name="load_scid_game">Load game from Scid file</string>
|
||||||
<string name="save_game">Save game to PGN file</string>
|
<string name="save_game">Save game to PGN file</string>
|
||||||
<string name="get_fen">Retrieve Position</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="truncate_gametree">Truncate Game Tree</string>
|
||||||
<string name="move_var_up">Move Variation Up</string>
|
<string name="move_var_up">Move Variation Up</string>
|
||||||
<string name="move_var_down">Move Variation Down</string>
|
<string name="move_var_down">Move Variation Down</string>
|
||||||
|
|||||||
@@ -2186,6 +2186,7 @@ public class DroidFish extends Activity
|
|||||||
// savePGNToFile(".autosave.pgn", true);
|
// savePGNToFile(".autosave.pgn", true);
|
||||||
TimeControlData tcData = new TimeControlData();
|
TimeControlData tcData = new TimeControlData();
|
||||||
tcData.setTimeControl(timeControl, movesPerSession, timeIncrement);
|
tcData.setTimeControl(timeControl, movesPerSession, timeIncrement);
|
||||||
|
speech.flushQueue();
|
||||||
ctrl.newGame(gameMode, tcData);
|
ctrl.newGame(gameMode, tcData);
|
||||||
ctrl.startGame();
|
ctrl.startGame();
|
||||||
setBoardFlip(true);
|
setBoardFlip(true);
|
||||||
@@ -2264,12 +2265,13 @@ public class DroidFish extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final Dialog boardMenuDialog() {
|
private final Dialog boardMenuDialog() {
|
||||||
final int CLIPBOARD = 0;
|
final int CLIPBOARD = 0;
|
||||||
final int FILEMENU = 1;
|
final int FILEMENU = 1;
|
||||||
final int SHARE_GAME = 2;
|
final int SHARE_GAME = 2;
|
||||||
final int SHARE_TEXT = 3;
|
final int SHARE_TEXT = 3;
|
||||||
final int SHARE_IMAG = 4;
|
final int SHARE_IMAG = 4;
|
||||||
final int GET_FEN = 5;
|
final int GET_FEN = 5;
|
||||||
|
final int REPEAT_LAST_MOVE = 6;
|
||||||
|
|
||||||
setAutoMode(AutoMode.OFF);
|
setAutoMode(AutoMode.OFF);
|
||||||
List<CharSequence> lst = new ArrayList<CharSequence>();
|
List<CharSequence> lst = new ArrayList<CharSequence>();
|
||||||
@@ -2284,6 +2286,9 @@ public class DroidFish extends Activity
|
|||||||
if (hasFenProvider(getPackageManager())) {
|
if (hasFenProvider(getPackageManager())) {
|
||||||
lst.add(getString(R.string.get_fen)); actions.add(GET_FEN);
|
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);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(R.string.tools_menu);
|
builder.setTitle(R.string.tools_menu);
|
||||||
builder.setItems(lst.toArray(new CharSequence[lst.size()]), new DialogInterface.OnClickListener() {
|
builder.setItems(lst.toArray(new CharSequence[lst.size()]), new DialogInterface.OnClickListener() {
|
||||||
@@ -2308,6 +2313,10 @@ public class DroidFish extends Activity
|
|||||||
case GET_FEN:
|
case GET_FEN:
|
||||||
getFen();
|
getFen();
|
||||||
break;
|
break;
|
||||||
|
case REPEAT_LAST_MOVE:
|
||||||
|
speech.flushQueue();
|
||||||
|
ctrl.repeatLastMove();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ public class Speech {
|
|||||||
case TextToSpeech.LANG_COUNTRY_AVAILABLE:
|
case TextToSpeech.LANG_COUNTRY_AVAILABLE:
|
||||||
case TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE:
|
case TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE:
|
||||||
lang = Language.fromString(langStr);
|
lang = Language.fromString(langStr);
|
||||||
|
tts.addEarcon("[move]", "org.petero.droidfish", R.raw.movesound);
|
||||||
say(toSpeak);
|
say(toSpeak);
|
||||||
break;
|
break;
|
||||||
case TextToSpeech.LANG_MISSING_DATA:
|
case TextToSpeech.LANG_MISSING_DATA:
|
||||||
@@ -97,8 +98,10 @@ public class Speech {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void say(String text) {
|
public void say(String text) {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
if (lang != Language.NONE && text != null)
|
if (lang != Language.NONE && text != null) {
|
||||||
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
|
tts.playEarcon("[move]", TextToSpeech.QUEUE_ADD, null);
|
||||||
|
tts.speak(text, TextToSpeech.QUEUE_ADD, null);
|
||||||
|
}
|
||||||
toSpeak = null;
|
toSpeak = null;
|
||||||
} else {
|
} else {
|
||||||
toSpeak = text;
|
toSpeak = text;
|
||||||
|
|||||||
@@ -1036,6 +1036,10 @@ public class DroidChessController {
|
|||||||
updateGUI();
|
updateGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void repeatLastMove() {
|
||||||
|
gui.movePlayed(game.prevPos(), game.tree.currentNode.move, true);
|
||||||
|
}
|
||||||
|
|
||||||
private final void setPlayerNames(Game game) {
|
private final void setPlayerNames(Game game) {
|
||||||
if (game != null) {
|
if (game != null) {
|
||||||
String engine = "Computer";
|
String engine = "Computer";
|
||||||
|
|||||||
Reference in New Issue
Block a user