Android Talkback ad localization

I have a duo app lingo (english + spanish). I am implementing accessibility in my application and I want Talkback to read Spanish words in Spanish and English words in English. English and Spanish words will appear in separate text views. My app language is English and so Talkback + google text engine doesn't read Spanish words in Spanish, they read in English and more often their letters are read (expected behavior).

Is there any work or recommended Android solution to achieve the same.

Ultimately I want the Talkback service or custom accessibility service to read English words in English and Spanish words in Spanish.

+3


source to share


2 answers


DISCLAIMER: You must be extremely careful with this decision! The overriding TTS TalkBack behavior is very, VERY sketchy. There are many edge cases that can make this behavior awkward, cumbersome, and very poor in terms of accessibility. This solution should only be used if the declaration style is application specific behavior and functionality is REQUIRED. Otherwise, this solution breaks all WCAG 2.0 success criteria into user agent compatibility and is generally a terrible idea in terms of accessibility / usability!

In many cases, when I see questions like this, I hesitate to give an answer, lest I give the developers a tool they don't understand. PLEASE PLEASE PLEASE DO NOT DO THIS In a typical application, this is a terrible idea. That being said, I believe that this particular situation calls for it and that it is a very clean decision given the circumstances. When creating your activity, follow these steps:



findViewById(android.R.id.content).setAccessibilityDelegate(new View.AccessibilityDelegate() {

    private TextToSpeech mTts = new TextToSpeech(MainActivity.this, new TextToSpeech.OnInitListener() {
        @Override
        public void onInit(int status) {
            mTts.setLanguage(new Locale("es"));
            //Probably other things you should do to ensure TTS is initialized before requesting it speaks something.
        }
    });

    private boolean isSpanishView(View view) {
        return true;
    }

    @Override
    public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child, AccessibilityEvent event) {

        switch (event.getEventType()) {
            case AccessibilityEvent.TYPE_ANNOUNCEMENT:
            case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: {
                if (isSpanishView(child)) {
                    String speakableText = null;

                    if (event.getText() != null) {
                        speakableText = event.getText().toString();
                    } else if (event.getContentDescription() != null) {
                        speakableText = event.getContentDescription().toString();
                    }

                    if (speakableText != null) {
                        mTts.speak(speakableText.toString(), TextToSpeech.QUEUE_ADD, null);

                        //Prevent the default propagation of this event, have have handled it.
                        return false;
                    }
                }
            }

            default:
                return super.onRequestSendAccessibilityEvent(host, child, event);
        }
    }
});

      

Basically what we've been talking about here is attaching an accessibility delegate to the root view of our activity. Take a look at ALL Availability popups. Make sure it is an event that announces something. If so, make sure that it is a view containing Spanish text. If so, let our Spanish TTS Engine announce it instead of letting the fan spread. In all other cases, let the android do its job.

0


source


Google has announced an update that allows you to specify the language you want to read aloud. Here's an answer with links: fooobar.com/questions/2414618 / ...



0


source







All Articles