Warning: session_start(): open(/var/lib/php/sessions/sess_pqpopr8i64r1tluao1oen5t793, 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
import static x30_pkg.x30_util.VF1;
sclass ListenOnNoise > DynPrintLog {
float threshold = 30f;
double interval = 10.0;
volatile bool enabled = true;
transient float lastVolume;
transient Q q;
visualize {
ret centerAndSouthWithMargins(super.visualize(),
jrightalignedline(dm_fieldCheckBox('enabled)));
}
void start {
q = dm_startQ();
dm_addAudioListener(voidfunc(short[] data) {
if (!enabled) ret;
// Quickly calculate the volume
final float vol = shortSamplesToPercentVolume(data);
// Do everything else in our own thread; don't pile up
if (q.isEmpty()) q.add(r {
//print("vol: " + vol);
if (vol >= threshold && lastVolume < threshold) {
printWithTime("Got noise (" + iround(vol) + "%)");
/*O katze = dm_getModule(dm_requireModule("#1016461/Katze"));
call(katze, 'listenJustOnce);*/
dm_enableSpeechRecognitionFor(interval);
}
lastVolume = vol;
});
});
}
}