I have used below code for synthesizing .txt
file to .mp3
file using Android built-in TTS Engine
.
Code:
textToSpeech.synthesizeToFile(readFileText, utterParam, destinationFileName);
textToSpeech.setOnUtteranceProgressListener(new UtteranceProgressListener() {
@Override
public void onStart(final String utteranceId) {
Log.e(TAG, "onStart...");
}
@Override
public void onDone(final String utteranceId) {
Log.e(TAG, "onDone...");
}
@Override
public void onError(String utteranceId) {
Log.e(TAG, "onError...");
}
});
Above is sample code. Here is flow of application execution:
- Get file from SD card
- Synthesize file to mp3
- Play a mp3 file
Issue : When file Synthesization is done then only I can play mp3 file. For even file of size 1 mb it is taking around 1 minute.
Is there any improvement I can do over?
Note : We need to use MediaPlayer
as we need to play/pause reader.
Thanks.