@@ -103,6 +103,7 @@ public class CRt_ViewManagerASB implements ICRt_ViewManager, ILoadableObject {
103
103
private int attemptNum = 0 ;
104
104
private boolean skippedWord = false ;
105
105
private boolean storyBooting ;
106
+ private boolean restartListener ;
106
107
107
108
private String [] wordsToDisplay ; // current sentence words to display - contain punctuation
108
109
private String [] wordsToSpeak ; // current sentence words to hear
@@ -697,7 +698,6 @@ private void trackSegment() {
697
698
698
699
if (!endOfSentence ) {
699
700
// Tell the script to speak the new utterance
700
- //
701
701
mParent .applyBehavior (TCONST .SPEAK_UTTERANCE );
702
702
postDelayedTracker ();
703
703
} else {
@@ -750,7 +750,6 @@ private void publishStateValues() {
750
750
751
751
String cumulativeState = TCONST .RTC_CLEAR ;
752
752
753
- // ensure echo state has a valid value.
754
753
mParent .publishValue (TCONST .RTC_VAR_ECHOSTATE , TCONST .FALSE );
755
754
mParent .publishValue (TCONST .RTC_VAR_PARROTSTATE , TCONST .FALSE );
756
755
@@ -1016,6 +1015,7 @@ private void setTutorFeatures(int currPage, int currPara, int currLine) {
1016
1015
mParent .setTutorFeatures (mCurrEffectiveVariant );
1017
1016
1018
1017
if (storyBooting ) mParent .setFeature (TCONST .FTR_STORY_STARTING , TCONST .ADD_FEATURE );
1018
+ restartListener = true ;
1019
1019
1020
1020
pagePrompt = data [currPage ].prompt ;
1021
1021
mPrevPrompt = mCurrPrompt ;
@@ -1056,10 +1056,12 @@ private String computeEffectiveVariant(int currPage, int currPara, int currLine)
1056
1056
*/
1057
1057
public void continueListening () {
1058
1058
if (hearRead .equals (TCONST .FTR_USER_HEAR )) mParent .applyBehavior (TCONST .NARRATE_STORY );
1059
- if (hearRead .equals (TCONST .FTR_USER_READ )) startListening ();
1059
+ if (hearRead .equals (TCONST .FTR_USER_READ ) && restartListener ) startListening ();
1060
1060
}
1061
1061
1062
1062
private void startListening () {
1063
+ Log .d (TAG , "startListening" );
1064
+
1063
1065
// We allow the user to say any of the onscreen words but set the priority order of how we
1064
1066
// would like them matched Note that if the listener is not explicitly listening for a word
1065
1067
// it will just ignore it if spoken.
@@ -1088,6 +1090,7 @@ private void startListening() {
1088
1090
1089
1091
mListener .listenFor (wordsToListenFor .toArray (new String [wordsToListenFor .size ()]), 0 );
1090
1092
mListener .setPauseListener (false );
1093
+ restartListener = false ;
1091
1094
}
1092
1095
}
1093
1096
@@ -1255,8 +1258,7 @@ public void onUpdate(ListenerBase.HeardWord[] heardWords, boolean finalResult) {
1255
1258
}
1256
1259
1257
1260
while ((mCurrWord < wordsToSpeak .length ) && (mHeardWord < heardWords .length )) {
1258
- if (wordsToSpeak [mCurrWord ].equals (heardWords [mHeardWord ].hypWord ) // || ("START_" + wordsToSpeak[mCurrWord]).equals(heardWords[mHeardWord].hypWord)
1259
- ) {
1261
+ if (wordsToSpeak [mCurrWord ].equals (heardWords [mHeardWord ].hypWord ) || ("START_" + wordsToSpeak [mCurrWord ]).equals (heardWords [mHeardWord ].hypWord )) {
1260
1262
Log .i ("ASR" , "RIGHT" );
1261
1263
1262
1264
skippedWord = false ;
@@ -1266,8 +1268,7 @@ public void onUpdate(ListenerBase.HeardWord[] heardWords, boolean finalResult) {
1266
1268
attemptNum = 0 ;
1267
1269
result = true ;
1268
1270
mParent .updateContext (rawSentence , mCurrLine , wordsToSpeak , mCurrWord - 1 , heardWords [mHeardWord - 1 ].hypWord , attemptNum , heardWords [mHeardWord - 1 ].utteranceId == "" , true );
1269
- } else if (skippingWords && !skippedWord && attemptNum == 0 && mCurrWord + 1 < wordsToSpeak .length && (wordsToSpeak [mCurrWord + 1 ].equals (heardWords [mHeardWord ].hypWord ) // || ("START_" + wordsToSpeak[mCurrWord]).equals(heardWords[mHeardWord].hypWord)
1270
- )) {
1271
+ } 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 ))) {
1271
1272
Log .i ("ASR" , "SKIPPED" );
1272
1273
1273
1274
skippedWord = true ;
@@ -1290,6 +1291,7 @@ public void onUpdate(ListenerBase.HeardWord[] heardWords, boolean finalResult) {
1290
1291
1291
1292
skippedWord = false ;
1292
1293
mListener .setPauseListener (true );
1294
+ restartListener = true ;
1293
1295
attemptNum ++;
1294
1296
result = false ;
1295
1297
mParent .updateContext (rawSentence , mCurrLine , wordsToSpeak , mCurrWord , heardWords [mHeardWord ].hypWord , attemptNum , heardWords [mHeardWord ].utteranceId == "" , false );
0 commit comments