This is my sample code
<label id="label-id" for="input-id">some description</label>
<input id="input-id" aria-labelledby="label-id" placeholder="hello">
When i enable screen reader(Android Talkback), it reads the placeholder from the input tag and then reads the detected text from the input tag (So it reads placeholder twice)
How can i tell screen reader to read just place holder and do not detect any text in input tag?
I tried 'aria-label', 'aria-labelledby', 'aira-describedby' but it didn't work.
Text detection via OCR is something device and OS specific. It basically means that it may not be available (most of the cases it isn't, for example on desktop computers or older phones), and should be configurable.
It also means that you shouldn't try to interfere with it, because by doing so, you are well going to make accessibility worse for all the users who aren't using exactly the same device / OS / screen reader as yourself.
Most people don't have an OCR. If you disable the normal and only correct way of rendering information to screen readers, then the user won't see anything.
Additionally, OCR is often not that reliable. A slight change in font/size and other visual text characteristics can make it produce errors or fail. On a well accessible app or website, relying on it is totally uncessary. It's especially intended as a last ressort when the app or website isn't made screen reader accessible. If all apps and websites were perfectly accessible, OCR would be totally useless.
In your case, your code is perfectly accessible: the field has its label. So what the OCR might say is irrelevant. Disable it if you can, and otherwise just ignore it.
A small note about your code though: the attribute aria-labelledby on the <input>
is useless, since the link between the field and the label is already made with the for attribute of the <label>
.