-
Notifications
You must be signed in to change notification settings - Fork 307
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
Supply phonetic road names to AVSpeechSynthesizer #624
Conversation
The fallback exists for a few reasons, including:
|
b098d1f
to
d08c3fd
Compare
e5e710b
to
9b8ad92
Compare
return | ||
} | ||
|
||
guard let url = awsTask.result else { | ||
super.speak(fallbackText, error: "No polly response") | ||
print("No polly response") | ||
speakWithoutPolly(for: routeProgress, userDistance: userDistance) | ||
return | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we cancel the task before creating a new one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, but I think we should address this issue in #661. Once that PR lands, I’ll rebase and do likewise here.
@@ -150,13 +152,14 @@ public class PollyVoiceController: RouteVoiceController { | |||
audioPlayer.volume = strongSelf.volume | |||
audioPlayer.play() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the return value of .play()
is discardable but I think we should observe it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#661 takes care of responding to the return value.
9b8ad92
to
2097f6d
Compare
@1ec5 is this still actionable? |
It would still be desirable to ensure that the AVSpeechSynthesizer fallback can handle phonetic names. AVSpeechSynthesizer isn’t going away; after all, Polly is optional, and it doesn’t support most of the languages we do, like Chinese. For AVSpeechSynthesizer to apply the phonetic names as string attributes, this library currently depends on OSRMTextInstructions.swift, hence all the merge conflicts. Relying on OSRMTextInstructions.swift would create some inconsistencies between the instructions spoken by Polly and those spoken by AVSpeechSynthesizer, due to extra processing we’re doing server-side outside of OSRM Text Instructions. A better solution would be for the Directions API to indicate the ranges within the plain-text instruction that should be pronounced a certain way. We can track that issue internally. I’ve also been leaving this PR around in order to track a refactoring of PollyVoiceController and RouteVoiceController, but I had you carry it out in #800. |
In the meantime, RouteVoiceController can search for the current route step’s |
2097f6d
to
9448372
Compare
Ready for review. |
This implementation currently relies on RouteStepFormatter which is getting removed in #767. |
Yeah let's do that. |
Yes, we should wait until after #767 lands. This PR still includes the modifications to RouteStepFormatter mainly so that the project can still build. But the cruxt of the change is in RouteVoiceController. |
Build speech strings as attributed strings in order to apply an IPA notation attribute to road names when spoken by AVSpeechSynthesizer.
9448372
to
1c5e549
Compare
All set. |
if Locale.preferredLocalLanguageCountryCode == "en-US" { | ||
utterance.voice = AVSpeechSynthesisVoice(identifier: AVSpeechSynthesisVoiceIdentifierAlex) | ||
// Alex can’t handle attributed text. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😢
This change provides AVSpeechSynthesizer with the same phonetic names that #622 provides Polly with. This way the AVSpeechSynthesizer fallback remains consistent with Polly in terms of its pronunciation of difficult names. The closer the two voices’ pronunciation, the less jarring it is when the fallback kicks in.
AVSpeechSynthesizer doesn’t support SSML; instead, on iOS 10 and above, it uses the native NSAttributedString type to hold attributes such as pronunciations. It turns out that the Alex voice (#612) does not support attributed strings, but it manages to correctly pronounce just about all the roads that are currently tagged with pronunciations anyways.
Depends on #621, mapbox/mapbox-directions-swift#174, and Project-OSRM/osrm-text-instructions.swift#39./cc @frederoni @bsudekum