Added beta JS tts support
This commit is contained in:
parent
405e63d4a3
commit
65e8b0b7b6
11 changed files with 50 additions and 31 deletions
|
@ -48,31 +48,31 @@
|
|||
<!--<asset source="voice/be/be_tts.js" destination="voice/be-tts/be_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<!--<asset source="voice/cs/cs_tts.js" destination="voice/cs-tts/cs_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<!--<asset source="voice/da/da_tts.js" destination="voice/da-tts/da_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<asset source="voice/de/de_tts.js" destination="voice/de-tts/de_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<asset source="voice/de/de_tts.js" destination="voice/de-tts-js/de_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<!--<asset source="voice/el/el_tts.js" destination="voice/el-tts/el_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<asset source="voice/en/en_tts.js" destination="voice/en-tts/en_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<asset source="voice/en/en_tts.js" destination="voice/en-tts-js/en_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<!--<asset source="voice/en-gb/en-gb_tts.js" destination="voice/en-gb-tts/en-gb_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<asset source="voice/es/es_tts.js" destination="voice/es-tts/es_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<asset source="voice/es/es_tts.js" destination="voice/es-tts-js/es_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<!--<asset source="voice/es-ar/es-ar_tts.js" destination="voice/es-ar-tts/es-ar_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<!--<asset source="voice/et/et_tts.js" destination="voice/et-tts/et_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<!--<asset source="voice/fa/fa_tts.js" destination="voice/fa-tts/fa_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<!--<asset source="voice/fi/fi_tts.js" destination="voice/fi-tts/fi_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<asset source="voice/fr/fr_tts.js" destination="voice/fr-tts/fr_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<asset source="voice/fr/fr_tts.js" destination="voice/fr-tts-js/fr_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<!--<asset source="voice/he/he_tts.js" destination="voice/he-tts/he_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<!--<asset source="voice/hi/hi_tts.js" destination="voice/hi-tts/hi_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<!--<asset source="voice/hr/hr_tts.js" destination="voice/hr-tts/hr_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<asset source="voice/hu/hu_tts.js" destination="voice/hu-tts/hu_tts.js" mode="overwriteOnlyIfExists" />
|
||||
<asset source="voice/hu/hu_tts.js" destination="voice/hu-tts-js/hu_tts.js" mode="overwriteOnlyIfExists" />
|
||||
<!--<asset source="voice/hu-formal/hu-formal_tts.js" destination="voice/hu_formal-tts/hu-formal_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<asset source="voice/it/it_tts.js" destination="voice/it-tts/it_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<asset source="voice/it/it_tts.js" destination="voice/it-tts-js/it_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<!--<asset source="voice/ja/ja_tts.js" destination="voice/ja-tts/ja_tts.js" mode="alwaysOverwriteOrCopy" />-->
|
||||
<!--<asset source="voice/ko/ko_tts.js" destination="voice/ko-tts/ko_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<!--<asset source="voice/lv/lv_tts.js" destination="voice/lv-tts/lv_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<asset source="voice/nl/nl_tts.js" destination="voice/nl-tts/nl_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<asset source="voice/pl/pl_tts.js" destination="voice/pl-tts/pl_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<asset source="voice/pt/pt_tts.js" destination="voice/pt-tts/pt_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<asset source="voice/nl/nl_tts.js" destination="voice/nl-tts-js/nl_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<asset source="voice/pl/pl_tts.js" destination="voice/pl-tts-js/pl_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<asset source="voice/pt/pt_tts.js" destination="voice/pt-tts-js/pt_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<!--<asset source="voice/pt-br/pt-br_tts.js" destination="voice/pt-br-tts/pt-br_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<!--<asset source="voice/ro/ro_tts.js" destination="voice/ro-tts/ro_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<asset source="voice/ru/ru_tts.js" destination="voice/ru-tts/ru_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<asset source="voice/ru/ru_tts.js" destination="voice/ru-tts-js/ru_tts.js" mode="alwaysOverwriteOrCopy" />
|
||||
<!--<asset source="voice/sc/sc_tts.js" destination="voice/sc-tts/sc_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<!--<asset source="voice/sk/sk_tts.js" destination="voice/sk-tts/sk_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
<!--<asset source="voice/sl/sl_tts.js" destination="voice/sl-tts/sl_tts.js" mode="overwriteOnlyIfExists" />-->
|
||||
|
|
|
@ -2935,4 +2935,5 @@
|
|||
<string name="use_js_voice_guidance_description">Use new voice guidance logic based on JavaScript</string>
|
||||
<string name="test_voice_desrc">Tap a button and listen to the corresponding voice prompt to identify missing or faulty propmts.</string>
|
||||
<string name="voice_tts_js">Voice prompts (JavaScript TTS)</string>
|
||||
<string name="js_tts_label">(JavaScript)</string>
|
||||
</resources>
|
||||
|
|
|
@ -578,10 +578,9 @@ public class AppInitializer implements IProgress {
|
|||
if (!voiceDir.exists()) {
|
||||
throw new CommandPlayerException(ctx.getString(R.string.voice_data_unavailable));
|
||||
}
|
||||
if (app.getSettings().USE_JS_VOICE_GUIDANCE.get()) {
|
||||
if (app.getSettings().USE_JS_VOICE_GUIDANCE.get() && JSTTSCommandPlayerImpl.isMyData(voiceDir)) {
|
||||
return new JSTTSCommandPlayerImpl(ctx, applicationMode, osmandApplication.getRoutingHelper().getVoiceRouter(), voiceProvider);
|
||||
}
|
||||
if (MediaCommandPlayerImpl.isMyData(voiceDir)) {
|
||||
} else if (MediaCommandPlayerImpl.isMyData(voiceDir)) {
|
||||
return new MediaCommandPlayerImpl(osmandApplication, applicationMode, osmandApplication.getRoutingHelper().getVoiceRouter(), voiceProvider);
|
||||
} else if (TTSCommandPlayerImpl.isMyData(voiceDir)) {
|
||||
return new TTSCommandPlayerImpl(ctx, applicationMode, osmandApplication.getRoutingHelper().getVoiceRouter(), voiceProvider);
|
||||
|
|
|
@ -219,12 +219,11 @@ public class LocalIndexHelper {
|
|||
private void loadVoiceData(File voiceDir, List<LocalIndexInfo> result, boolean backup, AbstractLoadLocalIndexTask loadTask) {
|
||||
if (voiceDir.canRead()) {
|
||||
//First list TTS files, they are preferred
|
||||
boolean useJs = app.getSettings().USE_JS_VOICE_GUIDANCE.get();
|
||||
for (File voiceF : listFilesSorted(voiceDir)) {
|
||||
if (voiceF.isDirectory() && !MediaCommandPlayerImpl.isMyData(voiceF)) {
|
||||
LocalIndexInfo info = null;
|
||||
if (useJs ? JSTTSCommandPlayerImpl.isMyData(voiceF) : TTSCommandPlayerImpl.isMyData(voiceF)) {
|
||||
info = new LocalIndexInfo(useJs ? LocalIndexType.TTS_VOICE_DATA_JS : LocalIndexType.TTS_VOICE_DATA, voiceF, backup, app);
|
||||
if (TTSCommandPlayerImpl.isMyData(voiceF)) {
|
||||
info = new LocalIndexInfo(LocalIndexType.TTS_VOICE_DATA, voiceF, backup, app);
|
||||
}
|
||||
if (info != null) {
|
||||
updateDescription(info);
|
||||
|
@ -234,6 +233,22 @@ public class LocalIndexHelper {
|
|||
}
|
||||
}
|
||||
|
||||
if (app.getSettings().USE_JS_VOICE_GUIDANCE.get()) {
|
||||
for (File voiceF : listFilesSorted(voiceDir)) {
|
||||
if (voiceF.isDirectory() && !MediaCommandPlayerImpl.isMyData(voiceF)) {
|
||||
LocalIndexInfo info = null;
|
||||
if (JSTTSCommandPlayerImpl.isMyData(voiceF)) {
|
||||
info = new LocalIndexInfo(LocalIndexType.TTS_VOICE_DATA_JS, voiceF, backup, app);
|
||||
}
|
||||
if (info != null) {
|
||||
updateDescription(info);
|
||||
result.add(info);
|
||||
loadTask.loadFile(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Now list recorded voices
|
||||
for (File voiceF : listFilesSorted(voiceDir)) {
|
||||
if (voiceF.isDirectory() && MediaCommandPlayerImpl.isMyData(voiceF)) {
|
||||
|
|
|
@ -253,7 +253,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
entries[k++] = getString(R.string.shared_string_do_not_use);
|
||||
for (String s : voiceFiles) {
|
||||
entries[k] = (s.contains("tts") ? getString(R.string.ttsvoice) + " " : "") +
|
||||
FileNameTranslationHelper.getVoiceName(this, s);
|
||||
FileNameTranslationHelper.getVoiceName(this, s) + (s.contains("-js") ? " " + getString(R.string.js_tts_label) : "");
|
||||
entrieValues[k] = s;
|
||||
k++;
|
||||
}
|
||||
|
|
|
@ -338,6 +338,9 @@ public class DownloadActivityType {
|
|||
// if(fileName.endsWith(IndexConstants.VOICE_INDEX_EXT_ZIP) ||
|
||||
// fileName.endsWith(IndexConstants.TTSVOICE_INDEX_EXT_ZIP)) {
|
||||
if (this == VOICE_FILE) {
|
||||
if (fileName.contains(".js")) {
|
||||
return fileName;
|
||||
}
|
||||
int l = fileName.lastIndexOf('_');
|
||||
if (l == -1) {
|
||||
l = fileName.length();
|
||||
|
@ -410,7 +413,7 @@ public class DownloadActivityType {
|
|||
if (l == -1) {
|
||||
l = fileName.length();
|
||||
}
|
||||
return fileName.substring(0, l);
|
||||
return fileName.endsWith(IndexConstants.TTSVOICE_INDEX_EXT_JS) ? fileName : fileName.substring(0, l);
|
||||
}
|
||||
if (this == FONT_FILE) {
|
||||
int l = fileName.indexOf('.');
|
||||
|
|
|
@ -139,6 +139,9 @@ public class IndexItem implements Comparable<IndexItem> {
|
|||
String basename;
|
||||
if (type == DownloadActivityType.HILLSHADE_FILE) {
|
||||
basename = (FileNameTranslationHelper.HILL_SHADE + getBasename()).replace("_", " ");
|
||||
} else if (type == DownloadActivityType.VOICE_FILE && getFileName().endsWith(IndexConstants.TTSVOICE_INDEX_EXT_JS)){
|
||||
return new File(type.getDownloadFolder(ctx, this),
|
||||
getBasename().replaceAll("[_\\.]+", "-") + File.separator + getBasename());
|
||||
} else {
|
||||
basename = getBasename();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class FileNameTranslationHelper {
|
|||
String basename = getBasename(fileName);
|
||||
if (basename.endsWith(WIKI_NAME)) { //wiki files
|
||||
return getWikiName(ctx, basename);
|
||||
} else if (fileName.endsWith("tts")) { //tts files
|
||||
} else if (fileName.endsWith("tts") || fileName.endsWith("tts-js")) { //tts files
|
||||
return getVoiceName(ctx, fileName);
|
||||
} else if (fileName.endsWith(IndexConstants.FONT_INDEX_EXT)) { //otf files
|
||||
return getFontName(ctx, basename);
|
||||
|
@ -80,8 +80,11 @@ public class FileNameTranslationHelper {
|
|||
|
||||
public static String getVoiceName(Context ctx, String fileName) {
|
||||
try {
|
||||
String nm = fileName.replace('-', '_').replace(' ', '_');
|
||||
if (nm.endsWith("_tts") || nm.endsWith("-tts")) {
|
||||
String nm = fileName.replace('-', '_').replace(' ', '_')
|
||||
.replace('.', '_');
|
||||
if (nm.endsWith("_tts_js")) {
|
||||
nm = nm.substring(0, nm.indexOf("_tts_js"));
|
||||
} else if (nm.endsWith("_tts") || nm.endsWith("-tts")) {
|
||||
nm = nm.substring(0, nm.length() - 4);
|
||||
}
|
||||
Field f = R.string.class.getField("lang_"+nm);
|
||||
|
|
|
@ -280,7 +280,7 @@ public class RoutePreferencesMenu {
|
|||
k++;
|
||||
for (String s : voiceFiles) {
|
||||
entries[k] = (s.contains("tts") ? mapActivity.getResources().getString(R.string.ttsvoice) + " " : "") +
|
||||
FileNameTranslationHelper.getVoiceName(mapActivity, s);
|
||||
FileNameTranslationHelper.getVoiceName(mapActivity, s) + (s.contains("-js") ? " " + mapActivity.getString(R.string.js_tts_label) : "");
|
||||
entrieValues[k] = s;
|
||||
adapter.addItem(itemBuilder.setTitle(entries[k]).createItem());
|
||||
if (s.equals(selectedValue)) {
|
||||
|
|
|
@ -392,11 +392,11 @@ public class ResourceManager {
|
|||
if (conf.exists()) {
|
||||
indexFileNames.put(f.getName(), dateFormat.format(conf.lastModified())); //$NON-NLS-1$
|
||||
}
|
||||
if (f.getName().contains("-tts")) {
|
||||
String lang = f.getName().replace("-tts", "");
|
||||
if (f.getName().contains("-tts-js")) {
|
||||
String lang = f.getName().replace("-tts-js", "");
|
||||
File jsConf = new File(f, lang + "_" + IndexConstants.TTSVOICE_INDEX_EXT_JS);
|
||||
if (jsConf.exists()) {
|
||||
indexFileNames.put(f.getName(), dateFormat.format(jsConf.lastModified()));
|
||||
indexFileNames.put(jsConf.getName(), dateFormat.format(jsConf.lastModified()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -325,12 +325,7 @@ public class JSTTSCommandPlayerImpl extends AbstractJSCommandPlayer {
|
|||
}
|
||||
|
||||
public static boolean isMyData(File voiceDir) {
|
||||
for (File f : voiceDir.listFiles()) {
|
||||
if (f.getName().contains(IndexConstants.TTSVOICE_INDEX_EXT_JS)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return voiceDir.getName().contains("-tts-js");
|
||||
}
|
||||
|
||||
private AlertDialog.Builder createAlertDialog(int titleResID, int messageResID,
|
||||
|
|
Loading…
Reference in a new issue