3

I am trying to implement the accessibility to my ios project.

Is there a way to correct the pronunciation of some specific words when the voice-over is turned on? For example, The correct pronunciation of 'speech' is [spiːtʃ], but I want the voice-over to read all the words 'speech' as same as 'speak' [spiːk] during my whole project.

I know there is one way that I can set the accessibility label of any UIElements that I want to change the pronunciation to 'speak'. However, some elements are dynamic. For example, we get the label text from the back-end, but we will never know when the label text will be 'speech'. If I get the words 'speech' from the back end, I would like to hear voice-over read it as 'speak'.

Therefore, I would like to change the setting for the voice-over. Every time, If the words are 'speech', the voice-over will read as 'speak'.

Can I do it?

LightOwlGG
  • 139
  • 10
  • "> However, some elements are dynamic" - what do you mean by that? Anything that inherits from `NSObject` can have `accessibilityLabel`. You can't replace globally the words that screen reader pronounces, because it already pronounces what you tell it to - accessibility labels. – Eugene Dudnyk Feb 16 '21 at 21:20
  • Sorry for the unclear expression. What I mean is that if we fetch the label text from the back-end. The text will be dynamic, we will never know what would be the content of this label. What I want to do is to change the pronunciation of some specific words. 'Speech' is an example. If I get the words 'speech' from the back end, I would like to hear voice-over read it as 'speak'. – LightOwlGG Feb 16 '21 at 21:30
  • You could add the accessibility label text from the back end as well as a separate string in the payload. – GJ Nilsen Feb 16 '21 at 23:16

2 Answers2

4

Short answer.

Yes you can do it, but please do not.

Long Answer

Can I do it?

Yes, of course you can.

Simply fetch the data from the backend and do a find-replace on the string for any words you want spoken differently using a dictionary of words to replace, then add the new version of the string as the accessibility label.

SHOULD you do it?

Absolutely not.

Every time someone tries to "fix" pronunciation it ends up making things a lot worse.

I don't even understand why you would want screen reader users to hear "speak" whenever anyone else sees "speech", it does not make sense and is likely to break the meaning of sentences:

"I attended the speech given last night, it was very informative".

Would transform into:

"I attended the speak given last night, it was very informative"

Screen reader users are used to it.

A screen reader user is used to hearing things said differently (and incorrectly!), my guess is you have not been using a screen reader long enough to get used to the idiosyncrasies of screen reader speech.

Far from helping screen reader users you will actually end up making things worse.

I have only ever overridden screen reader default behaviour twice, once when it was a version number that was being read as a date and once when it was a password manager that read the password back and would try and read things as words.

Other than those very narrow examples I have not come across a reason to change things for a screen reader.

What about braille users?

You could change things because they don't sound right. But braille users also use screen readers and changing things for them could be very confusing (as per the example above of "speech").

What about best practices

"Give assistive technology users as similar an experience as possible to non assistive tech users". That is the number one guiding principle of accessibility, the second you change pronunciations and words, you potentially change the meaning of sentences and therefore offer a different experience.

Summing up

Anyway this is turning into a rant when it isn't meant to be (my apologies, I am just trying to get the point across as I answer similar questions to this quite often!), hopefully you get the idea, leave it alone and present the same info, I haven't even covered different speech synthesizers, language translation and more that using "unnatural" language can interfere with.

GrahamTheDev
  • 22,724
  • 2
  • 32
  • 64
  • 1
    Thanks for your response. 'Speech' and 'Speak' is just an example. Actually, I just want to correct the incorrect pronunciation by voice-over. Sometimes the voice-over will give an incorrect pronunciation for some words. – LightOwlGG Feb 17 '21 at 04:50
  • As I said you don't need to bother. Screen reader users are used to it and it will cause you far too many headaches. If you still want to go ahead then the dictionary lookup and replace is the way to go at runtime, but I don't want to promote that option any further as it is a bad practice. Save yourself some extra work and just leave them :-) there are always other accessibility battles to be won! hehe. – GrahamTheDev Feb 17 '21 at 09:11
  • Thank you for this extensive answer! This helped me deciding against using `^. ` in my `accessibilityLabel` to make it sound more right (to me). – laka Sep 24 '21 at 09:57
  • no problem @laka, glad you found it useful! – GrahamTheDev Sep 24 '21 at 11:31
0

The easiest solution is to return a 2nd string from the backend that is used just for the accessibilityLabel.

If you need a bit more control, you can pass an AttributedString as the accessibilityLabel with a number of different options for controlling pronunication

https://medium.com/macoclock/ios-attributed-accessibility-labels-f54b8dcbf9fa

chedabob
  • 5,835
  • 2
  • 24
  • 44