-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_samples_json.php
More file actions
55 lines (46 loc) · 1.31 KB
/
generate_samples_json.php
File metadata and controls
55 lines (46 loc) · 1.31 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
<?php
// Set the content type to JSON
header('Content-Type: application/json');
// Base directory for samples
$baseDir = 'flac/samples';
// Directories to scan
$directories = [
'GeneralSongs',
'Experimental',
'Instrumentals',
'MultipleLang',
'Controlability-retake',
'Controlability-repaint',
'Controlability-edit',
'Application-Lyric2Vocal',
'Text2Sample',
"RapMachine"
];
// Initialize the result array
$result = [];
// Scan each directory
foreach ($directories as $dir) {
$dirPath = $baseDir . '/' . $dir;
$result[$dir] = [];
// Check if directory exists
if (is_dir($dirPath)) {
// Get all .flac files in the directory
$files = glob($dirPath . '/*.flac');
// Process each file
foreach ($files as $file) {
// Get the filename without extension
$fileName = basename($file, '.flac');
// Create ID from file name (replace underscores with hyphens)
$id = str_replace('_', '-', $fileName);
// Add to the result array
$result[$dir][] = [
'id' => $id,
'fileName' => $fileName,
'directory' => $dir
];
}
}
}
// Output the JSON
echo json_encode($result, JSON_PRETTY_PRINT);
?>