NSAttributedString.Key.accessibilitySpeechIPANotation in substrings

Hi,

I am trying to improve the pronunciation of a couple of words within a large block of text for VoiceOver users by applying the .accessibilitySpeechIPANotation key to a range in an NSAttributedString.

However it appears that the notations are ignored when the range is in the middle of the text. It only seems to apply if the attributed range is at the end of a sentence.

For example, using this code sample:

let s: String = "live radio"
let ipa = "ˈla͡ɪv"

let attributedString = NSMutableAttributedString(string: s)

let range = attributedString.string.range(of: "live")

attributedString.addAttributes(

    [.accessibilitySpeechIPANotation: ipa],

    range: NSRange(range!, in: attributedString.string))

label.attributedText = attributedString

the label will be read incorrectly ("live" rhyming with "give").

However if s = "listen on radio live" or "listen on radio live. today!" then it's read correctly.

Then if I change it to `"listen on radio live today!", it's wrong again.

What am I missing? Is there some sort of "end of word" symbol I need to include in my IPA notation?

(This is on iOS 15. It seems to work like I expect on iOS 12 FWIW).

  • Did you file a bug about this? Can you file one with a sample project and post the number here?

  • Hi Frameworks Engineer, I have submitted FB9646712 with a sample project.

Add a Comment