Merge pull request #5951 from osmandapp/js_voice_routing

Prolog will be used if there is no js file
This commit is contained in:
vshcherb 2018-08-29 11:13:51 +02:00 committed by GitHub
commit d4737f496c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 24 deletions

View file

@ -219,7 +219,8 @@ public class LocalIndexHelper {
if (voiceDir.canRead()) {
//First list TTS files, they are preferred
for (File voiceF : listFilesSorted(voiceDir)) {
if (voiceF.isDirectory() && JSTTSCommandPlayerImpl.isMyData(voiceF)) {
if (voiceF.isDirectory() && (JSTTSCommandPlayerImpl.isMyData(voiceF)
|| TTSCommandPlayerImpl.isMyData(voiceF))) {
LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.TTS_VOICE_DATA, voiceF, backup, app);
updateDescription(info);
result.add(info);
@ -230,7 +231,8 @@ public class LocalIndexHelper {
//Now list recorded voices
for (File voiceF : listFilesSorted(voiceDir)) {
if (voiceF.isDirectory() && JSMediaCommandPlayerImpl.isMyData(voiceF)) {
if (voiceF.isDirectory() && (JSMediaCommandPlayerImpl.isMyData(voiceF)
|| MediaCommandPlayerImpl.isMyData(voiceF))) {
LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.VOICE_DATA, voiceF, backup, app);
updateDescription(info);
result.add(info);

View file

@ -46,6 +46,7 @@ import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.voice.JSMediaCommandPlayerImpl;
import net.osmand.plus.voice.JSTTSCommandPlayerImpl;
import net.osmand.plus.voice.MediaCommandPlayerImpl;
import net.osmand.plus.voice.TTSCommandPlayerImpl;
import net.osmand.router.GeneralRouter;
import net.osmand.router.GeneralRouter.RoutingParameter;
import net.osmand.util.Algorithms;
@ -341,7 +342,8 @@ public class RoutePreferencesMenu {
if (extStorage.exists()) {
for (File f : extStorage.listFiles()) {
if (f.isDirectory()) {
if (JSMediaCommandPlayerImpl.isMyData(f) || JSTTSCommandPlayerImpl.isMyData(f)) {
if (JSMediaCommandPlayerImpl.isMyData(f) || JSTTSCommandPlayerImpl.isMyData(f)
|| MediaCommandPlayerImpl.isMyData(f) || TTSCommandPlayerImpl.isMyData(f)) {
setFiles.add(f.getName());
}
}

View file

@ -389,6 +389,10 @@ public class ResourceManager {
if (f.isDirectory()) {
String lang = f.getName().replace("-tts", "");
File conf = new File(f, lang + "_" + IndexConstants.TTSVOICE_INDEX_EXT_JS);
if (!conf.exists()) {
conf = new File(f, "_config.p");
conf = conf.exists() ? conf : new File(f, "_ttsconfig.p");
}
if (conf.exists()) {
indexFileNames.put(f.getName(), dateFormat.format(conf.lastModified())); //$NON-NLS-1$
}

View file

@ -60,7 +60,7 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
protected static final String DELAY_CONST = "delay_";
private static final String WEAR_ALERT = "WEAR_ALERT";
/** Must be sorted array! */
private final int[] sortedVoiceVersions;
private int[] sortedVoiceVersions;
private static AudioFocusHelper mAudioFocusHelper;
protected String language = "";
protected int streamType;
@ -78,24 +78,23 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
this.ctx = ctx;
this.streamType = ctx.getSettings().AUDIO_STREAM_GUIDANCE.getModeValue(applicationMode);
// if (!ctx.getSettings().USE_JS_VOICE_GUIDANCE.get()) {
// if (log.isInfoEnabled()) {
// log.info("Initializing prolog system : " + (System.currentTimeMillis() - time)); //$NON-NLS-1$
// }
// try {
// prologSystem = new Prolog(getLibraries());
// } catch (InvalidLibraryException e) {
// log.error("Initializing error", e); //$NON-NLS-1$
// throw new RuntimeException(e);
// }
// init(voiceProvider, ctx.getSettings(), configFile);
// final Term langVal = solveSimplePredicate("language");
// if (langVal instanceof Struct) {
// language = ((Struct) langVal).getName();
// }
// }
if (voiceProvider != null) {
initVoiceDir(voiceProvider);
initVoiceDir(voiceProvider);
if (voiceDir != null && (MediaCommandPlayerImpl.isMyData(voiceDir) || TTSCommandPlayerImpl.isMyData(voiceDir))) {
if (log.isInfoEnabled()) {
log.info("Initializing prolog system : " + (System.currentTimeMillis() - time)); //$NON-NLS-1$
}
try {
prologSystem = new Prolog(getLibraries());
} catch (InvalidLibraryException e) {
log.error("Initializing error", e); //$NON-NLS-1$
throw new RuntimeException(e);
}
init(voiceProvider, ctx.getSettings(), configFile);
final Term langVal = solveSimplePredicate("language");
if (langVal instanceof Struct) {
language = ((Struct) langVal).getName();
}
} else {
language = voiceProvider.replace("-tts", "").replace("-formal", "");
}
}
@ -147,8 +146,6 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
private void init(String voiceProvider, OsmandSettings settings, String configFile) throws CommandPlayerException {
prologSystem.clearTheory();
voiceDir = null;
initVoiceDir(voiceProvider);
// see comments below why it is impossible to read from zip (don't know
// how to play file from zip)