mapbox-navigation-android icon indicating copy to clipboard operation
mapbox-navigation-android copied to clipboard

How to play chinese text by MapboxVoiceInstructionsPlayer?

Open KayHung opened this issue 3 years ago • 16 comments

How to play chinese text by MapboxVoiceInstructionsPlayer?

my voiceInstructionsPlayer

voiceInstructionsPlayer = MapboxVoiceInstructionsPlayer( this, getMapboxAccessTokenFromResources(), Locale.SIMPLIFIED_CHINESE.language )

Android API: MapboxVoiceInstructionsPlayer Mapbox Navigation SDK version: mapbox-maps-android-android-v10.0.0-beta.18

KayHung avatar Jun 24 '21 10:06 KayHung

@KayHung thanks for reporting this issue. I'm going to summarize what I've tested and observed so far so the team has more information.

Testing with our example activity I get the correct voice instructions when testing with English, Portuguese, and Japanese. When I configure the MapboxSpeechApi, MapboxVoiceInstructionsPlayer and the RouteOptions for Locale.SIMPLIFIED_CHINESE.language. I can see (what looks like) Chinese is returned in the DirectionsRoute and the voice instructions going to the speech player are Chinese with the street names in English (since i'm testing in the U.S.). I only hear the English spoken. There seems to be a blank pause where the Chinese should be spoken.

However, if I pass a sentence in Chinese or other language to the MapboxVoiceInstructionsPlayer directly as on this line in the activity . Then I hear Chinese.

            voiceInstructionsPlayer.play(
                SpeechAnnouncement.Builder("Test hybrid speech player.").build(),
                voiceInstructionsPlayerCallback
            )

Sill investigating...

cafesilencio avatar Jun 29 '21 20:06 cafesilencio

cc'ing @1ec5 for visibility and any thoughts on the topic.

Guardiola31337 avatar Jun 29 '21 21:06 Guardiola31337

It looks like there might be something wrong with the mp3 file that gets created. If I omit the file reference in MapboxSpeechApi I hear the Chinese instructions.

cafesilencio avatar Jun 29 '21 22:06 cafesilencio

Seems to be a problem with the file generated by the speech service. Check out these two URLs. Note: the tokens are omitted.

Not sure who to forward this issue to.

Chinese https://api.mapbox.com/voice/v1/speak/<amazon:effect name="drc">出发向北,驶入Main Street,随后左转,驶入West 19th<%2Fsay-as> Street<%2Fprosody><%2Famazon:effect><%2Fspeak>?textType=ssml&language=zh&access_token=

URL encoded: https://api.mapbox.com/voice/v1/speak/%3Cspeak%3E%3Camazon:effect%20name=%22drc%22%3E%3Cprosody%20rate=%221.08%22%3E%E5%87%BA%E5%8F%91%E5%90%91%E5%8C%97%EF%BC%8C%E9%A9%B6%E5%85%A5Main%20Street%EF%BC%8C%E9%9A%8F%E5%90%8E%E5%B7%A6%E8%BD%AC%EF%BC%8C%E9%A9%B6%E5%85%A5West%20%3Csay-as%20interpret-as=%22address%22%3E19th%3C%2Fsay-as%3E%20Street%3C%2Fprosody%3E%3C%2Famazon:effect%3E%3C%2Fspeak%3E?textType=ssml&language=zh&access_token=

Japanese https://api.mapbox.com/voice/v1/speak/<amazon:effect name="drc">Main Streetを北方向です。。その先400フィートで左方向です。その先West 19th Streetです。<%2Fprosody><%2Famazon:effect><%2Fspeak>?textType=ssml&language=ja&access_token=

URL encoded: https://api.mapbox.com/voice/v1/speak/%3Cspeak%3E%3Camazon:effect%20name=%22drc%22%3E%3Cprosody%20rate=%221.08%22%3EMain%20Street%E3%82%92%E5%8C%97%E6%96%B9%E5%90%91%E3%81%A7%E3%81%99%E3%80%82%E3%80%82%E3%81%9D%E3%81%AE%E5%85%88400%E3%83%95%E3%82%A3%E3%83%BC%E3%83%88%E3%81%A7%E5%B7%A6%E6%96%B9%E5%90%91%E3%81%A7%E3%81%99%E3%80%82%E3%81%9D%E3%81%AE%E5%85%88West%2019th%20Street%E3%81%A7%E3%81%99%E3%80%82%3C%2Fprosody%3E%3C%2Famazon:effect%3E%3C%2Fspeak%3E?textType=ssml&language=ja&access_token=

cafesilencio avatar Jun 29 '21 23:06 cafesilencio

Not sure who to forward this issue to.

@mapbox/navigation-api @kshehadeh @danpat could you look into this when you have a chance? 🙏

Guardiola31337 avatar Jun 30 '21 14:06 Guardiola31337

@mandeepsandhu @dgearhart Anything come to mind with this issue?

kshehadeh avatar Jun 30 '21 14:06 kshehadeh

@cafesilencio Do you have any updates about this issue?

KayHung avatar Jul 07 '21 07:07 KayHung

@KayHung Other than confirming your initial bug report I don't have any updates at this time. The team that manages the service that produces the audio will be investigating.

@mandeepsandhu @dgearhart Do either of you have any updates?

cafesilencio avatar Jul 07 '21 15:07 cafesilencio

Where does Locale.SIMPLIFIED_CHINESE.language come from? language=zh is incorrect. It should be language=cmn https://api.mapbox.com/voice/v1/speak/%3Cspeak%3E%3Camazon:effect%20name=%22drc%22%3E%3Cprosody%20rate=%221.08%22%3E%E5%87%BA%E5%8F%91%E5%90%91%E5%8C%97%EF%BC%8C%E9%A9%B6%E5%85%A5Main%20Street%EF%BC%8C%E9%9A%8F%E5%90%8E%E5%B7%A6%E8%BD%AC%EF%BC%8C%E9%A9%B6%E5%85%A5West%20%3Csay-as%20interpret-as=%22address%22%3E19th%3C%2Fsay-as%3E%20Street%3C%2Fprosody%3E%3C%2Famazon:effect%3E%3C%2Fspeak%3E?textType=ssml&language=cmn&access_token=

browndp08 avatar Jul 08 '21 13:07 browndp08

Locale.SIMPLIFIED_CHINESE.language comes from java.util.Locale. Where does cmn come from? Is it defined in a constant somewhere?

Our documentation here: https://docs.mapbox.com/api/navigation/directions/#instructions-languages indicates Chinese (Simplified) is zh-Hans.

cafesilencio avatar Jul 08 '21 15:07 cafesilencio

Our documentation looks to be incorrect. cmn comes from AWS docs - https://docs.aws.amazon.com/polly/latest/dg/ph-table-mandarin.html

browndp08 avatar Jul 08 '21 16:07 browndp08

When requesting a route, the RouteOptions takes a language parameter. A value of "cmn" for the RouteOptions doesn't return Chinese in the DirectionsRoute but a value of Locale.SIMPLIFIED_CHINESE.language will. Having to pass a different language value (cmn) for the speech API doesn't make sense IMO. I think this is more than a documentation issue. The speech API should take the same value as the RouteOptions.

cafesilencio avatar Jul 08 '21 17:07 cafesilencio

l. Having to pass a different language value (cmn) for the speech API doesn't make sense IMO.

I agree and I would expect Locale.SIMPLIFIED_CHINESE to work. I'll cut a ticket to tweak api-voice to handle that.

browndp08 avatar Jul 08 '21 19:07 browndp08

I looked at the list of language codes between the Amazon link you referred to an the Mapbox documentation. Arabic looked like it might also be affected by this.

cafesilencio avatar Jul 08 '21 21:07 cafesilencio

Support for Chinese is broken due to mapbox/locale-utils#7, and support for Arabic is also broken due to mapbox/locale-utils#9.

Our documentation looks to be incorrect.

The Voice API uses locale-utils to match the written language codes from text instructions to spoken language codes expected by text-to-speech engines. The API documentation is correct because it only attempts to list the written language code for written instructions (that happen to be read aloud).

1ec5 avatar Oct 05 '21 15:10 1ec5

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 17 '22 06:04 stale[bot]