@@ -102,6 +102,7 @@ public class CRt_ViewManagerASB implements ICRt_ViewManager, ILoadableObject {
102
102
private int attemptNum = 0 ;
103
103
private boolean skippedWord = false ;
104
104
private boolean storyBooting ;
105
+ private boolean restartListener ;
105
106
106
107
private String [] wordsToDisplay ; // current sentence words to display - contain punctuation
107
108
private String [] wordsToSpeak ; // current sentence words to hear
@@ -691,7 +692,6 @@ private void trackSegment() {
691
692
692
693
if (!endOfSentence ) {
693
694
// Tell the script to speak the new utterance
694
- //
695
695
mParent .applyBehavior (TCONST .SPEAK_UTTERANCE );
696
696
postDelayedTracker ();
697
697
} else {
@@ -744,7 +744,6 @@ private void publishStateValues() {
744
744
745
745
String cumulativeState = TCONST .RTC_CLEAR ;
746
746
747
- // ensure echo state has a valid value.
748
747
mParent .publishValue (TCONST .RTC_VAR_ECHOSTATE , TCONST .FALSE );
749
748
mParent .publishValue (TCONST .RTC_VAR_PARROTSTATE , TCONST .FALSE );
750
749
@@ -1010,6 +1009,7 @@ private void setTutorFeatures(int currPage, int currPara, int currLine) {
1010
1009
mParent .setTutorFeatures (mCurrEffectiveVariant );
1011
1010
1012
1011
if (storyBooting ) mParent .setFeature (TCONST .FTR_STORY_STARTING , TCONST .ADD_FEATURE );
1012
+ restartListener = true ;
1013
1013
1014
1014
pagePrompt = data [currPage ].prompt ;
1015
1015
mPrevPrompt = mCurrPrompt ;
@@ -1050,10 +1050,12 @@ private String computeEffectiveVariant(int currPage, int currPara, int currLine)
1050
1050
*/
1051
1051
public void continueListening () {
1052
1052
if (hearRead .equals (TCONST .FTR_USER_HEAR )) mParent .applyBehavior (TCONST .NARRATE_STORY );
1053
- if (hearRead .equals (TCONST .FTR_USER_READ )) startListening ();
1053
+ if (hearRead .equals (TCONST .FTR_USER_READ ) && restartListener ) startListening ();
1054
1054
}
1055
1055
1056
1056
private void startListening () {
1057
+ Log .d (TAG , "startListening" );
1058
+
1057
1059
// We allow the user to say any of the onscreen words but set the priority order of how we
1058
1060
// would like them matched Note that if the listener is not explicitly listening for a word
1059
1061
// it will just ignore it if spoken.
@@ -1082,6 +1084,7 @@ private void startListening() {
1082
1084
1083
1085
mListener .listenFor (wordsToListenFor .toArray (new String [wordsToListenFor .size ()]), 0 );
1084
1086
mListener .setPauseListener (false );
1087
+ restartListener = false ;
1085
1088
}
1086
1089
}
1087
1090
@@ -1249,8 +1252,7 @@ public void onUpdate(ListenerBase.HeardWord[] heardWords, boolean finalResult) {
1249
1252
}
1250
1253
1251
1254
while ((mCurrWord < wordsToSpeak .length ) && (mHeardWord < heardWords .length )) {
1252
- if (wordsToSpeak [mCurrWord ].equals (heardWords [mHeardWord ].hypWord ) // || ("START_" + wordsToSpeak[mCurrWord]).equals(heardWords[mHeardWord].hypWord)
1253
- ) {
1255
+ if (wordsToSpeak [mCurrWord ].equals (heardWords [mHeardWord ].hypWord ) || ("START_" + wordsToSpeak [mCurrWord ]).equals (heardWords [mHeardWord ].hypWord )) {
1254
1256
Log .i ("ASR" , "RIGHT" );
1255
1257
1256
1258
skippedWord = false ;
@@ -1260,8 +1262,7 @@ public void onUpdate(ListenerBase.HeardWord[] heardWords, boolean finalResult) {
1260
1262
attemptNum = 0 ;
1261
1263
result = true ;
1262
1264
mParent .updateContext (rawSentence , mCurrLine , wordsToSpeak , mCurrWord - 1 , heardWords [mHeardWord - 1 ].hypWord , attemptNum , heardWords [mHeardWord - 1 ].utteranceId == "" , true );
1263
- } else if (skippingWords && !skippedWord && attemptNum == 0 && mCurrWord + 1 < wordsToSpeak .length && (wordsToSpeak [mCurrWord + 1 ].equals (heardWords [mHeardWord ].hypWord ) // || ("START_" + wordsToSpeak[mCurrWord]).equals(heardWords[mHeardWord].hypWord)
1264
- )) {
1265
+ } else if (skippingWords && !skippedWord && attemptNum == 0 && mCurrWord + 1 < wordsToSpeak .length && (wordsToSpeak [mCurrWord + 1 ].equals (heardWords [mHeardWord ].hypWord ) || ("START_" + wordsToSpeak [mCurrWord + 1 ]).equals (heardWords [mHeardWord ].hypWord ))) {
1265
1266
Log .i ("ASR" , "SKIPPED" );
1266
1267
1267
1268
skippedWord = true ;
@@ -1284,6 +1285,7 @@ public void onUpdate(ListenerBase.HeardWord[] heardWords, boolean finalResult) {
1284
1285
1285
1286
skippedWord = false ;
1286
1287
mListener .setPauseListener (true );
1288
+ restartListener = true ;
1287
1289
attemptNum ++;
1288
1290
result = false ;
1289
1291
mParent .updateContext (rawSentence , mCurrLine , wordsToSpeak , mCurrWord , heardWords [mHeardWord ].hypWord , attemptNum , heardWords [mHeardWord ].utteranceId == "" , false );
0 commit comments