Warning: session_start(): open(/var/lib/php/sessions/sess_5g3n2rl4muehhks0orq7u51irj, 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
set flag DynModule.
sclass Recording {
File file, clippedFile;
double clippedLength;
S text;
bool updateClip() {
clippedFile = fileIfExists(fileInSubDir(file, "clipped"));
if (clippedLength == 0)
try {
double l = lengthOfWAVInSeconds(clippedFile);
if (l != 0) ret true with clippedLength = l;
} catch print e {
clippedLength = -1;
}
false;
}
}
sclass AudioRecordings extends DynObjectTable {
start {
itemToMap = func(Recording r) -> Map {
litorderedmap(
Name := fileName(r.file),
"Clipped length" := r.clippedLength == 0 ? "" : formatDouble(r.clippedLength, 1) + " s",
Word := r.text)
};
setData(map(allRecordings(), func(File f) -> Recording {
nu(Recording,
file := f,
text := wordFromAudioFileName(f.getName()))
}));
thread "Get Clip Lengths" {
bool change = false;
for (Recording r : data)
if (r.updateClip()) set change;
if (change) updateTable();
}
}
visualize {
JComponent c = super.visualize();
ret withCenteredButtons(c,
tableDependentButton(table, "Play full", rThread { playWAV(selected().file) }),
tableDependentButton(table, "Play clipped", rThread { playWAV(selected().clippedFile) }),
tableDependentButton(table, "Clip", rThread {
autoClipRecording(selected().file);
updateTable();
}),
);
}
}