From dbfad1e88b74d0086897eab5926fcc0840346c18 Mon Sep 17 00:00:00 2001 From: sonora Date: Tue, 20 Jun 2017 18:26:47 +0200 Subject: [PATCH] Pass all test strings through our character replacement method --- .../net/osmand/plus/development/TestVoiceActivity.java | 8 ++++++++ OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java index 97704586ae..77ae072040 100644 --- a/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java +++ b/OsmAnd/src/net/osmand/plus/development/TestVoiceActivity.java @@ -25,6 +25,7 @@ import net.osmand.plus.voice.AbstractPrologCommandPlayer; import net.osmand.plus.voice.TTSCommandPlayerImpl; import net.osmand.plus.voice.CommandBuilder; import net.osmand.plus.voice.CommandPlayer; +import net.osmand.plus.routing.VoiceRouter; import net.osmand.util.Algorithms; import java.io.File; @@ -190,7 +191,14 @@ public class TestVoiceActivity extends OsmandActionBarActivity { } return new Struct(""); } + private Term street(CommandPlayer p, String name, String ref, String destName, String currentName) { + // Pass all test strings through our character replacement method + ref = VoiceRouter.getSpeakablePointName(ref); + name = VoiceRouter.getSpeakablePointName(name); + destName = VoiceRouter.getSpeakablePointName(destName); + currentName = VoiceRouter.getSpeakablePointName(currentName); + if(p.supportsStructuredStreetNames()) { Struct next = new Struct(new Term[] { getTermString(ref), getTermString(name), diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index 3fd91ca894..b1ac9d9a85 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -618,18 +618,18 @@ public class VoiceRouter { return empty; } - public String getSpeakablePointName(String pn) { - // Replace characters which may produce unwanted tts sounds: + public static String getSpeakablePointName(String pn) { + // Replace characters which may produce unwanted TTS sounds: if (pn != null) { pn = pn.replace('-', ' '); pn = pn.replace(':', ' '); pn = pn.replace(";", ", "); // Trailing blank prevents punctuation being pronounced. Replace by comma for better intonation. pn = pn.replace("/", ", "); // Slash is actually pronounced by many TTS engines, ceeating an awkward voice prompt, better replace by comma. if ((player != null) && (!player.getLanguage().equals("de"))) { - pn = pn.replace("\u00df", "ss"); // Helps non-German tts voices to pronounce German Strasse (=street) + pn = pn.replace("\u00df", "ss"); // Helps non-German TTS voices to pronounce German Straße (=street) } if ((player != null) && (player.getLanguage().startsWith("en"))) { - pn = pn.replace("SR", "S R"); // Avoid SR (as for State Route or Strada Regionale) be pronounced as "Senior" in English tts voice + pn = pn.replace("SR", "S R"); // Avoid SR (as for State Route or Strada Regionale) be pronounced as "Senior" in English TTS voice pn = pn.replace("Dr.", "Dr "); // Avoid pause many English TTS voices introduce after period } }