Prepare more granular Voice status reporting

This commit is contained in:
sonora 2017-06-14 21:41:18 +02:00
parent 32219ace81
commit cdad7eb033
2 changed files with 24 additions and 16 deletions

View file

@ -291,8 +291,9 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
}
}
if (description.startsWith("(11.3)")) {
final String systemVoiceUsed = AbstractPrologCommandPlayer.getCurrentVersion() > 99 ? TTSCommandPlayerImpl.getTtsVoiceName() : "Recorded voice";
Toast.makeText(TestVoiceActivity.this, "System's language availability status and voice actually used:\n\n" + systemVoiceUsed, Toast.LENGTH_LONG).show();
final String systemVoiceStatus = AbstractPrologCommandPlayer.getCurrentVersion() > 99 ? TTSCommandPlayerImpl.getTtsVoiceStatus() : "Recorded voice";
final String systemVoiceUsed = AbstractPrologCommandPlayer.getCurrentVersion() > 99 ? TTSCommandPlayerImpl.getTtsVoiceUsed() : "Recorded voice";
Toast.makeText(TestVoiceActivity.this, "Voice language availability: " + systemVoiceStatus + "\n\nVoice actually used: " + systemVoiceUsed, Toast.LENGTH_LONG).show();
}
}
});

View file

@ -65,7 +65,8 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
// TODO: We could actually remove v102 support, I am done updating all existing 35 TTS voices to v103. Hardy, July 2016
private static final Log log = PlatformUtil.getLog(TTSCommandPlayerImpl.class);
private static TextToSpeech mTts;
private static String ttsVoiceName = "";
private static String ttsVoiceStatus = "";
private static String ttsVoiceUsed = "";
private Context mTtsContext;
private HashMap<String, String> params = new HashMap<String, String>();
private VoiceRouter vrt;
@ -164,7 +165,8 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
}
if (mTts == null) {
mTtsContext = ctx;
ttsVoiceName = "";
ttsVoiceStatus = "";
ttsVoiceUsed = "";
ttsRequests = 0;
final float speechRate = cSpeechRate;
@ -185,7 +187,7 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
@Override
public void onInit(int status) {
if (status != TextToSpeech.SUCCESS) {
ttsVoiceName = "NO INIT SUCCESS";
ttsVoiceStatus = "NO INIT SUCCESS";
internalClear();
} else if (mTts != null) {
speechAllowed = true;
@ -201,13 +203,13 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
act);
builder.show();
}
ttsVoiceName = newLocale.getDisplayName() + ": LANG_MISSING_DATA";
ttsVoiceName = ttsVoiceName + "\n\n" + getVoiceUsed();
ttsVoiceStatus = newLocale.getDisplayName() + ": LANG_MISSING_DATA";
ttsVoiceUsed = getTtsVoiceUsed();
break;
case TextToSpeech.LANG_AVAILABLE:
ttsVoiceName = newLocale.getDisplayName() + ": LANG_AVAILABLE";
ttsVoiceStatus = newLocale.getDisplayName() + ": LANG_AVAILABLE";
case TextToSpeech.LANG_COUNTRY_AVAILABLE:
ttsVoiceName = "".equals(ttsVoiceName) ? newLocale.getDisplayName() + ": LANG_COUNTRY_AVAILABLE" : ttsVoiceName;
ttsVoiceStatus = "".equals(ttsVoiceStatus) ? newLocale.getDisplayName() + ": LANG_COUNTRY_AVAILABLE" : ttsVoiceStatus;
case TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE:
try {
mTts.setLanguage(newLocale);
@ -218,8 +220,8 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
if(speechRate != 1) {
mTts.setSpeechRate(speechRate);
}
ttsVoiceName = "".equals(ttsVoiceName) ? newLocale.getDisplayName() + ": LANG_COUNTRY_VAR_AVAILABLE" : ttsVoiceName;
ttsVoiceName = ttsVoiceName + "\n\n" + getVoiceUsed();
ttsVoiceStatus = "".equals(ttsVoiceStatus) ? newLocale.getDisplayName() + ": LANG_COUNTRY_VAR_AVAILABLE" : ttsVoiceStatus;
ttsVoiceUsed = getTtsVoiceUsed();
break;
case TextToSpeech.LANG_NOT_SUPPORTED:
//maybe weird, but I didn't want to introduce parameter in around 5 methods just to do this if condition
@ -234,8 +236,8 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
act);
builder.show();
}
ttsVoiceName = newLocale.getDisplayName() + ": LANG_NOT_SUPPORTED";
ttsVoiceName = ttsVoiceName + "\n\n" + getVoiceUsed();
ttsVoiceStatus = newLocale.getDisplayName() + ": LANG_NOT_SUPPORTED";
ttsVoiceUsed = getTtsVoiceUsed();
break;
}
}
@ -275,8 +277,12 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
}
}
public static String getTtsVoiceName() {
return ttsVoiceName;
public static String getTtsVoiceStatus() {
return ttsVoiceStatus;
}
public static String getTtsVoiceUsed() {
return ttsVoiceUsed;
}
private AlertDialog.Builder createAlertDialog(int titleResID, int messageResID,
@ -299,7 +305,8 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
}
abandonAudioFocus();
mTtsContext = null;
ttsVoiceName = "";
ttsVoiceStatus = "";
ttsVoiceUsed = "";
}
@Override