当用户处于偏离路线状态时,如何在“ Mapbox导航”中添加“重新计算”语音?

时间:2019-07-08 14:02:59

标签: android navigation mapbox voice mapbox-android

我需要通知用户语音离开路线时。我不能使语音公告说“正在重新计算”。

我尝试创建了SpeechAnnouncement,甚至尝试创建ssml标签,但无济于事。

    navigationView.retrieveMapboxNavigation().addOffRouteListener(new OffRouteListener() {

            boolean isOffRouteAnnounced = false;

            @Override
            public void userOffRoute(Location location) {
                if (!isOffRouteAnnounced) {
                    if (PreferencesManager.getInstance().getLanguage().equals("hu")) {
                        saySomething("Újratervezés");
                    } else {
                        willVoice(SpeechAnnouncement.builder().announcement("Recalculating").ssmlAnnouncement("<speak><amazon:effect name=\"drc\"><prosody rate=\"1.08\">Recalculating</prosody></amazon:effect></speak>").build());
                    }
                    isOffRouteAnnounced = true;
                } else {
                    //handle the multiple rerouting requests, say it only once in 5 seconds
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            isOffRouteAnnounced = false;
                        }
                    }, 5000);
                }
            }
        });

    @Override
    public SpeechAnnouncement willVoice(SpeechAnnouncement speechAnnouncement) {
        if (PreferencesManager.getInstance().getLanguage().equals("hu")) {
            saySomething(TranslatorUtil.getTranslationWithSeparator(speechAnnouncement.announcement().toLowerCase()));
            return null;
        } else {
            return speechAnnouncement;
        }
    }

预期结果: -当offRoute检测触发时,语音会说“正在重新计算”。 实际结果: -会触发offRoute检测,但是willVoice什么也没说。

0 个答案:

没有答案