forked from chrisdonahue/ddc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
61 lines (51 loc) · 1.85 KB
/
Copy pathscript.js
File metadata and controls
61 lines (51 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(function(ddc, tf) {
const EXAMPLE_MP3 =
"https://cdn.glitch.com/b0d48e64-a514-4d74-bcf7-8ebe00ad9ebb%2Ftest1_22050.mp3?v=1573149419598";
const FEATURE_DIR =
"https://dancedanceconvolution.com/assets/feature_extraction";
const PLACEMENT_DIR =
"https://dancedanceconvolution.com/assets/step_placement";
const SELECTION_DIR =
"https://dancedanceconvolution.com/assets/step_selection";
function memoryUsageBytes() {
return tf.memory().numBytes;
}
async function init() {
console.log(`Allocated memory: ${memoryUsageBytes()}`);
/*
console.log("Loading audio");
const audio = await ddc.audioIO.loadFromUrl(EXAMPLE_MP3);
console.log("Extracting features");
await ddc.featureExtraction.initialize(FEATURE_DIR);
const features = await ddc.featureExtraction.extract(audio);
console.log("Scoring audio");
await ddc.stepPlacement.initialize(PLACEMENT_DIR);
const placementScores = await ddc.stepPlacement.place(
features,
ddc.difficulty.MEDIUM
);
console.log("Finding peaks");
const peaks = await ddc.stepPlacement.findPeaks(placementScores);
const peaksThresholded = ddc.stepPlacement.thresholdPeaks(
peaks,
ddc.difficulty.MEDIUM
);
console.log(peaksThresholded);
*/
const peaksThresholded = [7, 23, 31, 38];
const timestamps = ddc.stepPlacement.peaksToTimestamps(peaksThresholded);
console.log("Selecting steps");
await ddc.stepSelection.initialize(SELECTION_DIR);
const steps = await ddc.stepSelection.select(
timestamps,
ddc.difficulty.MEDIUM
);
await ddc.featureExtraction.dispose();
await ddc.stepPlacement.dispose();
await ddc.stepSelection.dispose();
//features.dispose();
//placementScores.dispose();
console.log(`Allocated memory: ${memoryUsageBytes()}`);
}
init();
})(window.ddc, window.tf);