In Daniel Devesa Derksen-Staats' book 'Developing Accessible iOS Apps', the following example is included to show how IPA (International Phonetic Alphabet) notation can be used to specify the VoiceOver pronunciation:
let ipaAttributedText = NSMutableAttributedString(string: "Paella is a Valencian rice dish")
let ipaRange = ipaAttributedText.string.range(of: "Paella")!
ipaAttributedText.addAttributes([.accessibilitySpeechIPANotation: "paˈeʎa"], range: NSRange(ipaRange, in: ipaAttributedText.string))
ipaLabel.attributedText = ipaAttributedText
// Excerpt From: Daniel Devesa Derksen-Staats. “Developing Accessible iOS Apps.” Apple Books.
The result, at least in iOS 15, is clearly not what was intended. The accessibility label, as it appears in the VoiceOver caption is "ipa, Paellais a Valencian rice dish" - and this is how it is read. The VoiceOver synth's pronunciation is roughly 'paylace', that is, it is completely ignoring the phonetic transcription (I can replace "paˈeʎa" with literally anything, the pronunciation doesn't change). Also any whitespace between the target word and what follows is deleted in the caption and pronunciation. In the console, I can output the value of the ipaAttributedText, everything there looks ok:
Paella{
UIAccessibilitySpeechAttributeIPANotation = "pa\U02c8e\U028ea";
} is a Valencian rice dish{
}
This blog post contains a very similar example, differing only in that it sets the .accessibilityAttributedLabel
instead of .attributedText
, but it fails in the same way.
Is this broken on iOS 15? or is there something else needed to make this work?