Build out an audio player card in preperation for audio datasets and samples.

This commit is contained in:
Jaret Burkett
2026-02-03 08:15:55 -07:00
parent 50664c2421
commit 42acb0d4be
11 changed files with 843 additions and 12 deletions

View File

@@ -36,7 +36,7 @@ export async function POST(request: Request) {
* @returns Array of absolute paths to image files
*/
function findImagesRecursively(dir: string): string[] {
const imageExtensions = ['.png', '.jpg', '.jpeg', '.webp', '.mp4', '.avi', '.mov', '.mkv', '.wmv', '.m4v', '.flv'];
const imageExtensions = ['.png', '.jpg', '.jpeg', '.webp', '.mp4', '.avi', '.mov', '.mkv', '.wmv', '.m4v', '.flv', '.mp3', '.wav'];
let results: string[] = [];
const items = fs.readdirSync(dir);

View File

@@ -58,7 +58,10 @@ export async function GET(request: NextRequest, { params }: { params: { filePath
'.mkv': 'video/x-matroska',
'.wmv': 'video/x-ms-wmv',
'.m4v': 'video/x-m4v',
'.flv': 'video/x-flv'
'.flv': 'video/x-flv',
// Audio
'.mp3': 'audio/mpeg',
'.wav': 'audio/wav',
};
const contentType = contentTypeMap[ext] || 'application/octet-stream';

View File

@@ -55,7 +55,10 @@ export async function GET(request: NextRequest, { params }: { params: { imagePat
'.mkv': 'video/x-matroska',
'.wmv': 'video/x-ms-wmv',
'.m4v': 'video/x-m4v',
'.flv': 'video/x-flv'
'.flv': 'video/x-flv',
// Audio
'.mp3': 'audio/mpeg',
'.wav': 'audio/wav',
};
const contentType = contentTypeMap[ext] || 'application/octet-stream';

View File

@@ -15,7 +15,7 @@ export async function POST(request: Request) {
}
// make sure it is an image
if (!/\.(jpg|jpeg|png|bmp|gif|tiff|webp|mp4)$/i.test(imgPath.toLowerCase())) {
if (!/\.(jpg|jpeg|png|bmp|gif|tiff|webp|mp4|mp3|wav)$/i.test(imgPath.toLowerCase())) {
return NextResponse.json({ error: 'Not an image' }, { status: 400 });
}

View File

@@ -29,7 +29,7 @@ export async function GET(request: NextRequest, { params }: { params: { jobID: s
const samples = fs
.readdirSync(samplesFolder)
.filter(file => {
return file.endsWith('.png') || file.endsWith('.jpg') || file.endsWith('.jpeg') || file.endsWith('.webp') || file.endsWith('.mp4');
return file.endsWith('.png') || file.endsWith('.jpg') || file.endsWith('.jpeg') || file.endsWith('.webp') || file.endsWith('.mp4') || file.endsWith('mp3') || file.endsWith('wav');
})
.map(file => {
return path.join(samplesFolder, file);