5
    spoken1 = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
        @Override
        public void onInit(int status) {
            if(status != TextToSpeech.ERROR){
                spoken1.setLanguage(Locale.US);
            }
        }
    })
    f1 = new File("test1.wav");
    abc = spoken1.synthesizeToFile("text",null, f1, "test12");

Hi all, I'm newbie on android and java development. Currently I'm work for small app that convert TTS to audio file. I also make the app speaks what I want. I stuck with synthesizeToFile that was deprecated in API level 21 and above. the value of "abc" variable is always "-1". I also found some help with google but turn out no answer for API level 21 and above

Do someone know how to make synthesizeToFile method return positive? and get the audio file to media library too?

EDIT: I found why, How to grant Permission for create file is change between Android version, on my Local VM it is Android API level 24 which should request permission on running, and change permission in manifest is NOT ENOUGH for API level 24.
Also if API level 22 and below, the code run fine.

minhhq
  • 181
  • 2
  • 6

0 Answers0