Warning: session_start(): open(/var/lib/php/sessions/sess_87i2bs4jluontncn3ffuq1fris, 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
cmodule SpeechRecognizer {
switchable bool autoStart;
//bool hideChromeWindow; // doesn't work
transient new Flag flag;
switchable bool showHostTrayIcon = true;
switchable bool usePassiveLog;
transient S botName = "Chrome Speech.";
start {
O[] menuItems = litobjectarray(
"Start Listening", rThread startListening,
"Stop Listening", rThread stopListening,
"Switch to German", rThread switchToGerman,
"Switch to English", rThread switchToEnglish);
dm_addTrayIcon_left(componentPopupMenuItems(onLeftClick(
toolTip(jimage_16(#1101635), "Continuous Speech Recognizer"),
rThread startListening),
menuItems));
dm_reloadOnFieldChange showHostTrayIcon();
if (showHostTrayIcon)
dm_systemTrayIcon(#1101635, "Continuous Speech Recognizer", itemPlusArray(rThread startListening, menuItems));
dm_watchField usePassiveLog(r {
infoBox(or2(sendOpt(botName, usePassiveLog ? "use passive log" : "use active log"), "No response"));
});
if (autoStart) startListening();
}
visualize {
ret jfullcenter(jButtonWithInset("Start listening", rThread doIt));
}
void setLanguage(S language) { if (sendOpt("botName", "language *", language) == null) startRecognizer(true); }
void switchToEnglish { setLanguage("en-US"); }
void switchToGerman { setLanguage("de-DE"); }
void startListening { doIt(false); }
void justOnce { doIt(true); }
void doIt enter { doIt(false); }
void doIt(bool justOnce) enter {
if (sendOpt(botName, justOnce ? "just once" : "start recognition") == null)
startRecognizer(justOnce);
}
// only call if it's not running already
void startRecognizer(bool justOnce) {
print("Starting recognizer");
fO recognizer = hotwireDependent(#1009816);
setAll(recognizer, doLog := false/*, +hideChromeWindow*/, +usePassiveLog);
set(recognizer, onUtterance := voidfunc(S text) {
S corrected = dm_correctRecognizedSpeech(text);
if (neq(corrected, text)) {
print("Correcting " + quote(text) + " to " + quote(corrected));
vmBus_send('correctedRecognizedSpeech, text, corrected);
text = corrected;
} else
print("Recognized: " + text);
if (!dm_osInForeground())
flatInfoBox(text);
dm_setAIBarTextAndFireWithInfo(text, "Chrome Speech");
/*if (ai_isStopListeningCommand(text)) {
call(recognizer, 'stopRecognition);
playBlip();
}*/
});
set(recognizer, +justOnce);
/*if (flag.raise())
dm_putRecognizedSpeechInAIBar();*/
runMain(recognizer);
}
void stopListening enter {
sendOpt(botName, "stop recognition");
}
void enhanceFrame(JInternalFrame f) {
super.enhanceFrame(f);
internalFrameTitleMenuItems(f,
"Switch to German", rThread switchToGerman,
"Switch to English", rThread switchToEnglish);
}
}