Warning: session_start(): open(/var/lib/php/sessions/sess_v489i7nc33r7rdi1seqi8nv4gm, 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
!7
module SpeechRecognitionControl {
S method = 'google;
transient JPanel stack;
transient new RestartableCountdown deleteIfUnused;
transient Set activeRequests;
transient ReliableSingleThread rstStartStop;
start {
rstStartStop = dm_rst(this, r startStop);
activeRequests = setWithNotify(rstStartStop);
startCountdown();
if (dm_getBounds() == null) {
int w = getWidth(dm_desktopPane()), h = getHeight(dm_desktopPane());
dm_setBounds(this, w-300, h-200, 300, h);
}
}
visualize {
ret withRightMargin(stack = dynamicVStack2());
}
// start countdown to delete module if unused
void startCountdown {
deleteIfUnused.start(60.0, rEnter dm_deleteModule);
}
void startStop {
if (nempty(activeRequests))
dm_requireAndCallModule("#1018551/SpeechRecognizer", 'startListening);
else
dm_findAndCallModule("#1018551/SpeechRecognizer", 'stopListening);
}
// API
// Note: cancelMe will be called in GUI thread
AutoCloseable activateSpeechRecognition(S reason) {
deleteIfUnused.stop();
final JLabel lbl = jlabel(reason);
final AutoCloseable release = autoCloseable {
removeAndValidate(c);
activeRequests.remove(this);
startCountdown();
};
final JComponent c = centerAndEast(lbl, jbutton("Cancel", r { close(release) }));
addAndValidate(stack, c);
ret addAndReturn(activeRequests, release);
}
}