Warning: session_start(): open(/var/lib/php/sessions/sess_npoe6t1e3doh2qcmeqt20tt97h, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
scope androidSay_keepEngine.
import android.app.Activity;
import android.speech.tts.*;
sbool #verbose;
static TextToSpeech #tts;
// TODO: better way to sync than synchronizing on main class
static synchronized void androidSay_keepEngine(final S text, final Locale locale) {
final new Flag flag;
if (tts == null) {
if (verbose) print("Initialising TTS");
tts = new TextToSpeech(androidContext(), new TextToSpeech.OnInitListener() {
public void onInit(int status) {
try {
if (status != TextToSpeech.SUCCESS)
fail("Speech engine initialization failed");
go(text, locale, flag);
} catch (Throwable e) { e.printStackTrace(); flag.raise(); }
}
});
if (verbose) print("TTS object created");
else
androidSay_keepEngine_go(text, locale, flag);
flag.waitUntilUp();
}
static void #go(S text, Locale locale, final Flag flag) {
if (verbose) print("TTS go: " + text);
int result = tts.setLanguage(locale);
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED)
fail("German is not supported");
/*if (empty(text)) { // Empty text = Initialize engine only
flag.raise();
ret;
}*/
result = tts.setOnUtteranceProgressListener(new UtteranceProgressListener() {
public void onDone(String utteranceId) {
print("TTS done");
flag.raise();
}
public void onError(String utteranceId) {
print("TTS error");
flag.raise();
}
public void onStart(String utteranceId) {
if (verbose) print("TTS started");
}
});
if (result != TextToSpeech.SUCCESS)
print("Could not set listener");
//if (nempty(text)) print("[speech output] " + text);
new HashMap params;
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, randomID(8));
tts.speak(text, TextToSpeech.QUEUE_FLUSH, params);
}
end scope