1

I'm developing an iOS project in Xcode using the Here SDK. I'm using the Premium Edition (v3.17). In the 'Settings' screen of my app users can choose the 'voice' that's being used by the SDK (I get that list through NMAVoiceCatalog voicePackages property.)

I would like to play a small sentence when users select a voice (E.g. "Turn right now"), so that they get immediate feedback if they like that voice or not.

Now, I know that NMAAudioManager has a method playOutput which will play either a prerecorded sound file or a tts string. That's great, but now for my question:

How can I make sure the NMAAudioManager.sharedInstance().play( method, plays with the same voice as NMANavigationManager?

It's important to note the difference between tts voices and pre-recorded voices here.

Pre-recorded voices I imagine this is a resource package of pre-recorded mp3 or wav files. I just need to know the url of a sound file or sound files that I could use. E.g. the sound file(s) for the sentence "turn right now". I imagine the filename is the same for all voices in all languages (Not sure though). Is there a list of available sound files and their names? Or could you give me a few sound file names (and URL's within the SDK) so I can play them as test sound through NMAAudioManager?

tts voices For those voices I could create a sentence in each supported language and feed that to the NMAAudioManager.sharedInstance().play( method. I would create an 'NMATTSAudioOutput' for that sentence. However, I need to set the correct AVSpeechSynthesisVoice to the voice property of that 'NMATTSAudioOutput' instance. With correct I mean the same AVSpeechSynthesisVoice that the NMANavigationManager is using. I've tried using AVSpeechSynthesisVoice(language: voicePackage.languageCode) but that doesn't give the same AVSpeechSynthesisVoice than the one that NMANavigationManager uses. E.g. English UK tts voicePackage plays with English US AVSpeechSynthesisVoice. Could you share with me how the NMANavigationManager chooses the AVSpeechSynthesisVoice from NMAVoicePackage properties?

guido
  • 2,792
  • 1
  • 21
  • 40

1 Answers1

0

Pre-recorded voices

The best way to get a sample is to use HERE SDK. As voice service URL can be changed in future. Install voice package (id:83101) from catalog and find wav files in your app directory:

/Documents/heremaps/diskcache/voices/es-MX_male/mexican_male/g5turns_left_002e

HERE SDK initialises AVAudioPlayer with wav file content and calls play() function.

TTS voices

NMANavigationManager uses something similar:

NMATTSAudioOutput *output = [NMATTSAudioOutput audioOutputWithText:text];
output.source = NMAAudioOutputSourceGuidance;
output.voice = [AVSpeechSynthesisVoice voiceWithLanguage:self.voicePackage.languageCode];
output.speechRate = AVSpeechUtteranceDefaultSpeechRate;
output.pitchMultiplier = 1.0;

[[NMAAudioManager sharedAudioManager] playOutput:output];

Note, there are many lua scripts and algorithms behind the scene which makes voice guidance smooth and advanced.

dashchak
  • 170
  • 6
  • I had this, but it doesn't work. For example, if I select the voicePackage English (UK) announced street names, the code above will select the same voice as when I select English (US) announced street names. Somehow, when I set the voicePackage NMANavigationManager the AVSpeechSynthesisVoice is selected differently. – guido May 11 '21 at 17:49
  • So, packageId 206 - English (US) - has languageCode "en-US". When I select this voice, NMANavigationmanager and NMAAudioManager have the same voice. packageId 201 - English (UK) - has languageCode "en". When I select this voice, NavManager and AudioManager have a DIFFERENT voice. NavManager has the correct one (a UK accent) but AudioManager has the same US voice I get with language code "en-US". Somehow NavManager knows that "en" should be "en-UK" however I don't see any NMAVoicePackage property with that value. How does NavManager derive the correct language code from NMAVoicePackage? – guido May 11 '21 at 22:41
  • For pre-recorded voices I'm running into a similar problem. How can I find out the directory name (in your example es-MX_male)? It's not always straight forward. E.g. for packageId 405000 - Espanol (América Latina) the language code is es-419, but the directory that's created is named es-CO_female. Where is that name coming from? – guido May 11 '21 at 23:37
  • I guess it would be really really nice if either NMAAudioManager or NMANavigationManager had a function "playDemoInstruction(forVoicePackage: NMAVoicePackage)" using exactly the same voice as NMANavigatiorManager uses when playing actual voice guidance instructions. If there is any easy way to do this, without analyzing file structure, parsing lua files, etc. that would be awesome. – guido May 12 '21 at 15:11
  • Thanks for detailed explanation. NMANavigationManager uses languageCode of its own voicePackage property. If missing, uses private voiceSkin language code API. Pre-recorded voice structures can vary, they are installed packages downloaded from Voice server. So you will have manually download all required languages and find needed wavs. Agree it is a dirty workaround for missing API. If you need direct link to packages or "playDemoInstruction" feature, please contact HERE representative for details. – dashchak May 12 '21 at 17:48