Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No voice in 0.13 #922

Closed
chooble opened this issue May 7, 2018 · 29 comments
Closed

No voice in 0.13 #922

chooble opened this issue May 7, 2018 · 29 comments
Assignees
Labels
bug Defect to be fixed. release blocker Needs to be resolved before the release.

Comments

@chooble
Copy link

chooble commented May 7, 2018

Since 0.13 I am not getting any voice instructions.
I get my routes via an external server which gets the DirectionRoute from Mapbox. Then I process the json to create a DirectionRoute via the Builder. When using the builder I set the RouteOptions.language:

RouteOptions routeOptions = RouteOptions.builder()
                    .language("en")

And the DirectionRoute.voiceLanguage

directionsRoute = DirectionsRoute.builder()
                    .voiceLanguage("en")  //since 0.13 

I start the navigation this way:

navigationOptions = MapboxNavigationOptions.builder()
      .locale(Locale.forLanguageTag("en"))

NavigationViewOptions options = NavigationViewOptions.builder()
      .navigationOptions(navigationOptions)
      .directionsRoute(route)

navigationView.startNavigation(options);

I also tried different combinations of .language, .voiceLanguage and .locale. Also not setting them, but with no result.

There are no logs or errors describing what is happening.

Android API: 27 (OnePlus 5) and 24 (Samsung J5)
Mapbox Navigation SDK version: 0.13

Expected behavior

I expected that the navigationView would give me voice instruction without the need to change anything in code when transferring from 0.12 to 0.13

Actual behavior

No voice instructions

@danesfeder danesfeder added bug Defect to be fixed. navigation-ui labels May 7, 2018
@danesfeder danesfeder added this to the 0.14.0 milestone May 7, 2018
@devotaaabel devotaaabel self-assigned this May 11, 2018
@devotaaabel
Copy link
Contributor

Hi @chooble , were you using an awsPoolId previously? And are you using NavigationView or a custom view implementation?

@chooble
Copy link
Author

chooble commented May 14, 2018

Hi @devotaaabel! No I wasn't using awsPoolId previously and I'm using the default NavigationView.

@danesfeder
Copy link
Contributor

@chooble Can you add a MilestoneEventListener via NavigationViewOptions#milestoneEventListener?

After adding this, can you verify that VoiceInstructionMilestone is being sent via this callback as you travel along the route? Thanks, this will help us determine the source of the bug you're seeing.

@tonyc10
Copy link

tonyc10 commented May 16, 2018

I am also not getting voice in 0.13, and, like @chooble, am constructing my own DirectionsRoute based on a response from our own OSRM route server. It worked fine earlier and still works well except for the voice.

I've got nothing else to add at this point and have been drawn off to another urgent project for a few days -- I can spend some time troubleshooting with you early next week if it's still a mystery.

@danesfeder
Copy link
Contributor

@tonyc10 Do you mind trying the same suggestion #922 (comment)? Voice instructions are provided by the response from the directions API, so I think something may be going on with that.

@chooble
Copy link
Author

chooble commented May 16, 2018

@danesfeder Hi! I added the MilestoneEventListener and getting this output (instruction is in dutch):

I'm logging this:

@Override
public void onMilestoneEvent(RouteProgress routeProgress, String instruction, Milestone milestone) {
    Log.d("NavigationActivity", "\n");
    Log.d("NavigationActivity", "onMilestoneEvent, instruction:" + instruction);
    if(milestone.getInstruction()!=null) Log.d("NavigationActivity", "onMilestoneEvent, milestone.getInstruction:" + milestone.getInstruction().toString());
    Log.d("NavigationActivity", "onMilestoneEvent, milestone.getIdentifier:" + milestone.getIdentifier());
    if(progress!=null) Log.d("NavigationActivity", "onMilestoneEvent, milestone.isOccurring:" + milestone.isOccurring(progress, routeProgress));
    Log.d("NavigationActivity", "\n");

    progress = routeProgress;
}

And the output is:

05-16 18:01:21.404 2578-2578/ D/NavigationActivity: onMilestoneEvent, instruction:Over 700 meter, ga rechtsaf naar Universiteitsweg (N412) onMilestoneEvent, milestone.getInstruction:com.mapbox.services.android.navigation.v5.milestone.VoiceInstructionMilestone$1@3031b59 onMilestoneEvent, milestone.getIdentifier:1 onMilestoneEvent, milestone.isOccurring:false

05-16 18:01:39.384 2578-2578/ D/NavigationActivity: onMilestoneEvent, instruction:Ga rechtsaf naar Universiteitsweg (N412) onMilestoneEvent, milestone.getInstruction:com.mapbox.services.android.navigation.v5.milestone.VoiceInstructionMilestone$1@232e733 onMilestoneEvent, milestone.getIdentifier:1 onMilestoneEvent, milestone.isOccurring:false

05-16 18:01:39.389 2578-2578/ D/NavigationActivity: onMilestoneEvent, instruction: onMilestoneEvent, milestone.getIdentifier:2 onMilestoneEvent, milestone.isOccurring:false

05-16 18:01:47.405 2578-2578/ D/NavigationActivity: onMilestoneEvent, instruction:Neem Utrechtseweg (N237) in oostelijke richting, daarna links aanhouden op de splitsing naar Utrechtseweg (N237) onMilestoneEvent, milestone.getInstruction:com.mapbox.services.android.navigation.v5.milestone.VoiceInstructionMilestone$1@3d58648 onMilestoneEvent, milestone.getIdentifier:1 onMilestoneEvent, milestone.isOccurring:false

05-16 18:01:47.408 2578-2578/ D/NavigationActivity: onMilestoneEvent, instruction: onMilestoneEvent, milestone.getIdentifier:2 onMilestoneEvent, milestone.isOccurring:false

05-16 18:02:16.384 2578-2578/ D/NavigationActivity: onMilestoneEvent, instruction:Links aanhouden op de splitsing naar Utrechtseweg (N237), daarna ga linksaf naar Utrechtseweg (N225) onMilestoneEvent, milestone.getInstruction:com.mapbox.services.android.navigation.v5.milestone.VoiceInstructionMilestone$1@e7dbb29 onMilestoneEvent, milestone.getIdentifier:1 onMilestoneEvent, milestone.isOccurring:false

05-16 18:02:16.387 2578-2578/ D/NavigationActivity: onMilestoneEvent, instruction: onMilestoneEvent, milestone.getIdentifier:2 onMilestoneEvent, milestone.isOccurring:false

05-16 18:02:24.376 2578-2578/ D/NavigationActivity: onMilestoneEvent, instruction: onMilestoneEvent, milestone.getIdentifier:2 onMilestoneEvent, milestone.isOccurring:false

@tonyc10
Copy link

tonyc10 commented May 16, 2018

I used @chooble's logging code and looks like my results are the same:

Turn right onto East 36th Street
onMilestoneEvent, milestone.getInstruction:com.mapbox.services.android.navigation.v5.milestone.VoiceInstructionMilestone$1@b08c6dc
onMilestoneEvent, milestone.getIdentifier:1

onMilestoneEvent, instruction:
onMilestoneEvent, milestone.getIdentifier:2
onMilestoneEvent, milestone.isOccurring:false

onMilestoneEvent, instruction:Turn left onto 46th Avenue South
onMilestoneEvent, milestone.getInstruction:com.mapbox.services.android.navigation.v5.milestone.VoiceInstructionMilestone$1@d731fdd
onMilestoneEvent, milestone.getIdentifier:1
onMilestoneEvent, milestone.isOccurring:false

onMilestoneEvent, instruction:
onMilestoneEvent, milestone.getIdentifier:2
onMilestoneEvent, milestone.isOccurring:false

onMilestoneEvent, instruction:Turn left onto East 46th Street (CR 46)
onMilestoneEvent, milestone.getInstruction:com.mapbox.services.android.navigation.v5.milestone.VoiceInstructionMilestone$1@590a6eb
onMilestoneEvent, milestone.getIdentifier:1
onMilestoneEvent, milestone.isOccurring:false

onMilestoneEvent, instruction:
onMilestoneEvent, milestone.getIdentifier:2
onMilestoneEvent, milestone.isOccurring:false

onMilestoneEvent, instruction:Continue onto Ford Parkway (CR 42)
onMilestoneEvent, milestone.getInstruction:com.mapbox.services.android.navigation.v5.milestone.VoiceInstructionMilestone$1@b8de496
onMilestoneEvent, milestone.getIdentifier:1
onMilestoneEvent, milestone.isOccurring:false
 
onMilestoneEvent, instruction:
onMilestoneEvent, milestone.getIdentifier:2
onMilestoneEvent, milestone.isOccurring:false

onMilestoneEvent, instruction:Turn right
onMilestoneEvent, milestone.getInstruction:com.mapbox.services.android.navigation.v5.milestone.VoiceInstructionMilestone$1@9dd0517
onMilestoneEvent, milestone.getIdentifier:1
onMilestoneEvent, milestone.isOccurring:false

@danesfeder
Copy link
Contributor

@chooble @tonyc10 Okay great, thank you both. So this means valid voice instructions are being fired, but something may be happening with the speech player code on our side. We will look into this - thanks for the help.

@akitchen akitchen added the release blocker Needs to be resolved before the release. label May 21, 2018
@danesfeder danesfeder modified the milestones: 0.14.0, 0.15.0 May 30, 2018
@danesfeder
Copy link
Contributor

danesfeder commented May 31, 2018

Hey @chooble @tony-cj can you both test your issues again with our newest release of the SDK 0.14.0 - please note - there are API breaking changes: https://github.com/mapbox/mapbox-navigation-android/releases/tag/v0.14.0

@chooble
Copy link
Author

chooble commented Jun 1, 2018

I don't seem to get it working. I've set the .language and .voiceUnit in RouteOptions like you described in the release notes. Also the .voiceLanguage in de DirectionRoute builder.

@skienzl
Copy link

skienzl commented Jun 4, 2018

@danesfeder i think the error could be related to a missing error case during the download of the mapbox voice file: MapboxSpeechPlayer.java

If the response is not successful (if (response.isSuccessful())) there is no error callback.

@tonyc10
Copy link

tonyc10 commented Jun 4, 2018 via email

@devotaaabel
Copy link
Contributor

@skienzl I'll get that in the next release.

@chooble
Copy link
Author

chooble commented Jun 18, 2018

@devotaaabel @danesfeder , do you have an ETA for the solution? Did you already found cause of the problem?

@devotaaabel
Copy link
Contributor

@chooble we have still been unable to reproduce your error, but I did add an extra call to retry using native TTS if MapboxSpeech fails here: 01aefe0. I also have a PR open right now to log errors to hopefully help you find your issue if the latter doesn't help: #1036. There will most likely be a release this week including both.

@Guardiola31337
Copy link
Contributor

Hey @chooble 👋 0.15.0 was released including @devotaaabel's above-mentioned changes.

Could you retest your issues again with our newest release of the SDK 0.15.0?

cc @tonyc10 @skienzl

@tonyc10
Copy link

tonyc10 commented Jun 25, 2018 via email

@tonyc10
Copy link

tonyc10 commented Jun 25, 2018 via email

@chooble
Copy link
Author

chooble commented Jun 25, 2018

@Guardiola31337 Great! It's working now! 👍 🥇

@danesfeder
Copy link
Contributor

@tonyc10 Unfortunately this is a known issue and is being addressed in #1054. Thanks for the feedback and glad to hear we are working towards a solution here.

@Guardiola31337
Copy link
Contributor

Going to go ahead and close this as OP should be fixed since 0.15.0 (we have also released 0.16.0-beta.1 afterwards) - if you find the issue persists, please feel free to re-open and we will continue to dig on this issue. Thanks for bringing this to our attention!

cc @chooble @tony-cj @skienzl

@JFDionne
Copy link

JFDionne commented Jul 30, 2019

@tonyc10 @chooble
Hi, I know this is a old thread, but any chance you can share how you do the conversion of OSRM to mapbox?

@tonyc10
Copy link

tonyc10 commented Jul 31, 2019

@JFDionne

It's been a year since I thought about this (or looked at this app) but I can share some code. Looking over this, it was pretty thick stuff — the key was migrating the polylines to version 6.

From our OSRM server, I got a response that fit into this Kotlin data class:

data class RouteResponse(
        val code: String,
        val routes: Array<JsonObject>,
        val waypoints: Array<Waypoint>
)

With Waypoint being:

data class Waypoint(
        val name: String,
        val hint: String,
        val location: Array<Double>
)

I got one or two objects in the routes array, depending on my request, With each one of these, I did the following conversion, using mapbox, v5, classes RouteOptions and DirectionsRoute, com.mapbox.geojson.utils.PolylineUtils, and
a JsonObject extension function I wrote called toDirectionsRoute

fun JsonObject.toDirectionsRoute(options: RouteOptions): DirectionsRoute {

    this.migratePolylinesTo6()

    val tempRoute = DirectionsRoute.fromJson(this.toString())
    return  tempRoute
            .toBuilder()
            .routeOptions(options)
            .build()
}

fun JsonObject.migratePolylinesTo6() {

    fun switchGeometryTo6(jsonObj: JsonObject): List<Point> {

        val geometryJson = jsonObj.get("geometry") ?: throw IllegalArgumentException(
                "Attempt to modify geometry on Json route object with no geometry.  Does this Json object represent an OSMR route?")

        // decode / recode
        try {
            val points = PolylineUtils.decode(geometryJson.asString, 5)
            val geometryAmended = PolylineUtils.encode(points, 6)
            // put back corrected encoding
            jsonObj.addProperty("geometry", geometryAmended)
            return points
        }
        catch (e: Exception) {
            throw IllegalArgumentException(
                    "Unable to modify geometry on JsonObject -- Does this object represent an OSMR route?")
        }
    }

    val legsJson = get("legs") ?: throw IllegalArgumentException(
            "Attempt to modify geometry on Json route object with no legs.  Does this Json object represent an OSMR route?")
    if (! legsJson.isJsonArray) throw IllegalArgumentException(
            "Attempt to modify geometry on Json route where legs element not an array.  Does this Json object represent an OSMR route?")

    val legsArray = legsJson.asJsonArray
    val allThePoints = mutableListOf<Point>()

    for (leg in legsArray) {

        val stepsJson = leg.asJsonObject.get("steps")
        if (stepsJson == null) throw IllegalArgumentException(
                "Attempt to modify steps geometry on Json route object with no steps.  Does this Json object represent an OSMR route?")
        if (! stepsJson.isJsonArray) throw IllegalArgumentException(
                "Attempt to modify steps geometry on Json route where steps element not an array.  Does this Json object represent an OSMR route?")

        val stepsArray = stepsJson.asJsonArray


        for (stepObj in stepsArray) {
            allThePoints.addAll(
                    switchGeometryTo6(stepObj.asJsonObject))
        }
    }
    val geometryAmended = PolylineUtils.encode(allThePoints, 6)
    // put back corrected encoding
    addProperty("geometry", geometryAmended)

}

Good luck!

@JFDionne
Copy link

@tonyc10

Thanks, but I’m curious, how did you build the var options (routeOptions)

Osrm can now return polyline6.

@JFDionne
Copy link

@tonyc10
And I'm wondering, the way you are doing it, it was filling the voiceInstructions and bannerInstruction ?

@tonyc10
Copy link

tonyc10 commented Jul 31, 2019 via email

@JFDionne
Copy link

@tonyc10
Sorry, it was more a question :) with your code do the voiceInstructions got filled?

I'll try your code, but what was the value of BuildConfig.BASE_URL? The url of your osrm server? or api.mapbox.com?

@tonyc10
Copy link

tonyc10 commented Aug 1, 2019 via email

@JFDionne
Copy link

JFDionne commented Aug 1, 2019

@tonyc10
Strange, because I can't have the voice working since the voiceInstructions is null.

Thanks you for all those information :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defect to be fixed. release blocker Needs to be resolved before the release.
Projects
None yet
Development

No branches or pull requests

8 participants