Day 9

IPA for homographs and your app name

27 May 2022

accessibilitySpeechIPANotation is sometimes handy in English where a word is spelled the same but pronounced differently depending of the context. Some examples are: live, read... Or you may want to correct how VoiceOver pronounces your app's name!

Example shows how you can specify the correct pronunciation for the text “Most read” and for the word “Live” in the context of direct broadcasting, using the IPA notation. The code sets an accessibilityAttributeLabel to the UILabel (or UIView) with the string and a dictionary containing the accessibilitySpeechIPANotation attribute key and the “Most rēd” or “laɪv” values.

Example code in the image:

let liveNewsChannelView = UIView()
let attributedLabel = NSMutableAttributedString(string: "24 hour news channel. ")

attributedLabel.append(NSAttributedString(string: "Live",attributes: [.accessibilitySpeechIPANotation: "laɪv"]))

liveNewsChannelView.accessibilityAttributedLabel = attributedLabel

Some of you have asked me how you can support what I do. This would really help, and would be hugely appreciated:

  • Find these posts useful? Share them at work, on social media, or with anyone that might find them interesting. Let's spread the word!

  • Check out any of my apps or games: Xarra!, RetroRapid!, or Mestre!.

    • A download and a review go a long way. They're free by default. On the App Store, ratings and reviews really help more people discover them.

    • Finding any of them useful? If so, and if you can afford it, purchasing lifetime access to all features or subscribing lets me buy the coffee that keeps me caffeinated. Caffeine keeps me going to maintain the apps, bring in new features that I hope you'll love, and keep writing.

You may also find interesting...

accessibilitySpeechIPANotation is useful for indicating how foreign words are pronounced. It really annoys me to hear the word paella constantly mispronounced 😁. You could also specify language, but this way, VoiceOver won't change its voice. Example code in the image: ```swift let recipeNameLabel = UILabel() let attributedLabel = NSAttributedString( string: "Paella", attributes: [.accessibilitySpeechIPANotation: "pɑːˈeɪə"] ) recipeNameLabel.accessibilityAttributedLabel = attributedLabel ```

An interesting speech attribute for attributed accessibility labels is accessibilitySpeechIPANotation that lets you specify how VoiceOver should pronounce a label with the International Phonetic Alphabet (IPA) notation. https://developer.apple.com/documentation/foundation/nsattributedstring/key/accessibilityspeechipanotation

The .summaryElement accessibility trait causes VoiceOver to announce that element when the app starts. The element won't get the focus though, and the order is not affected. A candidate for this trait could be the rings info in the Activity app.


Content © Daniel Devesa Derksen-Staats on Accessibility up to 11! is licensed under CC BY 4.0. License details