I want to write output from the TextToSpeech engine to my app's cache directory. In order to for the TTS to write there I first have to give it permissions to do so. But I don't know how. I understand that normally such problems can be solved by handing a FileDescriptor
over thus giving permissions to access a specific file. But I can't do that with TTS, as the TextToSpeech.synthesizeToFile method only accepts the file path as a String, no FileDescriptor
. So what to do?
To make my point that TTS really hasn't permissions to write to my app's directories, here's the code...:
TextToSpeech mTts = new new TextToSpeech(context, this);
mTts.synthesizeToFile(text, null, getCacheDir() + "/" + "speech.wav");
And the debugger log:
08-20 14:46:11.257: ERROR/TtsService(336): Can't create
/data/data/com.myorg.myapp/cache/speech.wav due to exception java.io.IOException: Permission denied