3

I am developing a android translator app which have TTS feature also. My problem is the voice for Greek language not working properly. It just speak characters also does not speak in Hindi. I have goggled and found that google TTS not support Greek language. Will it be possible if I download the Greek language pack and then it will work properly. Please suggest me if it work or if not then what is the reasons.

maddy d
  • 1,530
  • 2
  • 12
  • 23

1 Answers1

4

I had same issue before.

You can use Google Online TTS.

It is my example code.

public void Online_TTS(final String text,final String lan) {

    new Thread(new Runnable() {
        @Override
        public void run() {
            String Url = "https://translate.google.com/translate_tts?ie=UTF-8";
            String pronouce = "&q=" + text.replaceAll(" ", "%20");
            String language = "&tl=" + lan;
            String web = "&client=tw-ob";

            String fullUrl = Url + pronouce + language + web;

            Uri uri = Uri.parse(fullUrl);
            MediaPlayer mediaPlayer = new MediaPlayer();
            try {
                mediaPlayer.setDataSource(MainActivity.this,uri);
                mediaPlayer.prepare();
                mediaPlayer.start();
            } catch (IOException e) {
                e.printStackTrace();
                Log.i(TAG,"error");
            }
        }
    }).start();
}

Hope to help you