i am developing one module to read text file and play as a voice using TTS. i have successfully integrated TTS in my module. and also reading and speaking first 4000 characters.
i have string with more then 4000 characters, it may have more then 10000 too. at this time i am unable to read file and play using TTS.
i have tried by splitting large string into a small part of string. each string part have 4000 characters.
while i am playing first string part, its working fine as required. but after completed of first string part, i want to start second part immediately. but TTS not starting it.
i am using
int pos = 0;
while(true) {
String var = "";
try {
var = str.substring(pos, 3999);
pos += 3999;
} catch(Exception e) {
var = str.substring(pos, str.length());
break;
}
HashMap<String, String> map = new HashMap<String, String>();
map.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "utteranceId");
tts.speak(var, TextToSpeech.QUEUE_ADD, map);
}
i have tried a lot. also searched on web but not getting any good solution.
there is one setOnUtteranceCompletedListener() i think this may be usefull. but how Can anyone please help me. how can i play large text using TTS. or any other technique available?