Closed 1ec5 closed 6 years ago
Once https://github.com/mapbox/mapbox-navigation-ios/pull/617 is live, do you think there is much of a use case? Off the cuff, I think this would be a rather big lift for us.
Once mapbox/mapbox-navigation-ios#617 is live, do you think there is much of a use case?
Yes. There will remain some (hopefully niche) reasons to use something other than Polly via the Mapbox Speech API:
Whatever the case, we don’t have to get too fancy with this example. Just take MapboxVoiceController and replace all the code specific to the Mapbox Speech API with a comment explaining what TTS functionality to hook into. It can be up to the developer to understand the third-party library; we don’t have to advertise a particular library.
a developer write an adapter for a text-to-speech engine of their choice by subclassing it and overriding a few methods, using
PollyVoiceController
as a model.
As of mapbox/mapbox-navigation-ios#617, the developer would subclass RouteVoiceController
, overriding didPassSpokenInstructionPoint(_:)
(to prefetch audio from the network, if desired) and speak(_:)
(to play the audio). To keep things simple, the example would probably assume the audio files have been bundled with the application, so the subclass wouldn’t need to override didPassSpokenInstructionPoint(_:)
; all it would do is override speak(_:)
to create an AVAudioPlayer from the file and play it.
The override would look something like this:
I suppose we could also factor out an AudioPlayerVoiceController or something to make this task easier, since methods like duckAudio()
are private.
Plenty of text-to-speech engines besides Amazon Polly support SSML. Here’s a partial list.
RouteVoiceController
isopen
, so a developer write an adapter for a text-to-speech engine of their choice by subclassing it and overriding a few methods, usingPollyVoiceController
as a model. But an example would make it much easier for someone to do that./cc @bsudekum @ericdeveloper @captainbarbosa