Text to Speech Translation App - Android

1
Hello, I'm a beginner in android and would like to do a simple translator, where the user type anything and click on the button with the desired language to translate aloud, what would the translation algorithm look like in other languages? Follow my code

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout);

        edt_texto =(EditText)findViewById(R.id.edt_texto);
        btn =(Button)findViewById(R.id.btn);

        t2s = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(int status) {

                t2s.setLanguage(Locale.getDefault());

            }
        });

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String fala = edt_texto.getText().toString();

                t2s.speak(fala,TextToSpeech.QUEUE_FLUSH,null);
            }
        });
    }
    
asked by anonymous 11.05.2017 / 19:18

1 answer

2

You are already using other languages.

When using:

t2s.setLanguage(Locale.getDefault());

You are using the selected language on the device.

You can, however, define a different language with:

t2s.setLanguage( new Locale("en", "US"));

or

t2s.setLanguage( Locale.JAPAN );

or:

t2s.setLanguage( Locale.forLanguageTag("en-US") );
    
15.03.2018 / 16:15